diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index c5a7911a..c1437e25 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -630,28 +630,10 @@ GuiApplicationMain void GuiApplicationInitialize() { - Ptr theme; - { - WString osVersion=GetCurrentController()->GetOSVersion(); - vint index=osVersion.IndexOf(L';'); - if (index == -1) - { - theme=new win8::Win8Theme; - } - else - { - WString osMainVersion=osVersion.Sub(0, index); - if(osMainVersion==L"Windows 8" || osMainVersion==L"Windows Server 2012") - { - theme=new win8::Win8Theme; - } - else - { - theme=new win7::Win7Theme; - } - } - } - + // There will be a GacUI theme in the future + // win7::Win7Theme + // win8::Win8Theme + auto theme = MakePtr(); GetCurrentController()->InputService()->StartTimer(); #ifndef VCZH_DEBUG_NO_REFLECTION @@ -4451,6 +4433,7 @@ GuiWindow GetApplication()->InvokeInMainThread([=]() { WindowClosed.Detach(container->handler); + container->handler = nullptr; GetNativeWindow()->SetParent(0); callback(); owner->SetEnabled(true); @@ -18564,6 +18547,11 @@ Win7DocumentViewerStyle return nullptr; } + Color Win7DocumentViewerStyle::GetCaretColor() + { + return Color(0, 0, 0); + } + /*********************************************************************** Win7DocumentlabelStyle ***********************************************************************/ @@ -22672,6 +22660,11 @@ Win8DocumentViewerStyle return nullptr; } + Color Win8DocumentViewerStyle::GetCaretColor() + { + return Color(0, 0, 0); + } + /*********************************************************************** Win8DocumentlabelStyle ***********************************************************************/ @@ -25388,6 +25381,11 @@ GuiDocumentViewerTemplate_StyleProvider return controlTemplate->GetBaselineDocument(); } + Color GuiDocumentViewerTemplate_StyleProvider::GetCaretColor() + { + return controlTemplate->GetCaretColor(); + } + /*********************************************************************** GuiTextListTemplate_StyleProvider::ItemStyleProvider ***********************************************************************/ @@ -26621,6 +26619,7 @@ GuiDocumentCommonInterface documentElement=GuiDocumentElement::Create(); documentElement->SetCallback(this); + documentElement->SetCaretColor(caretColor); documentComposition=new GuiBoundsComposition; documentComposition->SetOwnedElement(documentElement); @@ -26985,8 +26984,9 @@ GuiDocumentCommonInterface //================ basic - GuiDocumentCommonInterface::GuiDocumentCommonInterface(Ptr _baselineDocument) + GuiDocumentCommonInterface::GuiDocumentCommonInterface(Ptr _baselineDocument, Color _caretColor) :baselineDocument(_baselineDocument) + ,caretColor(_caretColor) ,documentElement(0) ,documentComposition(0) ,activeHyperlinkParagraph(-1) @@ -30346,7 +30346,7 @@ GuiGrammarAutoComplete else { // initialize a TextLines with the latest modifiedCode - text::TextLines lines; + text::TextLines lines(nullptr); lines.SetText(newContext.modifiedCode); FOREACH(TextEditNotifyStruct, trace, usedTrace) { @@ -33337,7 +33337,6 @@ GuiWindowComposition ***********************************************************************/ GuiWindowComposition::GuiWindowComposition() - :attachedWindow(0) { } @@ -33345,20 +33344,18 @@ GuiWindowComposition { } - INativeWindow* GuiWindowComposition::GetAttachedWindow() - { - return attachedWindow; - } - - void GuiWindowComposition::SetAttachedWindow(INativeWindow* window) - { - attachedWindow=window; - SetRenderTarget(attachedWindow?GetGuiGraphicsResourceManager()->GetRenderTarget(attachedWindow):0); - } - Rect GuiWindowComposition::GetBounds() { - return attachedWindow?Rect(Point(0, 0), attachedWindow->GetClientSize()):Rect(); + 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) @@ -33371,7 +33368,6 @@ GuiBoundsComposition GuiBoundsComposition::GuiBoundsComposition() { - ClearAlignmentToParent(); } GuiBoundsComposition::~GuiBoundsComposition() @@ -33380,28 +33376,28 @@ GuiBoundsComposition Rect GuiBoundsComposition::GetPreferredBounds() { - Rect result=GetBoundsInternal(compositionBounds); - if(GetParent() && IsAlignedToParent()) + Rect result = GetBoundsInternal(compositionBounds); + if (GetParent() && IsAlignedToParent()) { - if(alignmentToParent.left>=0) + if (alignmentToParent.left >= 0) { - vint offset=alignmentToParent.left-result.x1; - result.x1+=offset; - result.x2+=offset; + vint offset = alignmentToParent.left - result.x1; + result.x1 += offset; + result.x2 += offset; } - if(alignmentToParent.top>=0) + if (alignmentToParent.top >= 0) { - vint offset=alignmentToParent.top-result.y1; - result.y1+=offset; - result.y2+=offset; + vint offset = alignmentToParent.top - result.y1; + result.y1 += offset; + result.y2 += offset; } - if(alignmentToParent.right>=0) + if (alignmentToParent.right >= 0) { - result.x2+=alignmentToParent.right; + result.x2 += alignmentToParent.right; } - if(alignmentToParent.bottom>=0) + if (alignmentToParent.bottom >= 0) { - result.y2+=alignmentToParent.bottom; + result.y2 += alignmentToParent.bottom; } } return result; @@ -33409,44 +33405,44 @@ GuiBoundsComposition Rect GuiBoundsComposition::GetBounds() { - Rect result=GetPreferredBounds(); - if(GetParent() && IsAlignedToParent()) + Rect result = GetPreferredBounds(); + if (GetParent() && IsAlignedToParent()) { - Size clientSize=GetParent()->GetClientArea().GetSize(); - if(alignmentToParent.left>=0 && alignmentToParent.right>=0) + Size clientSize = GetParent()->GetClientArea().GetSize(); + if (alignmentToParent.left >= 0 && alignmentToParent.right >= 0) { - result.x1=alignmentToParent.left; - result.x2=clientSize.x-alignmentToParent.right; + result.x1 = alignmentToParent.left; + result.x2 = clientSize.x - alignmentToParent.right; } - else if(alignmentToParent.left>=0) + else if (alignmentToParent.left >= 0) { - vint width=result.Width(); - result.x1=alignmentToParent.left; - result.x2=result.x1+width; + vint width = result.Width(); + result.x1 = alignmentToParent.left; + result.x2 = result.x1 + width; } - else if(alignmentToParent.right>=0) + else if (alignmentToParent.right >= 0) { - vint width=result.Width(); - result.x2=clientSize.x-alignmentToParent.right; - result.x1=result.x2-width; + vint width = result.Width(); + result.x2 = clientSize.x - alignmentToParent.right; + result.x1 = result.x2 - width; } - if(alignmentToParent.top>=0 && alignmentToParent.bottom>=0) + if (alignmentToParent.top >= 0 && alignmentToParent.bottom >= 0) { - result.y1=alignmentToParent.top; - result.y2=clientSize.y-alignmentToParent.bottom; + result.y1 = alignmentToParent.top; + result.y2 = clientSize.y - alignmentToParent.bottom; } - else if(alignmentToParent.top>=0) + else if (alignmentToParent.top >= 0) { - vint height=result.Height(); - result.y1=alignmentToParent.top; - result.y2=result.y1+height; + vint height = result.Height(); + result.y1 = alignmentToParent.top; + result.y2 = result.y1 + height; } - else if(alignmentToParent.bottom>=0) + else if (alignmentToParent.bottom >= 0) { - vint height=result.Height(); - result.y2=clientSize.y-alignmentToParent.bottom; - result.y1=result.y2-height; + vint height = result.Height(); + result.y2 = clientSize.y - alignmentToParent.bottom; + result.y1 = result.y2 - height; } } UpdatePreviousBounds(result); @@ -33455,12 +33451,8 @@ GuiBoundsComposition void GuiBoundsComposition::SetBounds(Rect value) { - compositionBounds=value; - } - - void GuiBoundsComposition::ClearAlignmentToParent() - { - alignmentToParent=Margin(-1, -1, -1, -1); + compositionBounds = value; + InvokeOnCompositionStateChanged(); } Margin GuiBoundsComposition::GetAlignmentToParent() @@ -33470,12 +33462,13 @@ GuiBoundsComposition void GuiBoundsComposition::SetAlignmentToParent(Margin value) { - alignmentToParent=value; + alignmentToParent = value; + InvokeOnCompositionStateChanged(); } bool GuiBoundsComposition::IsAlignedToParent() { - return alignmentToParent!=Margin(-1, -1, -1, -1); + return alignmentToParent != Margin(-1, -1, -1, -1); } } } @@ -33505,6 +33498,7 @@ GuiSharedSizeItemComposition { parentRoot->ForceCalculateSizeImmediately(); } + InvokeOnCompositionStateChanged(); } void GuiSharedSizeItemComposition::OnParentLineChanged() @@ -33676,6 +33670,11 @@ namespace vl using namespace controls; using namespace elements; + void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition) + { + composition->InvokeOnCompositionStateChanged(); + } + /*********************************************************************** GuiGraphicsComposition ***********************************************************************/ @@ -33725,12 +33724,58 @@ GuiGraphicsComposition } } - void GuiGraphicsComposition::OnRenderTargetChanged() + void GuiGraphicsComposition::OnRenderContextChanged() { - if(associatedControl) + } + + void GuiGraphicsComposition::UpdateRelatedHostRecord(GraphicsHostRecord* record) + { + relatedHostRecord = record; + auto renderTarget = GetRenderTarget(); + if (ownedElement) + { + if (auto renderer = ownedElement->GetRenderer()) + { + renderer->SetRenderTarget(renderTarget); + } + } + if (associatedControl) { associatedControl->OnRenderTargetChanged(renderTarget); } + OnRenderContextChanged(); + + for (vint i = 0; i < children.Count(); i++) + { + children[i]->UpdateRelatedHostRecord(record); + } + } + + 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) @@ -33745,13 +33790,8 @@ GuiGraphicsComposition } GuiGraphicsComposition::GuiGraphicsComposition() - :parent(0) - ,visible(true) + :visible(true) ,minSizeLimitation(NoLimit) - ,renderTarget(0) - ,associatedControl(0) - ,associatedHost(0) - ,associatedCursor(0) ,associatedHitTestResult(INativeWindowListener::NoDecision) { sharedPtrDestructorProc = &GuiGraphicsComposition::SharedPtrDestructorProc; @@ -33782,31 +33822,33 @@ GuiGraphicsComposition bool GuiGraphicsComposition::InsertChild(vint index, GuiGraphicsComposition* child) { - if(!child) return false; - if(child->GetParent()) return false; + if (!child) return false; + if (child->GetParent()) return false; children.Insert(index, child); - child->parent=this; - child->SetRenderTarget(renderTarget); + child->parent = this; + child->UpdateRelatedHostRecord(relatedHostRecord); OnChildInserted(child); - child->OnParentChanged(0, child->parent); + child->OnParentChanged(nullptr, child->parent); + InvokeOnCompositionStateChanged(); return true; } bool GuiGraphicsComposition::RemoveChild(GuiGraphicsComposition* child) { - if(!child) return false; - vint index=children.IndexOf(child); - if(index==-1) return false; - child->OnParentChanged(child->parent, 0); + if (!child) return false; + vint index = children.IndexOf(child); + if (index == -1) return false; + child->OnParentChanged(child->parent, nullptr); OnChildRemoved(child); - child->SetRenderTarget(0); - child->parent=0; - GuiGraphicsHost* host=GetRelatedGraphicsHost(); - if(host) + child->UpdateRelatedHostRecord(nullptr); + child->parent = nullptr; + GuiGraphicsHost* host = GetRelatedGraphicsHost(); + if (host) { host->DisconnectComposition(child); } children.RemoveAt(index); + InvokeOnCompositionStateChanged(); return true; } @@ -33817,6 +33859,7 @@ GuiGraphicsComposition if(index==-1) return false; children.RemoveAt(index); children.Insert(newIndex, child); + InvokeOnCompositionStateChanged(); return true; } @@ -33827,22 +33870,26 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetOwnedElement(Ptr element) { - if(ownedElement) + if (ownedElement != element) { - IGuiGraphicsRenderer* renderer=ownedElement->GetRenderer(); - if(renderer) + if (ownedElement) { - renderer->SetRenderTarget(0); + if (auto renderer = ownedElement->GetRenderer()) + { + renderer->SetRenderTarget(nullptr); + } + ownedElement->SetOwnerComposition(nullptr); } - } - ownedElement=element; - if(ownedElement) - { - IGuiGraphicsRenderer* renderer=ownedElement->GetRenderer(); - if(renderer) + ownedElement = element; + if (ownedElement) { - renderer->SetRenderTarget(renderTarget); + if (auto renderer = ownedElement->GetRenderer()) + { + renderer->SetRenderTarget(GetRenderTarget()); + } + ownedElement->SetOwnerComposition(this); } + InvokeOnCompositionStateChanged(); } } @@ -33853,7 +33900,8 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetVisible(bool value) { - visible=value; + visible = value; + InvokeOnCompositionStateChanged(); } GuiGraphicsComposition::MinSizeLimitation GuiGraphicsComposition::GetMinSizeLimitation() @@ -33863,70 +33911,54 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetMinSizeLimitation(MinSizeLimitation value) { - minSizeLimitation=value; + minSizeLimitation = value; + InvokeOnCompositionStateChanged(); } - IGuiGraphicsRenderTarget* GuiGraphicsComposition::GetRenderTarget() + elements::IGuiGraphicsRenderTarget* GuiGraphicsComposition::GetRenderTarget() { - return renderTarget; - } - - void GuiGraphicsComposition::SetRenderTarget(IGuiGraphicsRenderTarget* value) - { - renderTarget=value; - if(ownedElement) - { - IGuiGraphicsRenderer* renderer=ownedElement->GetRenderer(); - if(renderer) - { - renderer->SetRenderTarget(renderTarget); - } - } - for(vint i=0;iSetRenderTarget(renderTarget); - } - OnRenderTargetChanged(); + return relatedHostRecord ? relatedHostRecord->renderTarget : nullptr; } void GuiGraphicsComposition::Render(Size offset) { - if(visible && renderTarget && !renderTarget->IsClipperCoverWholeTarget()) + 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; + 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) + 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; + bounds.x1 += offset.x; + bounds.x2 += offset.x; + bounds.y1 += offset.y; + bounds.y2 += offset.y; - if(ownedElement) + if (ownedElement) { - IGuiGraphicsRenderer* renderer=ownedElement->GetRenderer(); - if(renderer) + IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); + if (renderer) { renderer->Render(bounds); } } - if(children.Count()>0) + 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) + 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(); + offset = bounds.GetSize(); renderTarget->PushClipper(bounds); - if(!renderTarget->IsClipperCoverWholeTarget()) + if (!renderTarget->IsClipperCoverWholeTarget()) { - for(vint i=0;iRender(Size(bounds.x1, bounds.y1)); } @@ -33954,21 +33986,21 @@ GuiGraphicsComposition GuiGraphicsComposition* GuiGraphicsComposition::FindComposition(Point location) { - if(!visible) return 0; - Rect bounds=GetBounds(); - Rect relativeBounds=Rect(Point(0, 0), bounds.GetSize()); - if(relativeBounds.Contains(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--) + 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) + 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; } @@ -33983,17 +34015,17 @@ GuiGraphicsComposition Rect GuiGraphicsComposition::GetGlobalBounds() { - Rect bounds=GetBounds(); - GuiGraphicsComposition* composition=parent; - while(composition) + 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; + 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; } @@ -34003,33 +34035,16 @@ GuiGraphicsComposition return associatedControl; } - void GuiGraphicsComposition::SetAssociatedControl(controls::GuiControl* control) - { - if(associatedControl) - { - for(vint i=0;iOnControlParentChanged(0); - } - } - associatedControl=control; - if(associatedControl) - { - for(vint i=0;iOnControlParentChanged(associatedControl); - } - } - } - GuiGraphicsHost* GuiGraphicsComposition::GetAssociatedHost() { - return associatedHost; - } - - void GuiGraphicsComposition::SetAssociatedHost(GuiGraphicsHost* host) - { - associatedHost=host; + if (relatedHostRecord && relatedHostRecord->host->GetMainComposition() == this) + { + return relatedHostRecord->host; + } + else + { + return nullptr; + } } INativeCursor* GuiGraphicsComposition::GetAssociatedCursor() @@ -34039,7 +34054,7 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetAssociatedCursor(INativeCursor* cursor) { - associatedCursor=cursor; + associatedCursor = cursor; } INativeWindowListener::HitTestResult GuiGraphicsComposition::GetAssociatedHitTestResult() @@ -34049,76 +34064,55 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetAssociatedHitTestResult(INativeWindowListener::HitTestResult value) { - associatedHitTestResult=value; + associatedHitTestResult = value; } controls::GuiControl* GuiGraphicsComposition::GetRelatedControl() { - GuiGraphicsComposition* composition=this; - while(composition) + GuiGraphicsComposition* composition = this; + while (composition) { - if(composition->GetAssociatedControl()) + if (composition->GetAssociatedControl()) { return composition->GetAssociatedControl(); } else { - composition=composition->GetParent(); + composition = composition->GetParent(); } } - return 0; + return nullptr; } GuiGraphicsHost* GuiGraphicsComposition::GetRelatedGraphicsHost() { - GuiGraphicsComposition* composition=this; - while(composition) - { - if(composition->GetAssociatedHost()) - { - return composition->GetAssociatedHost(); - } - else - { - composition=composition->GetParent(); - } - } - return 0; + return relatedHostRecord ? relatedHostRecord->host : nullptr; } controls::GuiControlHost* GuiGraphicsComposition::GetRelatedControlHost() { - GuiGraphicsComposition* composition=this; - while(composition) + if (auto control = GetRelatedControl()) { - if(composition->GetAssociatedControl()) - { - GuiControlHost* controlHost=dynamic_cast(composition->GetAssociatedControl()); - if(controlHost) - { - return controlHost; - } - } - composition=composition->GetParent(); + return control->GetRelatedControlHost(); } - return 0; + return nullptr; } INativeCursor* GuiGraphicsComposition::GetRelatedCursor() { - GuiGraphicsComposition* composition=this; - while(composition) + GuiGraphicsComposition* composition = this; + while (composition) { - if(composition->GetAssociatedCursor()) + if (composition->GetAssociatedCursor()) { return composition->GetAssociatedCursor(); } else { - composition=composition->GetParent(); + composition = composition->GetParent(); } } - return 0; + return nullptr; } Margin GuiGraphicsComposition::GetMargin() @@ -34128,7 +34122,8 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetMargin(Margin value) { - margin=value; + margin = value; + InvokeOnCompositionStateChanged(); } Margin GuiGraphicsComposition::GetInternalMargin() @@ -34138,7 +34133,8 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetInternalMargin(Margin value) { - internalMargin=value; + internalMargin = value; + InvokeOnCompositionStateChanged(); } Size GuiGraphicsComposition::GetPreferredMinSize() @@ -34148,7 +34144,8 @@ GuiGraphicsComposition void GuiGraphicsComposition::SetPreferredMinSize(Size value) { - preferredMinSize=value; + preferredMinSize = value; + InvokeOnCompositionStateChanged(); } Rect GuiGraphicsComposition::GetClientArea() @@ -34163,10 +34160,11 @@ GuiGraphicsComposition void GuiGraphicsComposition::ForceCalculateSizeImmediately() { - for(vint i=0;iForceCalculateSizeImmediately(); } + InvokeOnCompositionStateChanged(); } /*********************************************************************** @@ -34175,25 +34173,26 @@ GuiGraphicsSite Rect GuiGraphicsSite::GetBoundsInternal(Rect expectedBounds) { - Size minSize=GetMinPreferredClientSize(); - if(minSize.xGetRenderer(); - if(renderer) + IGuiGraphicsRenderer* renderer = ownedElement->GetRenderer(); + if (renderer) { - minSize=renderer->GetMinSize(); + minSize = renderer->GetMinSize(); } } } - if(minSizeLimitation==GuiGraphicsComposition::LimitToElementAndChildren) + if (minSizeLimitation == GuiGraphicsComposition::LimitToElementAndChildren) { - vint childCount=Children().Count(); - for(vint i=0;iIsSizeAffectParent()) + GuiGraphicsComposition* child = children[i]; + if (child->IsSizeAffectParent()) { - Rect childBounds=child->GetPreferredBounds(); - if(minSize.xGetPreferredBounds(); + if (minSize.x < childBounds.x2) minSize.x = childBounds.x2; + if (minSize.y < childBounds.y2) minSize.y = childBounds.y2; } } } @@ -34369,6 +34368,8 @@ GuiFlowComposition 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; @@ -34476,10 +34477,10 @@ GuiFlowComposition Point( itemLeft + clientMargin.left, itemTop + clientMargin.top - ), + ), itemSize - ) - ); + ) + ); rowUsedWidth += itemSize.x; } @@ -34510,8 +34511,8 @@ GuiFlowComposition void GuiFlowComposition::OnChildRemoved(GuiGraphicsComposition* child) { GuiBoundsComposition::OnChildRemoved(child); - auto item=dynamic_cast(child); - if(item) + auto item = dynamic_cast(child); + if (item) { flowItems.Remove(item); needUpdate = true; @@ -34542,6 +34543,7 @@ GuiFlowComposition { extraMargin = value; needUpdate = true; + InvokeOnCompositionStateChanged(); } vint GuiFlowComposition::GetRowPadding() @@ -34553,6 +34555,7 @@ GuiFlowComposition { rowPadding = value; needUpdate = true; + InvokeOnCompositionStateChanged(); } vint GuiFlowComposition::GetColumnPadding() @@ -34564,6 +34567,7 @@ GuiFlowComposition { columnPadding = value; needUpdate = true; + InvokeOnCompositionStateChanged(); } Ptr GuiFlowComposition::GetAxis() @@ -34577,6 +34581,7 @@ GuiFlowComposition { axis = value; needUpdate = true; + InvokeOnCompositionStateChanged(); } } @@ -34589,6 +34594,7 @@ GuiFlowComposition { alignment = value; needUpdate = true; + InvokeOnCompositionStateChanged(); } void GuiFlowComposition::ForceCalculateSizeImmediately() @@ -34703,6 +34709,7 @@ GuiFlowItemComposition void GuiFlowItemComposition::SetBounds(Rect value) { bounds = value; + InvokeOnCompositionStateChanged(); } Margin GuiFlowItemComposition::GetExtraMargin() @@ -34713,6 +34720,7 @@ GuiFlowItemComposition void GuiFlowItemComposition::SetExtraMargin(Margin value) { extraMargin = value; + InvokeOnCompositionStateChanged(); } GuiFlowOption GuiFlowItemComposition::GetFlowOption() @@ -34726,6 +34734,7 @@ GuiFlowItemComposition if (flowParent) { flowParent->needUpdate = true; + InvokeOnCompositionStateChanged(); } } } @@ -34765,7 +34774,8 @@ GuiSideAlignedComposition void GuiSideAlignedComposition::SetDirection(Direction value) { - direction=value; + direction = value; + InvokeOnCompositionStateChanged(); } vint GuiSideAlignedComposition::GetMaxLength() @@ -34775,8 +34785,9 @@ GuiSideAlignedComposition void GuiSideAlignedComposition::SetMaxLength(vint value) { - if(value<0) value=0; - maxLength=value; + if (value < 0) value = 0; + maxLength = value; + InvokeOnCompositionStateChanged(); } double GuiSideAlignedComposition::GetMaxRatio() @@ -34786,10 +34797,11 @@ GuiSideAlignedComposition void GuiSideAlignedComposition::SetMaxRatio(double value) { - maxRatio= - value<0?0: - value>1?1: + maxRatio = + value < 0 ? 0 : + value>1 ? 1 : value; + InvokeOnCompositionStateChanged(); } bool GuiSideAlignedComposition::IsSizeAffectParent() @@ -34800,34 +34812,34 @@ GuiSideAlignedComposition Rect GuiSideAlignedComposition::GetBounds() { Rect result; - GuiGraphicsComposition* parent=GetParent(); - if(parent) + 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) + 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; + bounds.x2 = bounds.x1 + w; } break; case Top: { - bounds.y2=bounds.y1+h; + bounds.y2 = bounds.y1 + h; } break; case Right: { - bounds.x1=bounds.x2-w; + bounds.x1 = bounds.x2 - w; } break; case Bottom: { - bounds.y1=bounds.y2-h; + bounds.y1 = bounds.y2 - h; } break; } @@ -34875,22 +34887,26 @@ GuiPartialViewComposition void GuiPartialViewComposition::SetWidthRatio(double value) { - wRatio=value; + wRatio = value; + InvokeOnCompositionStateChanged(); } void GuiPartialViewComposition::SetWidthPageSize(double value) { - wPageSize=value; + wPageSize = value; + InvokeOnCompositionStateChanged(); } void GuiPartialViewComposition::SetHeightRatio(double value) { - hRatio=value; + hRatio = value; + InvokeOnCompositionStateChanged(); } void GuiPartialViewComposition::SetHeightPageSize(double value) { - hPageSize=value; + hPageSize = value; + InvokeOnCompositionStateChanged(); } bool GuiPartialViewComposition::IsSizeAffectParent() @@ -34901,24 +34917,24 @@ GuiPartialViewComposition Rect GuiPartialViewComposition::GetBounds() { Rect result; - GuiGraphicsComposition* parent=GetParent(); - if(parent) + 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); + 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; + 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; + w -= ow; + h -= oh; + pw += ow; + ph += oh; result = Rect(Point((vint)(wRatio*w), (vint)(hRatio*h)), Size(pw, ph)); } @@ -35024,6 +35040,7 @@ GuiStackComposition } } + InvokeOnCompositionStateChanged(); #undef ADJUSTMENT } @@ -35049,8 +35066,8 @@ GuiStackComposition void GuiStackComposition::OnChildRemoved(GuiGraphicsComposition* child) { GuiBoundsComposition::OnChildRemoved(child); - GuiStackItemComposition* item=dynamic_cast(child); - if(item) + GuiStackItemComposition* item = dynamic_cast(child); + if (item) { stackItems.Remove(item); if (item == ensuringVisibleStackItem) @@ -35077,8 +35094,8 @@ GuiStackComposition bool GuiStackComposition::InsertStackItem(vint index, GuiStackItemComposition* item) { - index=stackItems.Insert(index, item); - if(!AddChild(item)) + index = stackItems.Insert(index, item); + if (!AddChild(item)) { stackItems.RemoveAt(index); return false; @@ -35130,7 +35147,7 @@ GuiStackComposition } } if (!ensuringVisibleStackItem || direction == Horizontal || direction == ReversedHorizontal) - { + { if (minSize.y < stackItemTotalSize.y) { minSize.y = stackItemTotalSize.y; @@ -35309,6 +35326,7 @@ GuiStackItemComposition void GuiStackItemComposition::SetBounds(Rect value) { bounds = value; + InvokeOnCompositionStateChanged(); } Margin GuiStackItemComposition::GetExtraMargin() @@ -35319,6 +35337,7 @@ GuiStackItemComposition void GuiStackItemComposition::SetExtraMargin(Margin value) { extraMargin = value; + InvokeOnCompositionStateChanged(); } } } @@ -35388,12 +35407,12 @@ GuiTableComposition vint GuiTableComposition::GetSiteIndex(vint _rows, vint _columns, vint _row, vint _column) { - return _row*_columns+_column; + return _row*_columns + _column; } void GuiTableComposition::SetSitedCell(vint _row, vint _column, GuiCellComposition* cell) { - cellCompositions[GetSiteIndex(rows, columns, _row, _column)]=cell; + cellCompositions[GetSiteIndex(rows, columns, _row, _column)] = cell; } void GuiTableComposition::UpdateCellBoundsInternal( @@ -35403,57 +35422,57 @@ GuiTableComposition 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(*getSize)(Size), + vint(*getLocation)(GuiCellComposition*), + vint(*getSpan)(GuiCellComposition*), + vint(*getRow)(vint, vint), + vint(*getCol)(vint, vint), vint maxPass - ) + ) { - for(vint pass=0;pass*dim1;i++) + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(pass==0) + GuiCellOption option = dimOptions[i]; + if (pass == 0) { - dimSizes[i]=0; + dimSizes[i] = 0; } - switch(option.composeType) + switch (option.composeType) { case GuiCellOption::Absolute: { - dimSizes[i]=option.absolute; + dimSizes[i] = option.absolute; } break; case GuiCellOption::MinSize: { - for(vint j=0;j*dim2;j++) + for (vint j = 0; j < this->*dim2; j++) { - GuiCellComposition* cell=GetSitedCell(getRow(i, j), getCol(i, j)); - if(cell) + GuiCellComposition* cell = GetSitedCell(getRow(i, j), getCol(i, j)); + if (cell) { - bool accept=false; - if(pass==0) + bool accept = false; + if (pass == 0) { - accept=getSpan(cell)==1; + accept = getSpan(cell) == 1; } else { - accept=getLocation(cell)+getSpan(cell)==i+1; + accept = getLocation(cell) + getSpan(cell) == i + 1; } - if(accept) + if (accept) { - vint size=getSize(cell->GetPreferredBounds().GetSize()); - vint span=getSpan(cell); - for(vint k=1;kGetPreferredBounds().GetSize()); + vint span = getSpan(cell); + for (vint k = 1; k < span; k++) { - size-=dimSizes[i-k]+cellPadding; + size -= dimSizes[i - k] + cellPadding; } - if(dimSizes[i]*dim1;i++) + + bool percentageExists = false; + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(option.composeType==GuiCellOption::Percentage) + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) { - if(0.001*dim1;i++) + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(option.composeType==GuiCellOption::Percentage) + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) { - if(0.001*dim2;j++) + for (vint j = 0; j < this->*dim2; j++) { - GuiCellComposition* cell=GetSitedCell(getRow(i, j), getCol(i, j)); - if(cell) + 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; + 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*dim1;i++) + vint percentageTotalSize = 0; + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(option.composeType==GuiCellOption::Percentage) + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) { - if(0.001*dim1;i++) + double totalPercentage = 0; + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(option.composeType==GuiCellOption::Percentage) + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) { - if(0.001*dim1;i++) + + for (vint i = 0; i < this->*dim1; i++) { - GuiCellOption option=dimOptions[i]; - if(option.composeType==GuiCellOption::Percentage) + GuiCellOption option = dimOptions[i]; + if (option.composeType == GuiCellOption::Percentage) { - if(0.001*dim1;i++) + for (vint i = 0; i < this->*dim1; i++) { - if(dimOptions[i].composeType!=GuiCellOption::Percentage) + if (dimOptions[i].composeType != GuiCellOption::Percentage) { - dimSize+=dimSizes[i]; + dimSize += dimSizes[i]; } - dimSizeWithPercentage+=dimSizes[i]; + dimSizeWithPercentage += dimSizes[i]; } } @@ -35586,29 +35605,29 @@ GuiTableComposition vint dimSize, vint maxDimSize, collections::Array& dimOptions - ) + ) { - if(maxDimSize>dimSize) + if (maxDimSize > dimSize) { - double totalPercentage=0; - vint percentageCount=0; - for(vint i=0;i0 && totalPercentage>0.001) + if (percentageCount > 0 && totalPercentage > 0.001) { - for(vint i=0;i(Children().Get(i)); - if(cell) + GuiCellComposition* cell = dynamic_cast(Children().Get(i)); + if (cell) { cell->OnTableRowsAndColumnsChanged(); } } ConfigChanged.Execute(GuiEventArgs(this)); UpdateCellBounds(); + InvokeOnCompositionStateChanged(); return true; } @@ -35812,7 +35832,8 @@ GuiTableComposition void GuiTableComposition::SetRowOption(vint _row, GuiCellOption option) { - rowOptions[_row]=option; + rowOptions[_row] = option; + InvokeOnCompositionStateChanged(); ConfigChanged.Execute(GuiEventArgs(this)); } @@ -35823,7 +35844,8 @@ GuiTableComposition void GuiTableComposition::SetColumnOption(vint _column, GuiCellOption option) { - columnOptions[_column]=option; + columnOptions[_column] = option; + InvokeOnCompositionStateChanged(); ConfigChanged.Execute(GuiEventArgs(this)); } @@ -35834,8 +35856,9 @@ GuiTableComposition void GuiTableComposition::SetCellPadding(vint value) { - if(value<0) value=0; - cellPadding=value; + if (value < 0) value = 0; + cellPadding = value; + InvokeOnCompositionStateChanged(); } bool GuiTableComposition::GetBorderVisible() @@ -35849,6 +35872,7 @@ GuiTableComposition { borderVisible = value; UpdateCellBounds(); + InvokeOnCompositionStateChanged(); } } @@ -35887,34 +35911,34 @@ GuiTableComposition Rect GuiTableComposition::GetBounds() { Rect result; - if(!IsAlignedToParent() && GetMinSizeLimitation()!=GuiGraphicsComposition::NoLimit) + if (!IsAlignedToParent() && GetMinSizeLimitation() != GuiGraphicsComposition::NoLimit) { - result=Rect(compositionBounds.LeftTop(), compositionBounds.GetSize()-Size(columnExtending, rowExtending)); + result = Rect(compositionBounds.LeftTop(), compositionBounds.GetSize() - Size(columnExtending, rowExtending)); } else { - result=GuiBoundsComposition::GetBounds(); + result = GuiBoundsComposition::GetBounds(); } - bool cellMinSizeModified=false; + bool cellMinSizeModified = false; SortedList cells; FOREACH(GuiCellComposition*, cell, cellCompositions) { - if(cell && !cells.Contains(cell)) + if (cell && !cells.Contains(cell)) { cells.Add(cell); - Size newSize=cell->GetPreferredBounds().GetSize(); - if(cell->lastPreferredSize!=newSize) + Size newSize = cell->GetPreferredBounds().GetSize(); + if (cell->lastPreferredSize != newSize) { - cell->lastPreferredSize=newSize; - cellMinSizeModified=true; + cell->lastPreferredSize = newSize; + cellMinSizeModified = true; } } } - if(previousBounds!=result || cellMinSizeModified) + if (previousBounds != result || cellMinSizeModified) { - previousBounds=result; + previousBounds = result; UpdateCellBounds(); } return result; @@ -35926,13 +35950,13 @@ GuiCellComposition void GuiCellComposition::ClearSitedCells(GuiTableComposition* table) { - if(row!=-1 && column!=-1) + if (row != -1 && column != -1) { - for(vint r=0;rSetSitedCell(row+r, column+c, 0); + table->SetSitedCell(row + r, column + c, 0); } } } @@ -35940,36 +35964,36 @@ GuiCellComposition void GuiCellComposition::SetSitedCells(GuiTableComposition* table) { - for(vint r=0;rSetSitedCell(row+r, column+c, this); + table->SetSitedCell(row + r, column + c, this); } } } void GuiCellComposition::ResetSiteInternal() { - row=-1; - column=-1; - rowSpan=1; - columnSpan=1; + 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; + 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 r = 0; r < _rowSpan; r++) { - for(vint c=0;c<_columnSpan;c++) + for (vint c = 0; c < _columnSpan; c++) { - GuiCellComposition* cell=tableParent->GetSitedCell(_row+r, _column+c); - if(cell && cell!=this) + GuiCellComposition* cell = tableParent->GetSitedCell(_row + r, _column + c); + if (cell && cell != this) { return false; } @@ -35978,10 +36002,10 @@ GuiCellComposition ClearSitedCells(tableParent); } - row=_row; - column=_column; - rowSpan=_rowSpan; - columnSpan=_columnSpan; + row = _row; + column = _column; + rowSpan = _rowSpan; + columnSpan = _columnSpan; if (tableParent) { @@ -35993,16 +36017,16 @@ GuiCellComposition void GuiCellComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) { GuiGraphicsSite::OnParentChanged(oldParent, newParent); - if(tableParent) + if (tableParent) { ClearSitedCells(tableParent); } - tableParent=dynamic_cast(newParent); - if(!tableParent || !SetSiteInternal(row, column, rowSpan, columnSpan)) + tableParent = dynamic_cast(newParent); + if (!tableParent || !SetSiteInternal(row, column, rowSpan, columnSpan)) { ResetSiteInternal(); } - if(tableParent) + if (tableParent) { if (row != -1 && column != -1) { @@ -36067,6 +36091,7 @@ GuiCellComposition { tableParent->UpdateCellBounds(); } + InvokeOnCompositionStateChanged(); return true; } else @@ -36311,6 +36336,7 @@ GuiRowSplitterComposition void GuiRowSplitterComposition::SetRowsToTheTop(vint value) { rowsToTheTop = value; + InvokeOnCompositionStateChanged(); } Rect GuiRowSplitterComposition::GetBounds() @@ -36362,6 +36388,7 @@ GuiColumnSplitterComposition void GuiColumnSplitterComposition::SetColumnsToTheLeft(vint value) { columnsToTheLeft = value; + InvokeOnCompositionStateChanged(); } Rect GuiColumnSplitterComposition::GetBounds() @@ -37150,11 +37177,11 @@ GuiDocumentElement void GuiDocumentElement::UpdateCaret() { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { elementRenderer->SetSelection(caretBegin, caretEnd); - if(caretVisible) + if (caretVisible) { elementRenderer->OpenCaret(caretEnd, caretColor, caretFrontSide); } @@ -37162,6 +37189,7 @@ GuiDocumentElement { elementRenderer->CloseCaret(caretEnd); } + InvokeOnCompositionStateChanged(); } } @@ -37171,10 +37199,6 @@ GuiDocumentElement { } - GuiDocumentElement::~GuiDocumentElement() - { - } - GuiDocumentElement::ICallback* GuiDocumentElement::GetCallback() { return callback; @@ -37193,11 +37217,8 @@ GuiDocumentElement void GuiDocumentElement::SetDocument(Ptr value) { document=value; - if(renderer) - { - renderer->OnElementStateChanged(); - SetCaret(TextPos(), TextPos(), false); - } + InvokeOnElementStateChanged(); + SetCaret(TextPos(), TextPos(), false); } TextPos GuiDocumentElement::GetCaretBegin() @@ -37298,171 +37319,180 @@ GuiDocumentElement void GuiDocumentElement::NotifyParagraphUpdated(vint index, vint oldCount, vint newCount, bool updatedText) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { elementRenderer->NotifyParagraphUpdated(index, oldCount, newCount, updatedText); + InvokeOnCompositionStateChanged(); } } void GuiDocumentElement::EditRun(TextPos begin, TextPos end, Ptr model) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - vint newRows=document->EditRun(begin, end, model); - if(newRows!=-1) + vint newRows = document->EditRun(begin, end, model); + if (newRows != -1) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, newRows, true); + 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) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - vint newRows=document->EditText(begin, end, frontSide, text); - if(newRows!=-1) + vint newRows = document->EditText(begin, end, frontSide, text); + if (newRows != -1) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, newRows, true); + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, newRows, true); } + InvokeOnCompositionStateChanged(); } } void GuiDocumentElement::EditStyle(TextPos begin, TextPos end, Ptr style) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - if(document->EditStyle(begin, end, style)) + if (document->EditStyle(begin, end, style)) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, end.row-begin.row+1, false); + 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) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - if(document->EditImage(begin, end, image)) + if (document->EditImage(begin, end, image)) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, 1, true); + 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) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - vint temp=begin; - begin=end; - end=temp; + vint temp = begin; + begin = end; + end = temp; } - if(document->EditHyperlink(paragraphIndex, begin, end, reference, normalStyleName, activeStyleName)) + 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) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - vint temp=begin; - begin=end; - end=temp; + vint temp = begin; + begin = end; + end = temp; } - if(document->RemoveHyperlink(paragraphIndex, begin, end)) + if (document->RemoveHyperlink(paragraphIndex, begin, end)) { elementRenderer->NotifyParagraphUpdated(paragraphIndex, 1, 1, false); } + InvokeOnCompositionStateChanged(); } } void GuiDocumentElement::EditStyleName(TextPos begin, TextPos end, const WString& styleName) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - if(document->EditStyleName(begin, end, styleName)) + if (document->EditStyleName(begin, end, styleName)) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, end.row-begin.row+1, false); + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); } + InvokeOnCompositionStateChanged(); } } void GuiDocumentElement::RemoveStyleName(TextPos begin, TextPos end) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - if(document->RemoveStyleName(begin, end)) + if (document->RemoveStyleName(begin, end)) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, end.row-begin.row+1, false); + 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) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { document->RenameStyle(oldStyleName, newStyleName); } @@ -37470,76 +37500,75 @@ GuiDocumentElement void GuiDocumentElement::ClearStyle(TextPos begin, TextPos end) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } - if(document->ClearStyle(begin, end)) + if (document->ClearStyle(begin, end)) { - elementRenderer->NotifyParagraphUpdated(begin.row, end.row-begin.row+1, end.row-begin.row+1, false); + elementRenderer->NotifyParagraphUpdated(begin.row, end.row - begin.row + 1, end.row - begin.row + 1, false); } + InvokeOnCompositionStateChanged(); } } Ptr GuiDocumentElement::SummarizeStyle(TextPos begin, TextPos end) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - if(begin>end) + if (begin > end) { - TextPos temp=begin; - begin=end; - end=temp; + TextPos temp = begin; + begin = end; + end = temp; } return document->SummarizeStyle(begin, end); } - return 0; + return nullptr; } void GuiDocumentElement::SetParagraphAlignment(TextPos begin, TextPos end, const collections::Array>& alignments) { - Ptr elementRenderer=renderer.Cast(); - if(elementRenderer) + auto elementRenderer = renderer.Cast(); + if (elementRenderer) { - vint first=begin.row; - vint last=end.row; - if(first>last) + vint first = begin.row; + vint last = end.row; + if (first > last) { - vint temp=first; - first=last; - last=temp; + vint temp = first; + first = last; + last = temp; } - if(0<=first && firstparagraphs.Count() && 0<=last && lastparagraphs.Count() && last-first+1==alignments.Count()) + 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++) + for (vint i = first; i <= last; i++) { - document->paragraphs[i]->alignment=alignments[i-first]; + document->paragraphs[i]->alignment = alignments[i - first]; } elementRenderer->NotifyParagraphUpdated(first, alignments.Count(), alignments.Count(), false); } + InvokeOnCompositionStateChanged(); } } Ptr GuiDocumentElement::GetHyperlinkFromPoint(Point point) { - Ptr elementRenderer=renderer.Cast(); + auto elementRenderer=renderer.Cast(); if(elementRenderer) { return elementRenderer->GetHyperlinkFromPoint(point); } - else - { - return 0; - } + return nullptr; } } } @@ -37567,11 +37596,6 @@ GuiSolidBorderElement { } - GuiSolidBorderElement::~GuiSolidBorderElement() - { - renderer->Finalize(); - } - Color GuiSolidBorderElement::GetColor() { return color; @@ -37582,10 +37606,7 @@ GuiSolidBorderElement if(color!=value) { color=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37609,11 +37630,6 @@ GuiRoundBorderElement { } - GuiRoundBorderElement::~GuiRoundBorderElement() - { - renderer->Finalize(); - } - Color GuiRoundBorderElement::GetColor() { return color; @@ -37624,10 +37640,7 @@ GuiRoundBorderElement if(color!=value) { color=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37641,10 +37654,7 @@ GuiRoundBorderElement if(radius!=value) { radius=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37656,11 +37666,6 @@ Gui3DBorderElement { } - Gui3DBorderElement::~Gui3DBorderElement() - { - renderer->Finalize(); - } - Color Gui3DBorderElement::GetColor1() { return color1; @@ -37687,10 +37692,7 @@ Gui3DBorderElement { color1=value1; color2=value2; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37703,11 +37705,6 @@ Gui3DSplitterElement { } - Gui3DSplitterElement::~Gui3DSplitterElement() - { - renderer->Finalize(); - } - Color Gui3DSplitterElement::GetColor1() { return color1; @@ -37734,10 +37731,7 @@ Gui3DSplitterElement { color1=value1; color2=value2; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37751,10 +37745,7 @@ Gui3DSplitterElement if(direction!=value) { direction=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37768,11 +37759,6 @@ GuiSolidBackgroundElement { } - GuiSolidBackgroundElement::~GuiSolidBackgroundElement() - { - renderer->Finalize(); - } - Color GuiSolidBackgroundElement::GetColor() { return color; @@ -37783,10 +37769,7 @@ GuiSolidBackgroundElement if(color!=value) { color=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37810,11 +37793,6 @@ GuiGradientBackgroundElement { } - GuiGradientBackgroundElement::~GuiGradientBackgroundElement() - { - renderer->Finalize(); - } - Color GuiGradientBackgroundElement::GetColor1() { return color1; @@ -37841,10 +37819,7 @@ GuiGradientBackgroundElement { color1=value1; color2=value2; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37858,10 +37833,7 @@ GuiGradientBackgroundElement if(direction!=value) { direction=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37892,11 +37864,6 @@ GuiSolidLabelElement fontProperties.size=12; } - GuiSolidLabelElement::~GuiSolidLabelElement() - { - renderer->Finalize(); - } - Color GuiSolidLabelElement::GetColor() { return color; @@ -37907,10 +37874,7 @@ GuiSolidLabelElement if(color!=value) { color=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37924,10 +37888,7 @@ GuiSolidLabelElement if(fontProperties!=value) { fontProperties=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37941,10 +37902,7 @@ GuiSolidLabelElement if(text!=value) { text=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37974,10 +37932,7 @@ GuiSolidLabelElement { hAlignment=horizontal; vAlignment=vertical; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -37991,10 +37946,7 @@ GuiSolidLabelElement if(wrapLine!=value) { wrapLine=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38008,10 +37960,7 @@ GuiSolidLabelElement if(ellipse!=value) { ellipse=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38025,10 +37974,7 @@ GuiSolidLabelElement if(multiline!=value) { multiline=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38042,10 +37988,7 @@ GuiSolidLabelElement if(wrapLineHeightCalculation!=value) { wrapLineHeightCalculation=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38062,11 +38005,6 @@ GuiImageFrameElement { } - GuiImageFrameElement::~GuiImageFrameElement() - { - renderer->Finalize(); - } - Ptr GuiImageFrameElement::GetImage() { return image; @@ -38101,10 +38039,7 @@ GuiImageFrameElement image=_image; frameIndex=_frameIndex; } - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38134,10 +38069,7 @@ GuiImageFrameElement { hAlignment=horizontal; vAlignment=vertical; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38151,10 +38083,7 @@ GuiImageFrameElement if(stretch!=value) { stretch=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38168,10 +38097,7 @@ GuiImageFrameElement if(enabled!=value) { enabled=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38183,10 +38109,6 @@ GuiPolygonElement { } - GuiPolygonElement::~GuiPolygonElement() - { - } - Size GuiPolygonElement::GetSize() { return size; @@ -38197,10 +38119,7 @@ GuiPolygonElement if(size!=value) { size=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38221,10 +38140,7 @@ GuiPolygonElement { memcpy(&points[0], p, sizeof(*p)*count); } - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } const GuiPolygonElement::PointArray& GuiPolygonElement::GetPointsArray() @@ -38247,10 +38163,7 @@ GuiPolygonElement if(borderColor!=value) { borderColor=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -38264,10 +38177,7 @@ GuiPolygonElement if(backgroundColor!=value) { backgroundColor=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } } @@ -38593,9 +38503,9 @@ GuiGraphicsHost } if(mouseCaptureComposition==composition) { - if(nativeWindow) + if(hostRecord.nativeWindow) { - nativeWindow->ReleaseCapture(); + hostRecord.nativeWindow->ReleaseCapture(); } mouseCaptureComposition=0; } @@ -38608,11 +38518,11 @@ GuiGraphicsHost void GuiGraphicsHost::MouseCapture(const NativeWindowMouseInfo& info) { - if(nativeWindow && (info.left || info.middle || info.right)) + if(hostRecord.nativeWindow && (info.left || info.middle || info.right)) { - if(!nativeWindow->IsCapturing() && !info.nonClient) + if(!hostRecord.nativeWindow->IsCapturing() && !info.nonClient) { - nativeWindow->RequireCapture(); + hostRecord.nativeWindow->RequireCapture(); mouseCaptureComposition=windowComposition->FindComposition(Point(info.x, info.y)); } } @@ -38620,9 +38530,9 @@ GuiGraphicsHost void GuiGraphicsHost::MouseUncapture(const NativeWindowMouseInfo& info) { - if(nativeWindow && !(info.left || info.middle || info.right)) + if(hostRecord.nativeWindow && !(info.left || info.middle || info.right)) { - nativeWindow->ReleaseCapture(); + hostRecord.nativeWindow->ReleaseCapture(); mouseCaptureComposition=0; } } @@ -38758,16 +38668,16 @@ GuiGraphicsHost INativeWindowListener::HitTestResult GuiGraphicsHost::HitTest(Point location) { - Rect bounds=nativeWindow->GetBounds(); - Rect clientBounds=nativeWindow->GetClientBoundsInScreen(); - Point clientLocation(location.x+bounds.x1-clientBounds.x1, location.y+bounds.y1-clientBounds.y1); - GuiGraphicsComposition* hitComposition=windowComposition->FindComposition(clientLocation); - while(hitComposition) + Rect bounds = hostRecord.nativeWindow->GetBounds(); + Rect clientBounds = hostRecord.nativeWindow->GetClientBoundsInScreen(); + Point clientLocation(location.x + bounds.x1 - clientBounds.x1, location.y + bounds.y1 - clientBounds.y1); + GuiGraphicsComposition* hitComposition = windowComposition->FindComposition(clientLocation); + while (hitComposition) { - INativeWindowListener::HitTestResult result=hitComposition->GetAssociatedHitTestResult(); - if(result==INativeWindowListener::NoDecision) + INativeWindowListener::HitTestResult result = hitComposition->GetAssociatedHitTestResult(); + if (result == INativeWindowListener::NoDecision) { - hitComposition=hitComposition->GetParent(); + hitComposition = hitComposition->GetParent(); } else { @@ -38779,55 +38689,63 @@ GuiGraphicsHost void GuiGraphicsHost::Moving(Rect& bounds, bool fixSizeOnly) { - Rect oldBounds=nativeWindow->GetBounds(); - minSize=windowComposition->GetPreferredBounds().GetSize(); - Size minWindowSize=minSize+(oldBounds.GetSize()-nativeWindow->GetClientSize()); - if(bounds.Width()GetBounds(); + minSize = windowComposition->GetPreferredBounds().GetSize(); + Size minWindowSize = minSize + (oldBounds.GetSize() - hostRecord.nativeWindow->GetClientSize()); + if (bounds.Width() < minWindowSize.x) { - if(fixSizeOnly) + if (fixSizeOnly) { - if(bounds.Width()GetClientSize(); - if(previousClientSize!=size) + Size size = hostRecord.nativeWindow->GetClientSize(); + if (previousClientSize != size) { - previousClientSize=size; - minSize=windowComposition->GetPreferredBounds().GetSize(); - Render(); + previousClientSize = size; + minSize = windowComposition->GetPreferredBounds().GetSize(); + Render(true); + } + } + + void GuiGraphicsHost::Paint() + { + if (!supressPaint) + { + needRender = true; } } @@ -38902,60 +38820,60 @@ GuiGraphicsHost { CompositionList newCompositions; { - GuiGraphicsComposition* composition=windowComposition->FindComposition(Point(info.x, info.y)); - while(composition) + GuiGraphicsComposition* composition = windowComposition->FindComposition(Point(info.x, info.y)); + while (composition) { newCompositions.Insert(0, composition); - composition=composition->GetParent(); + composition = composition->GetParent(); } } - vint firstDifferentIndex=mouseEnterCompositions.Count(); - for(vint i=0;i=firstDifferentIndex;i--) + for (vint i = mouseEnterCompositions.Count() - 1; i >= firstDifferentIndex; i--) { - GuiGraphicsComposition* composition=mouseEnterCompositions[i]; - if(composition->HasEventReceiver()) + GuiGraphicsComposition* composition = mouseEnterCompositions[i]; + if (composition->HasEventReceiver()) { composition->GetEventReceiver()->mouseLeave.Execute(GuiEventArgs(composition)); } } CopyFrom(mouseEnterCompositions, newCompositions); - for(vint i=firstDifferentIndex;iHasEventReceiver()) + GuiGraphicsComposition* composition = mouseEnterCompositions[i]; + if (composition->HasEventReceiver()) { composition->GetEventReceiver()->mouseEnter.Execute(GuiEventArgs(composition)); } } - INativeCursor* cursor=0; - if(newCompositions.Count()>0) + INativeCursor* cursor = 0; + if (newCompositions.Count() > 0) { - cursor=newCompositions[newCompositions.Count()-1]->GetRelatedCursor(); + cursor = newCompositions[newCompositions.Count() - 1]->GetRelatedCursor(); } - if(cursor) + if (cursor) { - nativeWindow->SetWindowCursor(cursor); + hostRecord.nativeWindow->SetWindowCursor(cursor); } else { - nativeWindow->SetWindowCursor(GetCurrentController()->ResourceService()->GetDefaultSystemCursor()); + hostRecord.nativeWindow->SetWindowCursor(GetCurrentController()->ResourceService()->GetDefaultSystemCursor()); } OnMouseInput(info, &GuiGraphicsEventReceiver::mouseMove); @@ -39067,15 +38985,15 @@ GuiGraphicsHost void GuiGraphicsHost::SysKeyUp(const NativeWindowKeyInfo& info) { - if (!info.ctrl && !info.shift && info.code == VKEY_MENU && nativeWindow) + if (!info.ctrl && !info.shift && info.code == VKEY_MENU && hostRecord.nativeWindow) { - if (nativeWindow) + if (hostRecord.nativeWindow) { - nativeWindow->SupressAlt(); + hostRecord.nativeWindow->SupressAlt(); } } - if(focusedComposition && focusedComposition->HasEventReceiver()) + if (focusedComposition && focusedComposition->HasEventReceiver()) { OnKeyInput(info, focusedComposition, &GuiGraphicsEventReceiver::systemKeyUp); } @@ -39109,12 +39027,11 @@ GuiGraphicsHost } } - Render(); + Render(false); } GuiGraphicsHost::GuiGraphicsHost() - :nativeWindow(0) - ,shortcutKeyManager(0) + :shortcutKeyManager(0) ,windowComposition(0) ,focusedComposition(0) ,mouseCaptureComposition(0) @@ -39122,8 +39039,9 @@ GuiGraphicsHost ,currentAltHost(0) ,supressAltKey(0) { + hostRecord.host = this; windowComposition=new GuiWindowComposition; - windowComposition->SetAssociatedHost(this); + windowComposition->UpdateRelatedHostRecord(&hostRecord); windowComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); } @@ -39139,27 +39057,29 @@ GuiGraphicsHost INativeWindow* GuiGraphicsHost::GetNativeWindow() { - return nativeWindow; + return hostRecord.nativeWindow; } void GuiGraphicsHost::SetNativeWindow(INativeWindow* _nativeWindow) { - if(nativeWindow!=_nativeWindow) + if (hostRecord.nativeWindow != _nativeWindow) { - if(nativeWindow) + if (hostRecord.nativeWindow) { GetCurrentController()->CallbackService()->UninstallListener(this); - nativeWindow->UninstallListener(this); + hostRecord.nativeWindow->UninstallListener(this); } - nativeWindow=_nativeWindow; - windowComposition->SetAttachedWindow(nativeWindow); - if(nativeWindow) + hostRecord.nativeWindow = _nativeWindow; + hostRecord.renderTarget = _nativeWindow ? GetGuiGraphicsResourceManager()->GetRenderTarget(_nativeWindow) : nullptr; + windowComposition->UpdateRelatedHostRecord(&hostRecord); + if (hostRecord.nativeWindow) { - nativeWindow->InstallListener(this); + hostRecord.nativeWindow->InstallListener(this); GetCurrentController()->CallbackService()->InstallListener(this); - previousClientSize=nativeWindow->GetClientSize(); - minSize=windowComposition->GetPreferredBounds().GetSize(); - nativeWindow->SetCaretPoint(caretPoint); + previousClientSize = hostRecord.nativeWindow->GetClientSize(); + minSize = windowComposition->GetPreferredBounds().GetSize(); + hostRecord.nativeWindow->SetCaretPoint(caretPoint); + needRender = true; } } } @@ -39169,24 +39089,38 @@ GuiGraphicsHost return windowComposition; } - void GuiGraphicsHost::Render() + void GuiGraphicsHost::Render(bool forceUpdate) { - if(nativeWindow && nativeWindow->IsVisible()) + if (!forceUpdate && !needRender) { - windowComposition->GetRenderTarget()->StartRendering(); + return; + } + needRender = false; + + if(hostRecord.nativeWindow && hostRecord.nativeWindow->IsVisible()) + { + supressPaint = true; + hostRecord.renderTarget->StartRendering(); windowComposition->Render(Size()); - bool success = windowComposition->GetRenderTarget()->StopRendering(); - nativeWindow->RedrawContent(); + bool success = hostRecord.renderTarget->StopRendering(); + hostRecord.nativeWindow->RedrawContent(); + supressPaint = false; if (!success) { - windowComposition->SetAttachedWindow(0); - GetGuiGraphicsResourceManager()->RecreateRenderTarget(nativeWindow); - windowComposition->SetAttachedWindow(nativeWindow); + windowComposition->UpdateRelatedHostRecord(nullptr); + GetGuiGraphicsResourceManager()->RecreateRenderTarget(hostRecord.nativeWindow); + windowComposition->UpdateRelatedHostRecord(&hostRecord); + needRender = true; } } } + void GuiGraphicsHost::RequestRender() + { + needRender = true; + } + IGuiShortcutKeyManager* GuiGraphicsHost::GetShortcutKeyManager() { return shortcutKeyManager; @@ -39234,16 +39168,16 @@ GuiGraphicsHost void GuiGraphicsHost::SetCaretPoint(Point value, GuiGraphicsComposition* referenceComposition) { - if(referenceComposition) + if (referenceComposition) { - Rect bounds=referenceComposition->GetGlobalBounds(); - value.x+=bounds.x1; - value.y+=bounds.y1; + Rect bounds = referenceComposition->GetGlobalBounds(); + value.x += bounds.x1; + value.y += bounds.y1; } - caretPoint=value; - if(nativeWindow) + caretPoint = value; + if (hostRecord.nativeWindow) { - nativeWindow->SetCaretPoint(caretPoint); + hostRecord.nativeWindow->SetCaretPoint(caretPoint); } } @@ -39694,8 +39628,9 @@ text::CharMeasurer text::TextLines ***********************************************************************/ - TextLines::TextLines() - :charMeasurer(0) + TextLines::TextLines(GuiColorizedTextElement* _ownerElement) + :ownerElement(_ownerElement) + ,charMeasurer(0) ,renderTarget(0) ,tabWidth(1) ,tabSpaceCount(4) @@ -39856,6 +39791,10 @@ text::TextLines 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) { @@ -39957,6 +39896,10 @@ text::TextLines TextLine line; line.Initialize(); lines.Add(line); + if (ownerElement) + { + ownerElement->InvokeOnElementStateChanged(); + } } //-------------------------------------------------------- @@ -39975,6 +39918,10 @@ text::TextLines { tabWidth=1; } + if (ownerElement) + { + ownerElement->InvokeOnElementStateChanged(); + } } vint TextLines::GetTabSpaceCount() @@ -40174,14 +40121,10 @@ GuiColorizedTextElement ,isVisuallyEnabled(true) ,isFocused(false) ,caretVisible(false) + ,lines(this) { } - GuiColorizedTextElement::~GuiColorizedTextElement() - { - renderer->Finalize(); - } - text::TextLines& GuiColorizedTextElement::GetLines() { return lines; @@ -40210,10 +40153,7 @@ GuiColorizedTextElement { CopyFrom(colors, value); if(callback) callback->ColorChanged(); - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } void GuiColorizedTextElement::ResetTextColorIndex(vint index) @@ -40245,10 +40185,7 @@ GuiColorizedTextElement { callback->FontChanged(); } - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -40262,10 +40199,7 @@ GuiColorizedTextElement if(lines.GetPasswordChar()!=value) { lines.SetPasswordChar(value); - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -40279,10 +40213,7 @@ GuiColorizedTextElement if(viewPosition!=value) { viewPosition=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -40296,10 +40227,7 @@ GuiColorizedTextElement if(isVisuallyEnabled!=value) { isVisuallyEnabled=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -40313,10 +40241,7 @@ GuiColorizedTextElement if(isFocused!=value) { isFocused=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } @@ -40328,6 +40253,7 @@ GuiColorizedTextElement void GuiColorizedTextElement::SetCaretBegin(TextPos value) { caretBegin=value; + InvokeOnElementStateChanged(); } TextPos GuiColorizedTextElement::GetCaretEnd() @@ -40338,6 +40264,7 @@ GuiColorizedTextElement void GuiColorizedTextElement::SetCaretEnd(TextPos value) { caretEnd=value; + InvokeOnElementStateChanged(); } bool GuiColorizedTextElement::GetCaretVisible() @@ -40348,6 +40275,7 @@ GuiColorizedTextElement void GuiColorizedTextElement::SetCaretVisible(bool value) { caretVisible=value; + InvokeOnElementStateChanged(); } Color GuiColorizedTextElement::GetCaretColor() @@ -40360,10 +40288,7 @@ GuiColorizedTextElement if(caretColor!=value) { caretColor=value; - if(renderer) - { - renderer->OnElementStateChanged(); - } + InvokeOnElementStateChanged(); } } } diff --git a/Import/GacUI.h b/Import/GacUI.h index 6b4ddaf4..c95b0f07 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -690,6 +690,13 @@ namespace vl { using namespace reflection; + namespace compositions + { + class GuiGraphicsComposition; + + extern void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition); + } + namespace elements { class IGuiGraphicsElement; @@ -709,17 +716,26 @@ Basic Construction /// class IGuiGraphicsElement : public virtual IDescriptable, public Description { + friend class compositions::GuiGraphicsComposition; + protected: + + virtual void SetOwnerComposition(compositions::GuiGraphicsComposition* composition) = 0; public: /// /// Access the that is used to create this graphics elements. /// /// Returns the related factory. - virtual IGuiGraphicsElementFactory* GetFactory()=0; + virtual IGuiGraphicsElementFactory* GetFactory() = 0; /// /// Access the associated for this graphics element. /// /// Returns the related renderer. - virtual IGuiGraphicsRenderer* GetRenderer()=0; + virtual IGuiGraphicsRenderer* GetRenderer() = 0; + /// + /// Get the owner composition. + /// + /// The owner composition. + virtual compositions::GuiGraphicsComposition* GetOwnerComposition() = 0; }; /// @@ -2508,11 +2524,6 @@ Native Window Controller /// The user dialog service virtual INativeDialogService* DialogService()=0; /// - /// Get the operating system's version display string. - /// - /// The version string. In Windows implementation, the version string formats like "MAIN-VERSION;CSD-VERSION, e.g. "Windows XP;Service Pack 3". The ";" always exists, but the CSD version can be empty. - virtual WString GetOSVersion()=0; - /// /// Get the file path of the current executable. /// /// The file path of the current executable. @@ -2998,48 +3009,93 @@ Resource Manager Helpers ***********************************************************************/ + template + class GuiElementBase : public Object, public IGuiGraphicsElement, public Description + { + public: + class Factory : public Object, public IGuiGraphicsElementFactory + { + public: + WString GetElementTypeName() + { + return TElement::GetElementTypeName(); + } + IGuiGraphicsElement* Create() + { + auto element = new TElement; + element->factory = this; + IGuiGraphicsRendererFactory* rendererFactory = GetGuiGraphicsResourceManager()->GetRendererFactory(GetElementTypeName()); + if (rendererFactory) + { + element->renderer = rendererFactory->Create(); + element->renderer->Initialize(element); + } + return element; + } + }; + protected: + IGuiGraphicsElementFactory* factory = nullptr; + Ptr renderer; + compositions::GuiGraphicsComposition* ownerComposition = nullptr; + + void SetOwnerComposition(compositions::GuiGraphicsComposition* composition)override + { + ownerComposition = composition; + } + + void InvokeOnCompositionStateChanged() + { + if (ownerComposition) + { + compositions::InvokeOnCompositionStateChanged(ownerComposition); + } + } + + void InvokeOnElementStateChanged() + { + if (renderer) + { + renderer->OnElementStateChanged(); + } + InvokeOnCompositionStateChanged(); + } + public: + static TElement* Create() + { + return dynamic_cast(GetGuiGraphicsResourceManager()->GetElementFactory(TElement::GetElementTypeName())->Create()); + } + + ~GuiElementBase() + { + if (renderer) + { + renderer->Finalize(); + } + } + + IGuiGraphicsElementFactory* GetFactory()override + { + return factory; + } + + IGuiGraphicsRenderer* GetRenderer()override + { + return renderer.Obj(); + } + + compositions::GuiGraphicsComposition* GetOwnerComposition()override + { + return ownerComposition; + } + }; + #define DEFINE_GUI_GRAPHICS_ELEMENT(TELEMENT, ELEMENT_TYPE_NAME)\ - public:\ - class Factory : public Object, public IGuiGraphicsElementFactory\ - {\ - public:\ - WString GetElementTypeName()\ - {\ - return TELEMENT::GetElementTypeName();\ - }\ - IGuiGraphicsElement* Create()\ - {\ - TELEMENT* element=new TELEMENT;\ - element->factory=this;\ - IGuiGraphicsRendererFactory* rendererFactory=GetGuiGraphicsResourceManager()->GetRendererFactory(GetElementTypeName());\ - if(rendererFactory)\ - {\ - element->renderer=rendererFactory->Create();\ - element->renderer->Initialize(element);\ - }\ - return element;\ - }\ - };\ - protected:\ - IGuiGraphicsElementFactory* factory;\ - Ptr renderer;\ + friend class GuiElementBase;\ public:\ static WString GetElementTypeName()\ {\ return ELEMENT_TYPE_NAME;\ }\ - static TELEMENT* Create()\ - {\ - return dynamic_cast(GetGuiGraphicsResourceManager()->GetElementFactory(TELEMENT::GetElementTypeName())->Create());\ - }\ - IGuiGraphicsElementFactory* GetFactory()override\ - {\ - return factory;\ - }\ - IGuiGraphicsRenderer* GetRenderer()override\ - {\ - return renderer.Obj();\ - }\ #define DEFINE_GUI_GRAPHICS_RENDERER(TELEMENT, TRENDERER, TTARGET)\ public:\ @@ -4348,7 +4404,7 @@ Elements /// /// Defines a border element with a thickness of one pixel. /// - class GuiSolidBorderElement : public Object, public IGuiGraphicsElement, public Description + class GuiSolidBorderElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiSolidBorderElement, L"SolidBorder") protected: @@ -4357,8 +4413,6 @@ Elements GuiSolidBorderElement(); public: - ~GuiSolidBorderElement(); - /// /// Get the border color. /// @@ -4384,7 +4438,7 @@ Elements /// /// Defines a rectangle border element with round corners and a thickness of one pixel. /// - class GuiRoundBorderElement : public Object, public IGuiGraphicsElement, public Description + class GuiRoundBorderElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiRoundBorderElement, L"RoundBorder") protected: @@ -4393,8 +4447,6 @@ Elements GuiRoundBorderElement(); public: - ~GuiRoundBorderElement(); - /// /// Get the border color. /// @@ -4421,7 +4473,7 @@ Elements /// /// Defines a 3D-like rectangle element with a thickness of two pixels. /// - class Gui3DBorderElement : public Object, public IGuiGraphicsElement, public Description + class Gui3DBorderElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(Gui3DBorderElement, L"3DBorder") protected: @@ -4430,8 +4482,6 @@ Elements Gui3DBorderElement(); public: - ~Gui3DBorderElement(); - /// /// Get the left-top color. /// @@ -4463,7 +4513,7 @@ Elements /// /// Defines a 3D-like splitter element with a thickness of two pixels. /// - class Gui3DSplitterElement : public Object, public IGuiGraphicsElement, public Description + class Gui3DSplitterElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(Gui3DSplitterElement, L"3DSplitter") public: @@ -4484,8 +4534,6 @@ Elements Gui3DSplitterElement(); public: - ~Gui3DSplitterElement(); - /// /// Get the left-top color. /// @@ -4528,7 +4576,7 @@ Elements /// /// Defines a color-filled element without border. /// - class GuiSolidBackgroundElement : public Object, public IGuiGraphicsElement, public Description + class GuiSolidBackgroundElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiSolidBackgroundElement, L"SolidBackground") protected: @@ -4537,8 +4585,6 @@ Elements GuiSolidBackgroundElement(); public: - ~GuiSolidBackgroundElement(); - /// /// Get the border color. /// @@ -4564,7 +4610,7 @@ Elements /// /// Defines a color-filled gradient element without border. /// - class GuiGradientBackgroundElement : public Object, public IGuiGraphicsElement, public Description + class GuiGradientBackgroundElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiGradientBackgroundElement, L"GradientBackground") public: @@ -4590,8 +4636,6 @@ Elements GuiGradientBackgroundElement(); public: - ~GuiGradientBackgroundElement(); - /// /// Get the left-top color. /// @@ -4644,7 +4688,7 @@ Elements /// /// Defines an element of a plain text. /// - class GuiSolidLabelElement : public Object, public IGuiGraphicsElement, public Description + class GuiSolidLabelElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiSolidLabelElement, L"SolidLabel"); protected: @@ -4660,8 +4704,6 @@ Elements GuiSolidLabelElement(); public: - ~GuiSolidLabelElement(); - /// /// Get the text color. /// @@ -4770,7 +4812,7 @@ Elements /// /// Defines an element containing an image. /// - class GuiImageFrameElement : public Object, public IGuiGraphicsElement, public Description + class GuiImageFrameElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiImageFrameElement, L"ImageFrame"); protected: @@ -4783,8 +4825,6 @@ Elements GuiImageFrameElement(); public: - ~GuiImageFrameElement(); - /// /// Get the containing image. /// @@ -4865,7 +4905,7 @@ Elements /// /// Defines a polygon element with a thickness of one pixel. /// - class GuiPolygonElement : public Object, public IGuiGraphicsElement, public Description + class GuiPolygonElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiPolygonElement, L"Polygon"); @@ -4878,8 +4918,6 @@ Elements GuiPolygonElement(); public: - ~GuiPolygonElement(); - /// /// Get a suggested size. The polygon element will be layouted to the center of the required bounds using this size. /// @@ -4969,6 +5007,7 @@ namespace vl { namespace elements { + class GuiColorizedTextElement; /*********************************************************************** Colorized Plain Text (model) @@ -5106,7 +5145,7 @@ Colorized Plain Text (model) /// Bind a render target to this character measurer. /// /// The render target to bind. - void SetRenderTarget(IGuiGraphicsRenderTarget* value); + void SetRenderTarget(IGuiGraphicsRenderTarget* value); /// /// Measure the width of a character using the binded render target. /// @@ -5127,6 +5166,7 @@ Colorized Plain Text (model) { typedef collections::List TextLineList; protected: + GuiColorizedTextElement* ownerElement; TextLineList lines; CharMeasurer* charMeasurer; IGuiGraphicsRenderTarget* renderTarget; @@ -5134,7 +5174,7 @@ Colorized Plain Text (model) vint tabSpaceCount; wchar_t passwordChar; public: - TextLines(); + TextLines(GuiColorizedTextElement* _ownerElement); ~TextLines(); /// @@ -5363,10 +5403,11 @@ Colorized Plain Text (element) /// /// Defines a text element with separate color configuration for each character. /// - class GuiColorizedTextElement : public Object, public IGuiGraphicsElement, public Description + class GuiColorizedTextElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiColorizedTextElement, L"ColorizedText"); + friend class text::TextLines; typedef collections::Array ColorArray; public: /// @@ -5401,8 +5442,6 @@ Colorized Plain Text (element) GuiColorizedTextElement(); public: - ~GuiColorizedTextElement(); - /// /// Get the internal object that stores all characters and colors. /// @@ -5564,7 +5603,7 @@ Rich Content Document (element) ***********************************************************************/ /// Defines a rich text document element for rendering complex styled document. - class GuiDocumentElement : public Object, public IGuiGraphicsElement, public Description + class GuiDocumentElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiDocumentElement, L"RichDocument"); public: @@ -5677,8 +5716,6 @@ Rich Content Document (element) GuiDocumentElement(); public: - ~GuiDocumentElement(); - /// Get the callback. /// The callback. ICallback* GetCallback(); @@ -6420,6 +6457,7 @@ Basic Construction friend class controls::GuiControl; friend class GuiGraphicsHost; + friend void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition); public: /// /// Minimum size limitation. @@ -6433,18 +6471,27 @@ Basic Construction /// Minimum size of this composition is combiniation of sub compositions and the minimum size of the contained graphics element. LimitToElementAndChildren, }; + + protected: + + struct GraphicsHostRecord + { + GuiGraphicsHost* host = nullptr; + elements::IGuiGraphicsRenderTarget* renderTarget = nullptr; + INativeWindow* nativeWindow = nullptr; + }; + protected: CompositionList children; - GuiGraphicsComposition* parent; + GuiGraphicsComposition* parent = nullptr; Ptr ownedElement; bool visible; - elements::IGuiGraphicsRenderTarget* renderTarget; MinSizeLimitation minSizeLimitation; Ptr eventReceiver; - controls::GuiControl* associatedControl; - GuiGraphicsHost* associatedHost; - INativeCursor* associatedCursor; + GraphicsHostRecord* relatedHostRecord = nullptr; + controls::GuiControl* associatedControl = nullptr; + INativeCursor* associatedCursor = nullptr; INativeWindowListener::HitTestResult associatedHitTestResult; Margin margin; @@ -6456,10 +6503,11 @@ Basic Construction virtual void OnChildRemoved(GuiGraphicsComposition* child); virtual void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent); virtual void OnParentLineChanged(); - virtual void OnRenderTargetChanged(); + virtual void OnRenderContextChanged(); - virtual void SetAssociatedControl(controls::GuiControl* control); - virtual void SetAssociatedHost(GuiGraphicsHost* host); + void UpdateRelatedHostRecord(GraphicsHostRecord* record); + void SetAssociatedControl(controls::GuiControl* control); + void InvokeOnCompositionStateChanged(); static bool SharedPtrDestructorProc(DescriptableObject* obj, bool forceDisposing); public: @@ -6512,9 +6560,6 @@ Basic Construction /// Get the binded render target. /// The binded render target. elements::IGuiGraphicsRenderTarget* GetRenderTarget(); - /// Set the binded render target. This function is designed for internal usage. Users are not suggested to call this function directly. - /// The binded render target. - void SetRenderTarget(elements::IGuiGraphicsRenderTarget* value); /// Render the composition using an offset. /// The offset. @@ -6677,18 +6722,9 @@ Basic Compositions /// class GuiWindowComposition : public GuiGraphicsSite, public Description { - protected: - INativeWindow* attachedWindow; public: GuiWindowComposition(); ~GuiWindowComposition(); - - /// Get the attached native window object. - /// The attached native window object. - INativeWindow* GetAttachedWindow(); - /// Attached a native window object. - /// The native window object to attach. - void SetAttachedWindow(INativeWindow* window); Rect GetBounds()override; void SetMargin(Margin value)override; @@ -6701,7 +6737,7 @@ Basic Compositions { protected: Rect compositionBounds; - Margin alignmentToParent; + Margin alignmentToParent{ -1,-1,-1,-1 }; public: GuiBoundsComposition(); @@ -6713,8 +6749,6 @@ Basic Compositions /// The expected bounds. void SetBounds(Rect value); - /// Make the composition not aligned to its parent. - void ClearAlignmentToParent(); /// Get the alignment to its parent. -1 in each alignment component means that the corressponding side is not aligned to its parent. /// The alignment to its parent. Margin GetAlignmentToParent(); @@ -6889,7 +6923,7 @@ Table Compositions void UpdateCellBoundsInternal(); void UpdateTableContentMinSize(); - void OnRenderTargetChanged()override; + void OnRenderContextChanged()override; public: GuiTableComposition(); ~GuiTableComposition(); @@ -7951,10 +7985,14 @@ Host typedef collections::List CompositionList; typedef collections::Dictionary AltActionMap; typedef collections::Dictionary AltControlMap; + typedef GuiGraphicsComposition::GraphicsHostRecord HostRecord; public: - static const vuint64_t CaretInterval=500; + static const vuint64_t CaretInterval = 500; protected: - INativeWindow* nativeWindow; + HostRecord hostRecord; + bool supressPaint = false; + bool needRender = true; + IGuiShortcutKeyManager* shortcutKeyManager; GuiWindowComposition* windowComposition; GuiGraphicsComposition* focusedComposition; @@ -7994,6 +8032,7 @@ Host 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; @@ -8031,7 +8070,9 @@ Host /// The main compositoin. GuiGraphicsComposition* GetMainComposition(); /// Render the main composition and all content to the associated window. - void Render(); + void Render(bool forceUpdate); + /// Request a rendering + void RequestRender(); /// Get the attached with this graphics host. /// The shortcut key manager. @@ -14873,6 +14914,7 @@ GuiDocumentCommonInterface }; protected: Ptr baselineDocument; + Color caretColor; DocumentItemMap documentItems; GuiControl* documentControl; elements::GuiDocumentElement* documentElement; @@ -14917,7 +14959,7 @@ GuiDocumentCommonInterface void OnFinishRender()override; Size OnRenderEmbeddedObject(const WString& name, const Rect& location)override; public: - GuiDocumentCommonInterface(Ptr _baselineDocument); + GuiDocumentCommonInterface(Ptr _baselineDocument, Color _caretColor = {}); ~GuiDocumentCommonInterface(); /// Active hyperlink changed event. @@ -15137,6 +15179,9 @@ GuiDocumentViewer /// Get a baseline document for customize default styles. /// The baseline document. virtual Ptr GetBaselineDocument() = 0; + /// Get the caret color. + /// The caret color. + virtual Color GetCaretColor() = 0; }; protected: @@ -18454,6 +18499,7 @@ Control Template #define GuiDocumentViewerTemplate_PROPERTIES(F)\ F(GuiDocumentViewerTemplate, Ptr, BaselineDocument)\ + F(GuiDocumentViewerTemplate, Color, CaretColor)\ GuiDocumentViewerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) }; @@ -18915,6 +18961,7 @@ Control Template ~GuiDocumentViewerTemplate_StyleProvider(); Ptr GetBaselineDocument()override; + Color GetCaretColor()override; }; class GuiTextListTemplate_StyleProvider @@ -20276,6 +20323,7 @@ TextBox ~Win7DocumentViewerStyle(); Ptr GetBaselineDocument()override; + Color GetCaretColor()override; }; /// Document label style (Windows 7). @@ -21185,6 +21233,7 @@ TextBox ~Win8DocumentViewerStyle(); Ptr GetBaselineDocument()override; + Color GetCaretColor()override; }; /// Document label style (Windows 8). diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index a44f81be..0603e5b9 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -512,7 +512,6 @@ Type Declaration BEGIN_INTERFACE_MEMBER_NOPROXY(INativeController) CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetCurrentController, NO_PARAMETER, INativeController*(*)(), vl::reflection::description::GetCurrentController) - CLASS_MEMBER_PROPERTY_READONLY_FAST(OSVersion) CLASS_MEMBER_PROPERTY_READONLY_FAST(ExecutablePath) CLASS_MEMBER_METHOD(ResourceService, NO_PARAMETER) @@ -745,6 +744,7 @@ Type Declaration END_INTERFACE_MEMBER(IGuiResourceManager) BEGIN_INTERFACE_MEMBER_NOPROXY(IGuiGraphicsElement) + CLASS_MEMBER_PROPERTY_READONLY_FAST(OwnerComposition) END_INTERFACE_MEMBER(IGuiGraphicsElement) BEGIN_CLASS_MEMBER(GuiGraphicsComposition) @@ -852,7 +852,6 @@ Type Declaration CLASS_MEMBER_PROPERTY_EVENT_FAST(Bounds, BoundsChanged) CLASS_MEMBER_PROPERTY_FAST(AlignmentToParent) - CLASS_MEMBER_METHOD(ClearAlignmentToParent, NO_PARAMETER) CLASS_MEMBER_METHOD(IsAlignedToParent, NO_PARAMETER) END_CLASS_MEMBER(GuiBoundsComposition) @@ -2604,6 +2603,7 @@ Type Declaration CLASS_MEMBER_BASE(GuiScrollContainer::IStyleProvider) CLASS_MEMBER_PROPERTY_READONLY_FAST(BaselineDocument) + CLASS_MEMBER_PROPERTY_READONLY_FAST(CaretColor) END_INTERFACE_MEMBER(GuiDocumentViewer::IStyleProvider) BEGIN_CLASS_MEMBER(GuiDocumentLabel) diff --git a/Import/GacUIReflection.h b/Import/GacUIReflection.h index f92f87bd..351b62ff 100644 --- a/Import/GacUIReflection.h +++ b/Import/GacUIReflection.h @@ -1927,6 +1927,11 @@ Interface Proxy { INVOKEGET_INTERFACE_PROXY_NOPARAMS(GetBaselineDocument); } + + presentation::Color GetCaretColor()override + { + INVOKEGET_INTERFACE_PROXY_NOPARAMS(GetCaretColor); + } END_INTERFACE_PROXY(presentation::controls::GuiDocumentViewer::IStyleProvider) BEGIN_INTERFACE_PROXY_RAWPTR(presentation::controls::GuiDocumentLabel::IStyleController, diff --git a/Import/GacUIWindows.cpp b/Import/GacUIWindows.cpp index 23eabef7..62116b42 100644 --- a/Import/GacUIWindows.cpp +++ b/Import/GacUIWindows.cpp @@ -1523,74 +1523,6 @@ WindowsController return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; } - bool IsWindowsServer() - { - OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, VER_NT_WORKSTATION }; - DWORDLONG const dwlConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL ); - - return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask); - } - - WString GetOSVersion() - { - const vint SystemCount = 5; - DWORD SystemVersions[SystemCount] = - { - _WIN32_WINNT_WIN2K, - _WIN32_WINNT_WINXP, - _WIN32_WINNT_VISTA, - _WIN32_WINNT_WIN7, - _WIN32_WINNT_WIN8 - }; - vint SystemMaxServerPacks[SystemCount] = - { - 4, - 3, - 2, - 1, - 0, - }; - const wchar_t* SystemClientNames[SystemCount] = - { - L"Windows 2000", - L"Windows XP", - L"Windows Vista", - L"Windows 7", - L"Windows 8", - }; - const wchar_t* SystemServerNames[SystemCount] = - { - L"Windows Server 2003", - L"Windows Server 2003 R2", - L"Windows Server 2008", - L"Windows Server 2008 R2", - L"Windows Server 2012", - }; - - bool isWindowsServer = IsWindowsServer(); - for(vint systemIndex = SystemCount-1; systemIndex >=0; systemIndex--) - { - DWORD systemVersion = SystemVersions[systemIndex]; - vint maxSp = SystemMaxServerPacks[systemIndex]; - for(vint sp = maxSp; sp>=0; sp--) - { - if(IsWindowsVersionEqualOrGreater(HIBYTE(systemVersion), LOBYTE(systemVersion), (WORD)sp)) - { - WString systemName = isWindowsServer?SystemServerNames[systemIndex]:SystemClientNames[systemIndex]; - if(sp==0) - { - return systemName+L";"; - } - else - { - return systemName+L";SP"+itow(sp); - } - } - } - } - return L"Windows "; - } - WString GetExecutablePath() { Array buffer(65536); @@ -9793,10 +9725,6 @@ GuiGDIElement GuiGDIElement::GuiGDIElement() { } - - GuiGDIElement::~GuiGDIElement() - { - } } namespace elements_windows_gdi @@ -12816,10 +12744,6 @@ GuiDirect2DElement GuiDirect2DElement::GuiDirect2DElement() { } - - GuiDirect2DElement::~GuiDirect2DElement() - { - } } namespace elements_windows_d2d diff --git a/Import/GacUIWindows.h b/Import/GacUIWindows.h index 576e491b..9f706a79 100644 --- a/Import/GacUIWindows.h +++ b/Import/GacUIWindows.h @@ -140,8 +140,8 @@ namespace vl { friend class WinMetaFile; protected: - vint FWidth; - vint FHeight; + vint FWidth; + vint FHeight; WinProxyDC* FDC; void Create(vint Width, vint Height); @@ -157,8 +157,8 @@ namespace vl void LoadFrom(WString FileName); void SaveTo(WString FileName); WinDC* GetWinDC(); - vint GetWidth(); - vint GetHeight(); + vint GetWidth(); + vint GetHeight(); }; class WinMetaFile : public Object @@ -166,16 +166,16 @@ namespace vl friend class WinMetaFileBuilder; protected: HENHMETAFILE FHandle; - vint FWidth; - vint FHeight; + vint FWidth; + vint FHeight; public: WinMetaFile(WString FileName); WinMetaFile(WinMetaFileBuilder* Builder); ~WinMetaFile(); HENHMETAFILE GetHandle(); - vint GetWidth(); - vint GetHeight(); + vint GetWidth(); + vint GetHeight(); }; class WinBitmap : public Object @@ -190,15 +190,15 @@ namespace vl }; protected: BitmapBits FBits; - vint FWidth; - vint FHeight; + vint FWidth; + vint FHeight; WinImageDC* FDC; HBITMAP FHandle; BYTE** FScanLines; bool FAlphaChannelBuilt; - vint GetBitsFromBB(BitmapBits BB); - vint GetLineBytes(vint Width, BitmapBits BB); + vint GetBitsFromBB(BitmapBits BB); + vint GetLineBytes(vint Width, BitmapBits BB); void FillBitmapInfoHeader(vint Width, vint Height, BitmapBits Bits, BITMAPINFOHEADER* Header); HBITMAP CreateDDB(vint Width, vint Height, BitmapBits Bits); HBITMAP CreateDIB(vint Width, vint Height, BitmapBits Bits, BYTE**& ScanLines); @@ -211,9 +211,9 @@ namespace vl void SaveToFile(WString FileName); WinDC* GetWinDC(); - vint GetWidth(); - vint GetHeight(); - vint GetLineBytes(); + vint GetWidth(); + vint GetHeight(); + vint GetLineBytes(); BYTE** GetScanLines(); HBITMAP GetBitmap(); BitmapBits GetBitmapBits(); @@ -237,7 +237,7 @@ namespace vl class WinBrush : public Object { public: - typedef Ptr Ptr; + typedef Ptr Ptr; protected: HBRUSH FHandle; unsigned char* FDIBMemory; @@ -1118,14 +1118,12 @@ Raw API Rendering Element /// /// Defines an element for customized rendering using GDI. /// - class GuiGDIElement : public Object, public IGuiGraphicsElement, public Description + class GuiGDIElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiGDIElement, L"GDIElement") protected: GuiGDIElement(); public: - ~GuiGDIElement(); - /// Rendering event. compositions::GuiGraphicsEvent Rendering; }; @@ -1874,14 +1872,12 @@ Raw API Rendering Element /// /// Defines an element for customized rendering using Direct2D. /// - class GuiDirect2DElement : public Object, public IGuiGraphicsElement, public Description + class GuiDirect2DElement : public GuiElementBase { DEFINE_GUI_GRAPHICS_ELEMENT(GuiDirect2DElement, L"Direct2DElement") protected: GuiDirect2DElement(); public: - ~GuiDirect2DElement(); - /// 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. diff --git a/Tools/GacGen.exe b/Tools/GacGen.exe index aba1b08a..5ecfdb8e 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen.exe differ diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Skin.xml b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Skin.xml index 259d967b..8bca09bb 100644 Binary files a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Skin.xml and b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Skin.xml differ diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Source/DemoPartialClasses.cpp index bdb77ce5..2c51d72c 100644 --- a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/Source/DemoPartialClasses.cpp @@ -19162,6 +19162,9 @@ Class (::darkskin::DocumentViewerTemplateConstructor) { ::vl::__vwsn::This(::vl::__vwsn::This(this)->self)->SetDefaultScrollSize(::vl::__vwsn::Parse<::vl::vint32_t>(::vl::WString(L"20", false))); } + { + ::vl::__vwsn::This(::vl::__vwsn::This(this)->self)->SetCaretColor(::vl::__vwsn::Parse<::vl::presentation::Color>(::vl::WString(L"#FFFFFF", false))); + } { ::vl::__vwsn::This(::vl::__vwsn::This(this)->self)->SetMinSizeLimitation(::vl::presentation::compositions::GuiGraphicsComposition::MinSizeLimitation::LimitToElementAndChildren); } diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin index 102f3066..c67575ff 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin and b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin differ