mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-30 04:55:18 +08:00
Update release
This commit is contained in:
+121
-34
@@ -15137,6 +15137,18 @@ GuiDocumentCommonInterface
|
||||
}
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::EnsureDocumentRectVisible(Rect bounds)
|
||||
{
|
||||
if (bounds != Rect())
|
||||
{
|
||||
bounds.x1 -= 15;
|
||||
bounds.y1 -= 15;
|
||||
bounds.x2 += 15;
|
||||
bounds.y2 += 15;
|
||||
EnsureRectVisible(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::Move(TextPos caret, bool shift, bool frontSide)
|
||||
{
|
||||
TextPos begin=documentElement->GetCaretBegin();
|
||||
@@ -15146,16 +15158,7 @@ GuiDocumentCommonInterface
|
||||
TextPos newEnd=caret;
|
||||
documentElement->SetCaret(newBegin, newEnd, frontSide);
|
||||
documentElement->SetCaretVisible(true);
|
||||
|
||||
Rect bounds=documentElement->GetCaretBounds(newEnd, frontSide);
|
||||
if(bounds!=Rect())
|
||||
{
|
||||
bounds.x1-=15;
|
||||
bounds.y1-=15;
|
||||
bounds.x2+=15;
|
||||
bounds.y2+=15;
|
||||
EnsureRectVisible(bounds);
|
||||
}
|
||||
EnsureDocumentRectVisible(documentElement->GetCaretBounds(newEnd, frontSide));
|
||||
UpdateCaretPoint();
|
||||
SelectionChanged.Execute(documentControl->GetNotifyEventArguments());
|
||||
}
|
||||
@@ -15276,26 +15279,23 @@ GuiDocumentCommonInterface
|
||||
|
||||
void GuiDocumentCommonInterface::InstallDocumentViewer(
|
||||
GuiControl* _sender,
|
||||
compositions::GuiGraphicsComposition* _mouseArea,
|
||||
compositions::GuiGraphicsComposition* _container,
|
||||
compositions::GuiGraphicsComposition* eventComposition,
|
||||
compositions::GuiGraphicsComposition* focusableComposition
|
||||
)
|
||||
)
|
||||
{
|
||||
documentControl=_sender;
|
||||
documentControl = _sender;
|
||||
|
||||
documentElement=GuiDocumentElement::Create();
|
||||
documentElement = GuiDocumentElement::Create();
|
||||
documentElement->SetCallback(this);
|
||||
|
||||
documentComposition=new GuiBoundsComposition;
|
||||
documentComposition = new GuiBoundsComposition;
|
||||
documentComposition->SetOwnedElement(documentElement);
|
||||
documentComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElement);
|
||||
documentComposition->SetAlignmentToParent(Margin(5, 5, 5, 5));
|
||||
_container->AddChild(documentComposition);
|
||||
|
||||
documentComposition->GetEventReceiver()->mouseMove.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseMove);
|
||||
documentComposition->GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseDown);
|
||||
documentComposition->GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseUp);
|
||||
documentComposition->GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseLeave);
|
||||
ReplaceMouseArea(_mouseArea);
|
||||
|
||||
focusableComposition->GetEventReceiver()->caretNotify.AttachMethod(this, &GuiDocumentCommonInterface::OnCaretNotify);
|
||||
focusableComposition->GetEventReceiver()->gotFocus.AttachMethod(this, &GuiDocumentCommonInterface::OnGotFocus);
|
||||
@@ -15315,6 +15315,30 @@ GuiDocumentCommonInterface
|
||||
SetDocument(new DocumentModel);
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::ReplaceMouseArea(compositions::GuiGraphicsComposition* _mouseArea)
|
||||
{
|
||||
if (documentMouseArea)
|
||||
{
|
||||
documentMouseArea->GetEventReceiver()->mouseMove.Detach(onMouseMoveHandler);
|
||||
documentMouseArea->GetEventReceiver()->leftButtonDown.Detach(onMouseDownHandler);
|
||||
documentMouseArea->GetEventReceiver()->leftButtonUp.Detach(onMouseUpHandler);
|
||||
documentMouseArea->GetEventReceiver()->mouseLeave.Detach(onMouseLeaveHandler);
|
||||
|
||||
onMouseMoveHandler = nullptr;
|
||||
onMouseDownHandler = nullptr;
|
||||
onMouseUpHandler = nullptr;
|
||||
onMouseLeaveHandler = nullptr;
|
||||
}
|
||||
documentMouseArea = _mouseArea;
|
||||
if (documentMouseArea)
|
||||
{
|
||||
onMouseMoveHandler = documentMouseArea->GetEventReceiver()->mouseMove.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseMove);
|
||||
onMouseDownHandler = documentMouseArea->GetEventReceiver()->leftButtonDown.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseDown);
|
||||
onMouseUpHandler = documentMouseArea->GetEventReceiver()->leftButtonUp.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseUp);
|
||||
onMouseLeaveHandler = documentMouseArea->GetEventReceiver()->mouseLeave.AttachMethod(this, &GuiDocumentCommonInterface::OnMouseLeave);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::SetActiveHyperlink(Ptr<DocumentHyperlinkRun::Package> package)
|
||||
{
|
||||
ActivateActiveHyperlink(false);
|
||||
@@ -15379,6 +15403,7 @@ GuiDocumentCommonInterface
|
||||
caret=TextPos(begin.row+paragraphCount-1, lastParagraphLength);
|
||||
}
|
||||
documentElement->SetCaret(caret, caret, true);
|
||||
EnsureDocumentRectVisible(documentElement->GetCaretBounds(caret, true));
|
||||
documentControl->TextChanged.Execute(documentControl->GetNotifyEventArguments());
|
||||
UpdateCaretPoint();
|
||||
SelectionChanged.Execute(documentControl->GetNotifyEventArguments());
|
||||
@@ -15507,15 +15532,44 @@ GuiDocumentCommonInterface
|
||||
}
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::UpdateCursor(INativeCursor* cursor)
|
||||
{
|
||||
if (documentMouseArea)
|
||||
{
|
||||
documentMouseArea->SetAssociatedCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
Point GuiDocumentCommonInterface::GetMouseOffset()
|
||||
{
|
||||
if (documentMouseArea)
|
||||
{
|
||||
auto documentBounds = documentComposition->GetGlobalBounds();
|
||||
auto mouseAreaBounds = documentMouseArea->GetGlobalBounds();
|
||||
return Point(
|
||||
documentBounds.x1 - mouseAreaBounds.x1,
|
||||
documentBounds.y1 - mouseAreaBounds.y1
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Point(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiDocumentCommonInterface::OnMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments)
|
||||
{
|
||||
auto offset = GetMouseOffset();
|
||||
auto x = arguments.x - offset.x;
|
||||
auto y = arguments.y - offset.y;
|
||||
|
||||
if(documentControl->GetVisuallyEnabled())
|
||||
{
|
||||
switch(editMode)
|
||||
{
|
||||
case ViewOnly:
|
||||
{
|
||||
auto package = documentElement->GetHyperlinkFromPoint({ arguments.x, arguments.y });
|
||||
auto package = documentElement->GetHyperlinkFromPoint({ x, y });
|
||||
bool handCursor = false;
|
||||
|
||||
if(dragging)
|
||||
@@ -15542,11 +15596,11 @@ GuiDocumentCommonInterface
|
||||
if(handCursor)
|
||||
{
|
||||
auto cursor = GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::Hand);
|
||||
documentComposition->SetAssociatedCursor(cursor);
|
||||
UpdateCursor(cursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
documentComposition->SetAssociatedCursor(nullptr);
|
||||
UpdateCursor(nullptr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -15554,7 +15608,7 @@ GuiDocumentCommonInterface
|
||||
case Editable:
|
||||
if(dragging)
|
||||
{
|
||||
TextPos caret=documentElement->CalculateCaretFromPoint(Point(arguments.x, arguments.y));
|
||||
TextPos caret=documentElement->CalculateCaretFromPoint(Point(x, y));
|
||||
TextPos oldCaret=documentElement->GetCaretBegin();
|
||||
Move(caret, true, (oldCaret==caret?documentElement->IsCaretEndPreferFrontSide():caret<oldCaret));
|
||||
}
|
||||
@@ -15565,18 +15619,22 @@ GuiDocumentCommonInterface
|
||||
|
||||
void GuiDocumentCommonInterface::OnMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments)
|
||||
{
|
||||
auto offset = GetMouseOffset();
|
||||
auto x = arguments.x - offset.x;
|
||||
auto y = arguments.y - offset.y;
|
||||
|
||||
if(documentControl->GetVisuallyEnabled())
|
||||
{
|
||||
switch(editMode)
|
||||
{
|
||||
case ViewOnly:
|
||||
SetActiveHyperlink(documentElement->GetHyperlinkFromPoint({ arguments.x, arguments.y }));
|
||||
SetActiveHyperlink(documentElement->GetHyperlinkFromPoint({ x, y }));
|
||||
break;
|
||||
case Selectable:
|
||||
case Editable:
|
||||
{
|
||||
documentControl->SetFocus();
|
||||
TextPos caret=documentElement->CalculateCaretFromPoint(Point(arguments.x, arguments.y));
|
||||
TextPos caret=documentElement->CalculateCaretFromPoint(Point(x, y));
|
||||
TextPos oldCaret=documentElement->GetCaretEnd();
|
||||
if(caret!=oldCaret)
|
||||
{
|
||||
@@ -15591,6 +15649,10 @@ GuiDocumentCommonInterface
|
||||
|
||||
void GuiDocumentCommonInterface::OnMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments)
|
||||
{
|
||||
auto offset = GetMouseOffset();
|
||||
auto x = arguments.x - offset.x;
|
||||
auto y = arguments.y - offset.y;
|
||||
|
||||
if(documentControl->GetVisuallyEnabled())
|
||||
{
|
||||
dragging=false;
|
||||
@@ -15598,7 +15660,7 @@ GuiDocumentCommonInterface
|
||||
{
|
||||
case ViewOnly:
|
||||
{
|
||||
auto package = documentElement->GetHyperlinkFromPoint({ arguments.x, arguments.y });
|
||||
auto package = documentElement->GetHyperlinkFromPoint({ x, y });
|
||||
if(activeHyperlinks)
|
||||
{
|
||||
if (package && CompareEnumerable(activeHyperlinks->hyperlinks, package->hyperlinks) == 0)
|
||||
@@ -15619,7 +15681,7 @@ GuiDocumentCommonInterface
|
||||
|
||||
void GuiDocumentCommonInterface::OnMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments)
|
||||
{
|
||||
SetActiveHyperlink(0);
|
||||
SetActiveHyperlink(nullptr);
|
||||
}
|
||||
|
||||
Point GuiDocumentCommonInterface::GetDocumentViewPosition()
|
||||
@@ -15971,12 +16033,12 @@ GuiDocumentCommonInterface
|
||||
editMode=value;
|
||||
if(editMode==ViewOnly)
|
||||
{
|
||||
documentComposition->SetAssociatedCursor(0);
|
||||
UpdateCursor(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
INativeCursor* cursor=GetCurrentController()->ResourceService()->GetSystemCursor(INativeCursor::IBeam);
|
||||
documentComposition->SetAssociatedCursor(cursor);
|
||||
UpdateCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16213,6 +16275,7 @@ GuiDocumentViewer
|
||||
|
||||
void GuiDocumentViewer::BeforeControlTemplateUninstalled_()
|
||||
{
|
||||
ReplaceMouseArea(nullptr);
|
||||
}
|
||||
|
||||
void GuiDocumentViewer::AfterControlTemplateInstalled_(bool initialize)
|
||||
@@ -16224,6 +16287,7 @@ GuiDocumentViewer
|
||||
documentElement->SetCaretColor(ct->GetCaretColor());
|
||||
SetDocument(GetDocument());
|
||||
}
|
||||
ReplaceMouseArea(containerComposition->GetParent());
|
||||
}
|
||||
|
||||
void GuiDocumentViewer::UpdateDisplayFont()
|
||||
@@ -16261,7 +16325,7 @@ GuiDocumentViewer
|
||||
{
|
||||
SetAcceptTabInput(true);
|
||||
SetFocusableComposition(boundsComposition);
|
||||
InstallDocumentViewer(this, containerComposition, boundsComposition, focusableComposition);
|
||||
InstallDocumentViewer(this, containerComposition->GetParent(), containerComposition, boundsComposition, focusableComposition);
|
||||
|
||||
SetExtendToFullWidth(true);
|
||||
SetHorizontalAlwaysVisible(false);
|
||||
@@ -16313,7 +16377,7 @@ GuiDocumentLabel
|
||||
{
|
||||
SetAcceptTabInput(true);
|
||||
SetFocusableComposition(boundsComposition);
|
||||
InstallDocumentViewer(this, containerComposition, boundsComposition, focusableComposition);
|
||||
InstallDocumentViewer(this, containerComposition, containerComposition, boundsComposition, focusableComposition);
|
||||
}
|
||||
|
||||
GuiDocumentLabel::~GuiDocumentLabel()
|
||||
@@ -20572,6 +20636,23 @@ GuiMenu
|
||||
Hide();
|
||||
}
|
||||
|
||||
void GuiMenu::Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder)
|
||||
{
|
||||
GuiPopup::Moving(bounds, fixSizeOnly, draggingBorder);
|
||||
if (draggingBorder)
|
||||
{
|
||||
if (auto nativeWindow = GetNativeWindow())
|
||||
{
|
||||
auto newSize = bounds.GetSize();
|
||||
auto nativeOffset = (nativeWindow->GetBounds().GetSize() - nativeWindow->GetClientSize());
|
||||
auto preferredNativeSize = nativeWindow->Convert(preferredMenuClientSizeBeforeUpdating) + nativeOffset;
|
||||
if (newSize.x < preferredNativeSize.x) newSize.x = preferredNativeSize.x;
|
||||
if (newSize.y < preferredNativeSize.y) newSize.y = preferredNativeSize.y;
|
||||
preferredMenuClientSize = nativeWindow->Convert(newSize - nativeOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuiMenu::UpdateClientSizeAfterRendering(Size preferredSize, Size clientSize)
|
||||
{
|
||||
auto size = preferredSize;
|
||||
@@ -20661,6 +20742,7 @@ GuiMenu
|
||||
void GuiMenu::SetPreferredMenuClientSize(Size value)
|
||||
{
|
||||
preferredMenuClientSize = value;
|
||||
preferredMenuClientSizeBeforeUpdating = value;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -29369,6 +29451,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
|
||||
Ptr<DocumentHyperlinkRun::Package> GuiDocumentElement::GuiDocumentElementRenderer::GetHyperlinkFromPoint(Point point)
|
||||
{
|
||||
if (!renderTarget) return nullptr;
|
||||
vint top=0;
|
||||
vint index=-1;
|
||||
if(GetParagraphIndexFromPoint(point, top, index))
|
||||
@@ -29386,7 +29469,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
vint caret=cache->graphicsParagraph->GetCaretFromPoint(paragraphPoint);
|
||||
return element->document->GetHyperlink(index, caret, caret);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GuiDocumentElement::GuiDocumentElementRenderer::OpenCaret(TextPos caret, Color color, bool frontSide)
|
||||
@@ -29433,6 +29516,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
end=TextPos(-1, -1);
|
||||
}
|
||||
|
||||
if (!renderTarget) return;
|
||||
for(vint i=0;i<paragraphCaches.Count();i++)
|
||||
{
|
||||
if(begin.row<=i && i<=end.row)
|
||||
@@ -29466,6 +29550,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
|
||||
TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaret(TextPos comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide)
|
||||
{
|
||||
if (!renderTarget) return comparingCaret;
|
||||
Ptr<ParagraphCache> cache=EnsureAndGetCache(comparingCaret.row, true);
|
||||
if(cache)
|
||||
{
|
||||
@@ -29563,6 +29648,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
|
||||
TextPos GuiDocumentElement::GuiDocumentElementRenderer::CalculateCaretFromPoint(Point point)
|
||||
{
|
||||
if (!renderTarget) return TextPos(-1, -1);
|
||||
vint top=0;
|
||||
vint index=-1;
|
||||
if(GetParagraphIndexFromPoint(point, top, index))
|
||||
@@ -29577,6 +29663,7 @@ GuiDocumentElement::GuiDocumentElementRenderer
|
||||
|
||||
Rect GuiDocumentElement::GuiDocumentElementRenderer::GetCaretBounds(TextPos caret, bool frontSide)
|
||||
{
|
||||
if (!renderTarget) return Rect();
|
||||
Ptr<ParagraphCache> cache=EnsureAndGetCache(caret.row, true);
|
||||
if(cache)
|
||||
{
|
||||
@@ -31840,7 +31927,7 @@ GuiGraphicsHost
|
||||
return INativeWindowListener::NoDecision;
|
||||
}
|
||||
|
||||
void GuiGraphicsHost::Moving(NativeRect& bounds, bool fixSizeOnly)
|
||||
void GuiGraphicsHost::Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder)
|
||||
{
|
||||
NativeRect oldBounds = hostRecord.nativeWindow->GetBounds();
|
||||
minSize = windowComposition->GetPreferredBounds().GetSize();
|
||||
@@ -33092,7 +33179,7 @@ INativeWindowListener
|
||||
return INativeWindowListener::NoDecision;
|
||||
}
|
||||
|
||||
void INativeWindowListener::Moving(NativeRect& bounds, bool fixSizeOnly)
|
||||
void INativeWindowListener::Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+26
-4
@@ -2414,8 +2414,9 @@ Native Window
|
||||
/// Called when the window is moving.
|
||||
/// </summary>
|
||||
/// <param name="bounds">The bounds. Message handler can change the bounds.</param>
|
||||
/// <param name="fixSizeOnly">True if the message raise only want the message handler to change the size.</param>
|
||||
virtual void Moving(NativeRect& bounds, bool fixSizeOnly);
|
||||
/// <param name="fixSizeOnly">True if the message raise only want the message handler to change the size, and keep the position unchanged.</param>
|
||||
/// <param name="draggingBorder">True if the message raise because the user is dragging the border to change the size.</param>
|
||||
virtual void Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder);
|
||||
/// <summary>
|
||||
/// Called when the window is moved.
|
||||
/// </summary>
|
||||
@@ -6243,7 +6244,7 @@ Host
|
||||
|
||||
private:
|
||||
INativeWindowListener::HitTestResult HitTest(NativePoint location)override;
|
||||
void Moving(NativeRect& bounds, bool fixSizeOnly)override;
|
||||
void Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder)override;
|
||||
void Moved()override;
|
||||
void DpiChanged()override;
|
||||
void Paint()override;
|
||||
@@ -14369,6 +14370,13 @@ GuiDocumentCommonInterface
|
||||
GuiControl* documentControl = nullptr;
|
||||
elements::GuiDocumentElement* documentElement = nullptr;
|
||||
compositions::GuiBoundsComposition* documentComposition = nullptr;
|
||||
|
||||
compositions::GuiGraphicsComposition* documentMouseArea = nullptr;
|
||||
Ptr<compositions::IGuiGraphicsEventHandler> onMouseMoveHandler;
|
||||
Ptr<compositions::IGuiGraphicsEventHandler> onMouseDownHandler;
|
||||
Ptr<compositions::IGuiGraphicsEventHandler> onMouseUpHandler;
|
||||
Ptr<compositions::IGuiGraphicsEventHandler> onMouseLeaveHandler;
|
||||
|
||||
Ptr<DocumentHyperlinkRun::Package> activeHyperlinks;
|
||||
bool dragging = false;
|
||||
EditMode editMode = EditMode::ViewOnly;
|
||||
@@ -14380,9 +14388,18 @@ GuiDocumentCommonInterface
|
||||
void InvokeUndoRedoChanged();
|
||||
void InvokeModifiedChanged();
|
||||
void UpdateCaretPoint();
|
||||
void EnsureDocumentRectVisible(Rect bounds);
|
||||
void Move(TextPos caret, bool shift, bool frontSide);
|
||||
bool ProcessKey(VKEY code, bool shift, bool ctrl);
|
||||
void InstallDocumentViewer(GuiControl* _sender, compositions::GuiGraphicsComposition* _container, compositions::GuiGraphicsComposition* eventComposition, compositions::GuiGraphicsComposition* focusableComposition);
|
||||
void InstallDocumentViewer(
|
||||
GuiControl* _sender,
|
||||
compositions::GuiGraphicsComposition* _mouseArea,
|
||||
compositions::GuiGraphicsComposition* _container,
|
||||
compositions::GuiGraphicsComposition* eventComposition,
|
||||
compositions::GuiGraphicsComposition* focusableComposition
|
||||
);
|
||||
void ReplaceMouseArea(compositions::GuiGraphicsComposition* _mouseArea);
|
||||
|
||||
void SetActiveHyperlink(Ptr<DocumentHyperlinkRun::Package> package);
|
||||
void ActivateActiveHyperlink(bool activate);
|
||||
void AddShortcutCommand(VKEY key, const Func<void()>& eventHandler);
|
||||
@@ -14396,6 +14413,9 @@ GuiDocumentCommonInterface
|
||||
void OnLostFocus(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments);
|
||||
void OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments);
|
||||
void OnCharInput(compositions::GuiGraphicsComposition* sender, compositions::GuiCharEventArgs& arguments);
|
||||
|
||||
void UpdateCursor(INativeCursor* cursor);
|
||||
Point GetMouseOffset();
|
||||
void OnMouseMove(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments);
|
||||
void OnMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments);
|
||||
void OnMouseUp(compositions::GuiGraphicsComposition* sender, compositions::GuiMouseEventArgs& arguments);
|
||||
@@ -15760,6 +15780,7 @@ Menu
|
||||
private:
|
||||
IGuiMenuService* parentMenuService = nullptr;
|
||||
bool hideOnDeactivateAltHost = true;
|
||||
Size preferredMenuClientSizeBeforeUpdating;
|
||||
Size preferredMenuClientSize;
|
||||
|
||||
IGuiMenuService* GetParentMenuService()override;
|
||||
@@ -15768,6 +15789,7 @@ Menu
|
||||
bool IsSubMenuActivatedByMouseDown()override;
|
||||
void MenuItemExecuted()override;
|
||||
|
||||
void Moving(NativeRect& bounds, bool fixSizeOnly, bool draggingBorder)override;
|
||||
void UpdateClientSizeAfterRendering(Size preferredSize, Size clientSize)override;
|
||||
protected:
|
||||
GuiControl* owner;
|
||||
|
||||
+189
-70
@@ -725,7 +725,7 @@ WindowsDirect2DParagraph (Formatting)
|
||||
{
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
textLayout->GetMetrics(&metrics);
|
||||
return (vint)metrics.height;
|
||||
return (vint)ceil(metrics.height);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -774,49 +774,106 @@ WindowsDirect2DParagraph (Rendering)
|
||||
return true;
|
||||
}
|
||||
|
||||
struct BackgroundRenderer
|
||||
{
|
||||
IWindowsDirect2DRenderTarget* renderTarget = nullptr;
|
||||
ID2D1SolidColorBrush* lastBackgroundBrush = nullptr;
|
||||
FLOAT lbx1, lby1, lbx2, lby2;
|
||||
|
||||
void RenderBackground()
|
||||
{
|
||||
if (lastBackgroundBrush)
|
||||
{
|
||||
renderTarget->GetDirect2DRenderTarget()->FillRectangle(
|
||||
D2D1::RectF(lbx1, lby1, lbx2, lby2),
|
||||
lastBackgroundBrush
|
||||
);
|
||||
lastBackgroundBrush = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SubmitBackground(ID2D1SolidColorBrush* brush, FLOAT x1, FLOAT y1, FLOAT x2, FLOAT y2)
|
||||
{
|
||||
if (lastBackgroundBrush)
|
||||
{
|
||||
if (lastBackgroundBrush != brush)
|
||||
{
|
||||
RenderBackground();
|
||||
}
|
||||
else
|
||||
{
|
||||
FLOAT yc = (y1 + y2) / 2;
|
||||
if (yc<lby1 || yc>lby2)
|
||||
{
|
||||
RenderBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastBackgroundBrush)
|
||||
{
|
||||
if (lbx1 > x1) lbx1 = x1;
|
||||
if (lby1 > y1) lby1 = y1;
|
||||
if (lbx2 < x2) lbx2 = x2;
|
||||
if (lby2 < y2) lby2 = y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastBackgroundBrush = brush;
|
||||
lbx1 = x1;
|
||||
lby1 = y1;
|
||||
lbx2 = x2;
|
||||
lby2 = y2;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Render(Rect bounds)override
|
||||
{
|
||||
paragraphOffset = bounds.LeftTop();
|
||||
PrepareFormatData();
|
||||
for(vint i=0;i<backgroundColors.Count();i++)
|
||||
{
|
||||
TextRange key=backgroundColors.Keys()[i];
|
||||
Color color=backgroundColors.Values()[i];
|
||||
if(color.a>0)
|
||||
BackgroundRenderer backgroundRenderer;
|
||||
backgroundRenderer.renderTarget = renderTarget;
|
||||
|
||||
for (vint i = 0; i < backgroundColors.Count(); i++)
|
||||
{
|
||||
ID2D1SolidColorBrush* brush=renderTarget->CreateDirect2DBrush(color);
|
||||
|
||||
vint start=key.start;
|
||||
if(start<0)
|
||||
TextRange key = backgroundColors.Keys()[i];
|
||||
Color color = backgroundColors.Values()[i];
|
||||
if (color.a > 0)
|
||||
{
|
||||
start=0;
|
||||
ID2D1SolidColorBrush* brush = renderTarget->CreateDirect2DBrush(color);
|
||||
|
||||
vint start = key.start;
|
||||
if (start < 0)
|
||||
{
|
||||
start = 0;
|
||||
}
|
||||
|
||||
while (start < charHitTestMap.Count() && start < key.end)
|
||||
{
|
||||
vint index = charHitTestMap[start];
|
||||
DWRITE_HIT_TEST_METRICS& hitTest = hitTestMetrics[index];
|
||||
|
||||
FLOAT x1 = hitTest.left + (FLOAT)bounds.x1;
|
||||
FLOAT y1 = hitTest.top + (FLOAT)bounds.y1;
|
||||
FLOAT x2 = x1 + hitTest.width;
|
||||
FLOAT y2 = y1 + hitTest.height;
|
||||
|
||||
x1 -= 0.5f;
|
||||
y1 -= 0.0f;
|
||||
x2 += 0.5f;
|
||||
y2 += 0.5f;
|
||||
|
||||
backgroundRenderer.SubmitBackground(brush, x1, y1, x2, y2);
|
||||
start = hitTest.textPosition + hitTest.length;
|
||||
}
|
||||
|
||||
renderTarget->DestroyDirect2DBrush(color);
|
||||
}
|
||||
|
||||
while(start<charHitTestMap.Count() && start<key.end)
|
||||
{
|
||||
vint index=charHitTestMap[start];
|
||||
DWRITE_HIT_TEST_METRICS& hitTest=hitTestMetrics[index];
|
||||
|
||||
FLOAT x1=hitTest.left+(FLOAT)bounds.x1;
|
||||
FLOAT y1=hitTest.top+(FLOAT)bounds.y1;
|
||||
FLOAT x2=x1+hitTest.width;
|
||||
FLOAT y2=y1+hitTest.height;
|
||||
|
||||
x1-=0.5f;
|
||||
y1-=0.0f;
|
||||
x2+=0.5f;
|
||||
y2+=0.5f;
|
||||
|
||||
renderTarget->GetDirect2DRenderTarget()->FillRectangle(
|
||||
D2D1::RectF(x1, y1, x2, y2),
|
||||
brush
|
||||
);
|
||||
|
||||
start=hitTest.textPosition+hitTest.length;
|
||||
}
|
||||
|
||||
renderTarget->DestroyDirect2DBrush(color);
|
||||
}
|
||||
|
||||
backgroundRenderer.RenderBackground();
|
||||
}
|
||||
|
||||
renderTarget->GetDirect2DRenderTarget()->DrawTextLayout(
|
||||
@@ -825,23 +882,23 @@ WindowsDirect2DParagraph (Rendering)
|
||||
defaultTextColor,
|
||||
D2D1_DRAW_TEXT_OPTIONS_NO_SNAP);
|
||||
|
||||
if(caret!=-1)
|
||||
if (caret != -1)
|
||||
{
|
||||
Rect caretBounds=GetCaretBounds(caret, caretFrontSide);
|
||||
vint x=caretBounds.x1+bounds.x1;
|
||||
vint y1=caretBounds.y1+bounds.y1;
|
||||
vint y2=y1+caretBounds.Height();
|
||||
Rect caretBounds = GetCaretBounds(caret, caretFrontSide);
|
||||
vint x = caretBounds.x1 + bounds.x1;
|
||||
vint y1 = caretBounds.y1 + bounds.y1;
|
||||
vint y2 = y1 + caretBounds.Height();
|
||||
|
||||
renderTarget->GetDirect2DRenderTarget()->DrawLine(
|
||||
D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y1+0.5f),
|
||||
D2D1::Point2F((FLOAT)x-0.5f, (FLOAT)y2+0.5f),
|
||||
D2D1::Point2F((FLOAT)x - 0.5f, (FLOAT)y1 + 0.5f),
|
||||
D2D1::Point2F((FLOAT)x - 0.5f, (FLOAT)y2 + 0.5f),
|
||||
caretBrush
|
||||
);
|
||||
);
|
||||
renderTarget->GetDirect2DRenderTarget()->DrawLine(
|
||||
D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y1+0.5f),
|
||||
D2D1::Point2F((FLOAT)x+0.5f, (FLOAT)y2+0.5f),
|
||||
D2D1::Point2F((FLOAT)x + 0.5f, (FLOAT)y1 + 0.5f),
|
||||
D2D1::Point2F((FLOAT)x + 0.5f, (FLOAT)y2 + 0.5f),
|
||||
caretBrush
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8306,17 +8363,49 @@ WindowsForm
|
||||
ImmReleaseContext(handle, imc);
|
||||
}
|
||||
|
||||
bool supressClosePopups = false;
|
||||
|
||||
static void ClosePopupsOf(WindowsForm* owner, SortedList<WindowsForm*>& exceptions)
|
||||
{
|
||||
for (vint i = 0; i < owner->childWindows.Count(); i++)
|
||||
{
|
||||
auto popup = owner->childWindows[i];
|
||||
if (popup->windowMode != Normal && popup->IsVisible())
|
||||
{
|
||||
if (!exceptions.Contains(popup))
|
||||
{
|
||||
popup->Hide(false);
|
||||
}
|
||||
}
|
||||
ClosePopupsOf(popup, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
bool HandleMessageInternal(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result)
|
||||
{
|
||||
// handling popup windows
|
||||
if (!supressClosePopups)
|
||||
{
|
||||
bool closeChildPopups = false;
|
||||
bool closePopups = false;
|
||||
WindowsForm* activatedWindow = nullptr;
|
||||
WindowsForm* rootWindow = nullptr;
|
||||
SortedList<WindowsForm*> exceptions;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_ACTIVATE:
|
||||
if (wParam == WA_INACTIVE && windowMode == Normal)
|
||||
case WM_ACTIVATEAPP:
|
||||
if (wParam == FALSE)
|
||||
{
|
||||
closeChildPopups = true;
|
||||
closePopups = true;
|
||||
}
|
||||
break;
|
||||
case WM_ACTIVATE:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case WA_ACTIVE:
|
||||
case WA_CLICKACTIVE:
|
||||
activatedWindow = this;
|
||||
closePopups = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
@@ -8325,29 +8414,32 @@ WindowsForm
|
||||
case WM_NCLBUTTONDOWN:
|
||||
case WM_NCMBUTTONDOWN:
|
||||
case WM_NCRBUTTONDOWN:
|
||||
closeChildPopups = true;
|
||||
activatedWindow = this;
|
||||
closePopups = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (closeChildPopups)
|
||||
if (activatedWindow)
|
||||
{
|
||||
List<WindowsForm*> childPopups;
|
||||
childPopups.Add(this);
|
||||
for (vint i = 0; i < childPopups.Count(); i++)
|
||||
rootWindow = activatedWindow;
|
||||
exceptions.Add(rootWindow);
|
||||
while (auto parentWindow = rootWindow->parentWindow)
|
||||
{
|
||||
auto popup = childPopups[i];
|
||||
for (vint j = 0; j < popup->childWindows.Count(); j++)
|
||||
{
|
||||
auto childPopup = popup->childWindows[j];
|
||||
if (childPopup->windowMode != Normal)
|
||||
{
|
||||
childPopups.Add(childPopup);
|
||||
}
|
||||
}
|
||||
rootWindow = parentWindow;
|
||||
exceptions.Add(parentWindow);
|
||||
}
|
||||
}
|
||||
|
||||
if (popup != this && popup->IsVisible())
|
||||
if (closePopups)
|
||||
{
|
||||
List<IWindowsForm*> allRootWindows;
|
||||
GetAllCreatedWindows(allRootWindows, true);
|
||||
|
||||
for (vint i = 0; i < allRootWindows.Count(); i++)
|
||||
{
|
||||
if (auto windowsForm = dynamic_cast<WindowsForm*>(allRootWindows[i]))
|
||||
{
|
||||
popup->Hide(false);
|
||||
ClosePopupsOf(windowsForm, exceptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8364,7 +8456,7 @@ WindowsForm
|
||||
NativeRect bounds(rawBounds->left, rawBounds->top, rawBounds->right, rawBounds->bottom);
|
||||
for(vint i=0;i<listeners.Count();i++)
|
||||
{
|
||||
listeners[i]->Moving(bounds, false);
|
||||
listeners[i]->Moving(bounds, false, (uMsg == WM_SIZING));
|
||||
}
|
||||
if( rawBounds->left!=bounds.Left().value
|
||||
|| rawBounds->top!=bounds.Top().value
|
||||
@@ -9093,7 +9185,7 @@ WindowsForm
|
||||
NativeRect newBounds=bounds;
|
||||
for(vint i=0;i<listeners.Count();i++)
|
||||
{
|
||||
listeners[i]->Moving(newBounds, true);
|
||||
listeners[i]->Moving(newBounds, true, false);
|
||||
}
|
||||
MoveWindow(handle, (int)newBounds.Left().value, (int)newBounds.Top().value, (int)newBounds.Width().value, (int)newBounds.Height().value, FALSE);
|
||||
}
|
||||
@@ -9730,6 +9822,24 @@ WindowsController
|
||||
return windows.Values()[index];
|
||||
}
|
||||
|
||||
void GetAllCreatedWindows(collections::List<IWindowsForm*>& createdWindows, bool rootWindowOnly)
|
||||
{
|
||||
if (rootWindowOnly)
|
||||
{
|
||||
FOREACH(WindowsForm*, window, windows.Values())
|
||||
{
|
||||
if (window->GetWindowMode() == INativeWindow::Normal)
|
||||
{
|
||||
createdWindows.Add(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyFrom(createdWindows, windows.Values());
|
||||
}
|
||||
}
|
||||
|
||||
bool HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result)
|
||||
{
|
||||
bool skipDefaultProcedure=false;
|
||||
@@ -9970,7 +10080,7 @@ Windows Platform Native Controller
|
||||
{
|
||||
return controller->GetWindowsFormFromHandle(hwnd);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IWindowsForm* GetWindowsForm(INativeWindow* window)
|
||||
@@ -9978,6 +10088,15 @@ Windows Platform Native Controller
|
||||
return dynamic_cast<WindowsForm*>(window);
|
||||
}
|
||||
|
||||
void GetAllCreatedWindows(collections::List<IWindowsForm*>& windows, bool rootWindowOnly)
|
||||
{
|
||||
auto controller = dynamic_cast<WindowsController*>(GetCurrentController());
|
||||
if (controller)
|
||||
{
|
||||
controller->GetAllCreatedWindows(windows, rootWindowOnly);
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyWindowsNativeController(INativeController* controller)
|
||||
{
|
||||
delete controller;
|
||||
|
||||
@@ -2145,6 +2145,7 @@ Windows Platform Native Controller
|
||||
extern INativeController* CreateWindowsNativeController(HINSTANCE hInstance);
|
||||
extern IWindowsForm* GetWindowsFormFromHandle(HWND hwnd);
|
||||
extern IWindowsForm* GetWindowsForm(INativeWindow* window);
|
||||
extern void GetAllCreatedWindows(collections::List<IWindowsForm*>& windows, bool rootWindowOnly);
|
||||
extern void DestroyWindowsNativeController(INativeController* controller);
|
||||
extern void EnableCrossKernelCrashing();
|
||||
}
|
||||
|
||||
@@ -622,6 +622,14 @@ Custom Type
|
||||
, TBase(typeDescriptorFlags, this)
|
||||
{
|
||||
}
|
||||
|
||||
const WString& GetTypeName() override
|
||||
{
|
||||
// TypeDescriptorImplBase::GetTypeName returns WString(this->typeName, false)
|
||||
// which is this->workflowTypeName.Obj()
|
||||
// will become a dangling pointer after this type is unloaded
|
||||
return workflowTypeName;
|
||||
}
|
||||
};
|
||||
|
||||
class WfCustomType : public WfCustomTypeBase<reflection::description::TypeDescriptorImpl>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,8 +27,8 @@
|
||||
</demo:DocumentEditorRibbon>
|
||||
<ev.WindowClosing-eval>
|
||||
<![CDATA[
|
||||
arguments.cancel = editor.CancelWindowClose();
|
||||
]]>
|
||||
arguments.cancel = editor.CancelWindowClose();
|
||||
]]>
|
||||
</ev.WindowClosing-eval>
|
||||
</Window>
|
||||
</Instance>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
</demo:DocumentEditorToolstrip>
|
||||
<ev.WindowClosing-eval>
|
||||
<![CDATA[
|
||||
arguments.cancel = editor.CancelWindowClose();
|
||||
]]>
|
||||
arguments.cancel = editor.CancelWindowClose();
|
||||
]]>
|
||||
</ev.WindowClosing-eval>
|
||||
</Window>
|
||||
</Instance>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user