This commit is contained in:
vczh
2015-10-31 22:15:56 -07:00
parent 6f7b183d0a
commit 5ced7086ca
11 changed files with 1553 additions and 254 deletions
+384 -29
View File
File diff suppressed because it is too large Load Diff
+209 -12
View File
@@ -942,11 +942,15 @@ Layout Engine
struct InlineObjectProperties
{
/// <summary>The size of the inline object.</summary>
Size size;
Size size;
/// <summary>The baseline of the inline object.If the baseline is at the bottom, then set the baseline to -1.</summary>
vint baseline;
vint baseline = -1;
/// <summary>The break condition of the inline object.</summary>
BreakCondition breakCondition;
BreakCondition breakCondition;
/// <summary>The background image, nullable.</summary>
Ptr<IGuiGraphicsElement> backgroundImage;
/// <summary>The id for callback. If the value is -1, then no callback will be received .</summary>
vint callbackId = -1;
InlineObjectProperties()
:baseline(-1)
@@ -1015,7 +1019,7 @@ Layout Engine
/// <param name="properties">The properties for the inline object.</param>
/// <param name="value">The element.</param>
/// <returns>Returns true if this operation succeeded.</returns>
virtual bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties, Ptr<IGuiGraphicsElement> value)=0;
virtual bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties)=0;
/// <summary>Unbind all inline objects to a range of text.</summary>
/// <param name="start">The position of the first character of the specified range.</param>
/// <param name="length">The length of the specified range by character.</param>
@@ -1058,7 +1062,7 @@ Layout Engine
/// <param name="point">The point.</param>
/// <param name="start">Get the start position of this element.</param>
/// <param name="length">Get the length of this element.</param>
virtual Ptr<IGuiGraphicsElement> GetInlineObjectFromPoint(Point point, vint& start, vint& length)=0;
virtual Nullable<InlineObjectProperties> GetInlineObjectFromPoint(Point point, vint& start, vint& length)=0;
/// <summary>Get the nearest caret from a text position.</summary>
/// <returns>The caret. Returns -1 if failed. If the text position is a caret, then the result will be the text position itself without considering the frontSide argument.</returns>
/// <param name="textPos">The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.</param>
@@ -1074,6 +1078,17 @@ Layout Engine
virtual bool IsValidTextPos(vint textPos)=0;
};
/// <summary>Paragraph callback</summary>
class IGuiGraphicsParagraphCallback : public IDescriptable, public Description<IGuiGraphicsParagraphCallback>
{
public:
/// <summary>Called when an inline object with a valid callback id is being rendered.</summary>
/// <returns>Returns the new size of the rendered inline object.</returns>
/// <param name="callbackId">The callback id of the inline object</param>
/// <param name="location">The location of the inline object, relative to the left-top corner of this paragraph.</param>
virtual Size OnRenderInlineObject(vint callbackId, Rect location) = 0;
};
/// <summary>Renderer awared rich text document layout engine provider interface.</summary>
class IGuiGraphicsLayoutProvider : public IDescriptable, public Description<IGuiGraphicsLayoutProvider>
{
@@ -1082,7 +1097,7 @@ Layout Engine
/// <param name="text">The text used to fill the paragraph.</param>
/// <param name="renderTarget">The render target that the created paragraph will render to.</param>
/// <returns>The created paragraph object.</returns>
virtual Ptr<IGuiGraphicsParagraph> CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget)=0;
virtual Ptr<IGuiGraphicsParagraph> CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget, IGuiGraphicsParagraphCallback* callback)=0;
};
}
}
@@ -3801,6 +3816,7 @@ namespace vl
class DocumentStyleApplicationRun;
class DocumentHyperlinkRun;
class DocumentImageRun;
class DocumentEmbeddedObjectRun;
class DocumentParagraphRun;
/***********************************************************************
@@ -3860,6 +3876,9 @@ Rich Content Document (run)
/// <summary>Visit operation for <see cref="DocumentImageRun"/>.</summary>
/// <param name="run">The run object.</param>
virtual void Visit(DocumentImageRun* run)=0;
/// <summary>Visit operation for <see cref="DocumentEmbeddedObjectRun"/>.</summary>
/// <param name="run">The run object.</param>
virtual void Visit(DocumentEmbeddedObjectRun* run)=0;
/// <summary>Visit operation for <see cref="DocumentParagraphRun"/>.</summary>
/// <param name="run">The run object.</param>
virtual void Visit(DocumentParagraphRun* run)=0;
@@ -3936,6 +3955,19 @@ Rich Content Document (run)
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// <summary>Pepresents an embedded object run.</summary>
class DocumentEmbeddedObjectRun : public DocumentInlineObjectRun, public Description<DocumentImageRun>
{
public:
static const wchar_t* RepresentationText;
/// <summary>The object name.</summary>
WString name;
WString GetRepresentationText()override{return RepresentationText;}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
//-------------------------------------------------------------------------
/// <summary>Pepresents a style properties run.</summary>
@@ -5362,6 +5394,11 @@ namespace vl
namespace elements
{
namespace visitors
{
class SetPropertiesVisitor;
}
/***********************************************************************
Rich Content Document (element)
***********************************************************************/
@@ -5371,14 +5408,46 @@ Rich Content Document (element)
{
DEFINE_GUI_GRAPHICS_ELEMENT(GuiDocumentElement, L"RichDocument");
public:
class GuiDocumentElementRenderer : public Object, public IGuiGraphicsRenderer
/// <summary>Callback interface for this element.</summary>
class ICallback : public virtual IDescriptable, public Description<ICallback>
{
public:
/// <summary>Called when the rendering is started.</summary>
virtual void OnStartRender() = 0;
/// <summary>Called when the rendering is finished.</summary>
virtual void OnFinishRender() = 0;
/// <summary>Called when an embedded object is being rendered.</summary>
/// <returns>Returns the new size of the rendered embedded object.</returns>
/// <param name="name">The name of the embedded object</param>
/// <param name="location">The location of the embedded object, relative to the left-top corner of this element.</param>
virtual Size OnRenderEmbeddedObject(const WString& name, const Rect& location) = 0;
};
class GuiDocumentElementRenderer : public Object, public IGuiGraphicsRenderer, private IGuiGraphicsParagraphCallback
{
friend class visitors::SetPropertiesVisitor;
DEFINE_GUI_GRAPHICS_RENDERER(GuiDocumentElement, GuiDocumentElementRenderer, IGuiGraphicsRenderTarget)
protected:
struct EmbeddedObject
{
WString name;
Size size;
vint start;
bool resized = false;
};
typedef collections::Dictionary<vint, Ptr<EmbeddedObject>> IdEmbeddedObjectMap;
typedef collections::Dictionary<WString, vint> NameIdMap;
typedef collections::List<vint> FreeIdList;
struct ParagraphCache
{
WString fullText;
Ptr<IGuiGraphicsParagraph> graphicsParagraph;
IdEmbeddedObjectMap embeddedObjects;
vint selectionBegin;
vint selectionEnd;
@@ -5391,6 +5460,10 @@ Rich Content Document (element)
typedef collections::Array<Ptr<ParagraphCache>> ParagraphCacheArray;
typedef collections::Array<vint> ParagraphHeightArray;
private:
Size OnRenderInlineObject(vint callbackId, Rect location)override;
protected:
vint paragraphDistance;
vint lastMaxWidth;
@@ -5403,6 +5476,13 @@ Rich Content Document (element)
Color lastCaretColor;
bool lastCaretFrontSide;
NameIdMap nameCallbackIdMap;
FreeIdList freeCallbackIds;
vint usedCallbackIds = 0;
vint renderingParagraph = -1;
Point renderingParagraphOffset;
void InitializeInternal();
void FinalizeInternal();
void RenderTargetChangedInternal(IGuiGraphicsRenderTarget* oldRenderTarget, IGuiGraphicsRenderTarget* newRenderTarget);
@@ -5426,6 +5506,7 @@ Rich Content Document (element)
protected:
Ptr<DocumentModel> document;
ICallback* callback = nullptr;
TextPos caretBegin;
TextPos caretEnd;
bool caretVisible;
@@ -5438,6 +5519,13 @@ Rich Content Document (element)
public:
~GuiDocumentElement();
/// <summary>Get the callback.</summary>
/// <returns>The callback.</returns>
ICallback* GetCallback();
/// <summary>Set the callback.</summary>
/// <param name="value">The callback.</param>
void SetCallback(ICallback* value);
/// <summary>Get the document.</summary>
/// <returns>The document.</returns>
Ptr<DocumentModel> GetDocument();
@@ -6808,10 +6896,10 @@ Stack Compositions
/// <param name="value">The expected bounds of a stack item.</param>
void SetBounds(Rect value);
/// <summary>Get the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for decide the stack item layout.</summary>
/// <summary>Get the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout.</summary>
/// <returns>The extra margin for this stack item.</returns>
Margin GetExtraMargin();
/// <summary>Set the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for decide the stack item layout.</summary>
/// <summary>Set the extra margin for this stack item. An extra margin is used to enlarge the bounds of the stack item, but only the non-extra part will be used for deciding the stack item layout.</summary>
/// <param name="value">The extra margin for this stack item.</param>
void SetExtraMargin(Margin value);
};
@@ -6955,7 +7043,7 @@ Axis Implementation
/// <summary>Get the specified axis direction.</summary>
/// <returns>The specified axis direction.</returns>
AxisDirection GetAlignment();
AxisDirection GetDirection();
Size RealSizeToVirtualSize(Size size)override;
Size VirtualSizeToRealSize(Size size)override;
Point RealPointToVirtualPoint(Size realFullSize, Point point)override;
@@ -6993,18 +7081,29 @@ namespace vl
{
namespace compositions
{
class GuiFlowComposition;
class GuiFlowItemComposition;
/***********************************************************************
Flow Compositions
***********************************************************************/
/// <summary>
/// Alignment for a row in a flow layout
/// </summary>
enum class FlowAlignment
{
/// <summary>Align to the left.</summary>
Left,
/// <summary>Align to the center.</summary>
Center,
/// <summary>Extend to the entire row.</summary>
Extend,
};
/// <summary>
/// Represents a flow composition.
/// </summary>
class GuiFlowComposition : public GuiBoundsComposition, public Description<GuiFlowComposition>
{
friend class GuiFlowItemComposition;
@@ -7031,37 +7130,76 @@ Flow Compositions
GuiFlowComposition();
~GuiFlowComposition();
/// <summary>Get all flow items inside the flow composition.</summary>
/// <returns>All flow items inside the flow composition.</returns>
const ItemCompositionList& GetFlowItems();
/// <summary>Get the extra margin inside the flow composition.</summary>
/// <returns>The extra margin inside the flow composition.</returns>
Margin GetExtraMargin();
/// <summary>Set the extra margin inside the flow composition.</summary>
/// <param name="value">The extra margin inside the flow composition.</param>
void SetExtraMargin(Margin value);
/// <summary>Get the distance between rows.</summary>
/// <returns>The distance between rows.</returns>
vint GetRowPadding();
/// <summary>Set the distance between rows.</summary>
/// <param name="value">The distance between rows.</param>
void SetRowPadding(vint value);
/// <summary>Get the distance between columns.</summary>
/// <returns>The distance between columns.</returns>
vint GetColumnPadding();
/// <summary>Set the distance between columns.</summary>
/// <param name="value">The distance between columns.</param>
void SetColumnPadding(vint value);
/// <summary>Get the axis of the layout.</summary>
/// <returns>The axis.</returns>
Ptr<IGuiAxis> GetAxis();
/// <summary>Set the axis of the layout.</summary>
/// <param name="value">The axis.</param>
void SetAxis(Ptr<IGuiAxis> value);
/// <summary>Get the alignment for rows.</summary>
/// <returns>The alignment.</returns>
FlowAlignment GetAlignment();
/// <summary>Set the alignment for rows.</summary>
/// <param name="value">The alignment.</param>
void SetAlignment(FlowAlignment value);
Size GetMinPreferredClientSize()override;
Rect GetBounds()override;
};
/// <summary>
/// Represnets a base line configuration for a flow item.
/// </summary>
struct GuiFlowOption
{
/// <summary>Base line calculation algorithm</summary>
enum BaselineType
{
/// <summary>By percentage of the height from the top.</summary>
Percentage,
/// <summary>By a distance from the top.</summary>
FromTop,
/// <summary>By a distance from the bottom.</summary>
FromBottom,
};
/// <summary>The base line calculation algorithm.</summary>
BaselineType baseline = FromBottom;
/// <summary>The percentage value.</summary>
double percentage = 0.0;
/// <summary>The distance value.</summary>
vint distance = 0;
};
/// <summary>
/// Represents a flow item composition of a <see cref="GuiFlowComposition"/>.
/// </summary>
class GuiFlowItemComposition : public GuiGraphicsSite, public Description<GuiFlowItemComposition>
{
friend class GuiFlowComposition;
@@ -7081,10 +7219,18 @@ Flow Compositions
Rect GetBounds()override;
void SetBounds(Rect value);
/// <summary>Get the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout.</summary>
/// <returns>The extra margin for this flow item.</returns>
Margin GetExtraMargin();
/// <summary>Set the extra margin for this flow item. An extra margin is used to enlarge the bounds of the flow item, but only the non-extra part will be used for deciding the flow item layout.</summary>
/// <param name="value">The extra margin for this flow item.</param>
void SetExtraMargin(Margin value);
/// <summary>Get the base line option for this flow item.</summary>
/// <returns>The base line option.</returns>
GuiFlowOption GetFlowOption();
/// <summary>Set the base line option for this flow item.</summary>
/// <param name="value">The base line option.</param>
void SetFlowOption(GuiFlowOption value);
};
}
@@ -14232,9 +14378,36 @@ namespace vl
GuiDocumentCommonInterface
***********************************************************************/
/// <summary>Document displayer control common interface for displaying <see cref="DocumentModel"/>.</summary>
class GuiDocumentCommonInterface abstract : public Description<GuiDocumentCommonInterface>
class GuiDocumentCommonInterface;
/// <summary>Embedded object in a document.</summary>
class GuiDocumentItem : public Object, public Description<GuiDocumentItem>
{
friend class GuiDocumentCommonInterface;
protected:
bool visible = false;
WString name;
compositions::GuiBoundsComposition* container;
bool owned = false;
public:
GuiDocumentItem(const WString& _name);
~GuiDocumentItem();
/// <summary>Get the container for all embedded controls and compositions in this item.</summary>
/// <returns>The container.</returns>
compositions::GuiGraphicsComposition* GetContainer();
/// <summary>Get the name of the document item.</summary>
/// <returns>The name.</returns>
WString GetName();
};
/// <summary>Document displayer control common interface for displaying <see cref="DocumentModel"/>.</summary>
class GuiDocumentCommonInterface abstract
: protected virtual elements::GuiDocumentElement::ICallback
, public Description<GuiDocumentCommonInterface>
{
typedef collections::Dictionary<WString, Ptr<GuiDocumentItem>> DocumentItemMap;
public:
/// <summary>Represents the edit mode.</summary>
enum EditMode
@@ -14248,6 +14421,7 @@ GuiDocumentCommonInterface
};
protected:
Ptr<DocumentModel> baselineDocument;
DocumentItemMap documentItems;
GuiControl* documentControl;
elements::GuiDocumentElement* documentElement;
compositions::GuiBoundsComposition* documentComposition;
@@ -14259,6 +14433,7 @@ GuiDocumentCommonInterface
Ptr<GuiDocumentUndoRedoProcessor> undoRedoProcessor;
Ptr<compositions::GuiShortcutKeyManager> internalShortcutKeyManager;
protected:
void UpdateCaretPoint();
void Move(TextPos caret, bool shift, bool frontSide);
bool ProcessKey(vint code, bool shift, bool ctrl);
@@ -14281,6 +14456,12 @@ GuiDocumentCommonInterface
virtual Point GetDocumentViewPosition();
virtual void EnsureRectVisible(Rect bounds);
//================ callback
void OnStartRender()override;
void OnFinishRender()override;
Size OnRenderEmbeddedObject(const WString& name, const Rect& location)override;
public:
GuiDocumentCommonInterface(Ptr<DocumentModel> _baselineDocument);
~GuiDocumentCommonInterface();
@@ -14300,6 +14481,22 @@ GuiDocumentCommonInterface
/// <param name="value">The document.</param>
void SetDocument(Ptr<DocumentModel> value);
//================ document items
/// <summary>Add a document item. The name of the document item will display in the position of the &lt;object&gt; element with the same name in the document.</summary>
/// <param name="value">The document item.</param>
/// <returns>Returns true if this operation succeeded.</returns>
bool AddDocumentItem(Ptr<GuiDocumentItem> value);
/// <summary>Remove a document item.</summary>
/// <param name="value">The document item.</param>
/// <returns>Returns true if this operation succeeded.</returns>
bool RemoveDocumentItem(Ptr<GuiDocumentItem> value);
/// <summary>Get all document items.</summary>
/// <returns>All document items.</returns>
const DocumentItemMap& GetDocumentItems();
//================ caret operations
/// <summary>
+278 -3
View File
@@ -5147,6 +5147,261 @@ GuiBindableDataGridInstanceLoader
}
};
/***********************************************************************
GuiDocumentItemInstanceLoader
***********************************************************************/
class GuiDocumentItemInstanceLoader : public Object, public IGuiInstanceLoader
{
protected:
GlobalStringKey typeName;
GlobalStringKey _Name;
public:
GuiDocumentItemInstanceLoader()
{
typeName = GlobalStringKey::Get(description::GetTypeDescriptor<GuiDocumentItem>()->GetTypeName());
_Name = GlobalStringKey::Get(L"Name");
}
GlobalStringKey GetTypeName()override
{
return typeName;
}
bool IsCreatable(const TypeInfo& typeInfo)override
{
return typeName == typeInfo.typeName;
}
description::Value CreateInstance(Ptr<GuiInstanceEnvironment> env, const TypeInfo& typeInfo, collections::Group<GlobalStringKey, description::Value>& constructorArguments)override
{
if (typeInfo.typeName == GetTypeName())
{
vint indexName = constructorArguments.Keys().IndexOf(_Name);
if (indexName == -1)
{
return Value();
}
auto name = UnboxValue<WString>(constructorArguments.GetByIndex(indexName)[0]);
auto item = MakePtr<GuiDocumentItem>(name);
return Value::From(item);
}
return Value();
}
void GetConstructorParameters(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
{
if (typeInfo.typeName == GetTypeName())
{
propertyNames.Add(_Name);
}
}
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
{
propertyNames.Add(GlobalStringKey::Empty);
}
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
{
if (propertyInfo.propertyName == GlobalStringKey::Empty)
{
auto info = GuiInstancePropertyInfo::Collection();
info->acceptableTypes.Add(description::GetTypeDescriptor<GuiControl>());
info->acceptableTypes.Add(description::GetTypeDescriptor<GuiGraphicsComposition>());
return info;
}
else if (propertyInfo.propertyName == _Name)
{
auto info = GuiInstancePropertyInfo::Assign(description::GetTypeDescriptor<WString>());
info->scope = GuiInstancePropertyInfo::Constructor;
return info;
}
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
}
bool SetPropertyValue(PropertyValue& propertyValue)override
{
if (auto container = dynamic_cast<GuiDocumentItem*>(propertyValue.instanceValue.GetRawPtr()))
{
if (propertyValue.propertyName == GlobalStringKey::Empty)
{
if (auto control = dynamic_cast<GuiControl*>(propertyValue.propertyValue.GetRawPtr()))
{
container->GetContainer()->AddChild(control->GetBoundsComposition());
return true;
}
else if (auto composition = dynamic_cast<GuiGraphicsComposition*>(propertyValue.propertyValue.GetRawPtr()))
{
container->GetContainer()->AddChild(composition);
return true;
}
}
}
return false;
}
};
/***********************************************************************
GuiDocumentCommonInterfaceInstanceLoader
***********************************************************************/
class GuiDocumentCommonInterfaceInstanceLoader : public Object, public IGuiInstanceLoader
{
public:
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
{
propertyNames.Add(GlobalStringKey::Empty);
}
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
{
if (propertyInfo.propertyName == GlobalStringKey::Empty)
{
return GuiInstancePropertyInfo::CollectionWithParent(description::GetTypeDescriptor<GuiDocumentItem>());
}
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
}
bool SetPropertyValue(PropertyValue& propertyValue)override
{
if (auto container = dynamic_cast<GuiDocumentCommonInterface*>(propertyValue.instanceValue.GetRawPtr()))
{
if (propertyValue.propertyName == GlobalStringKey::Empty)
{
if (auto item = propertyValue.propertyValue.GetSharedPtr().Cast<GuiDocumentItem>())
{
container->AddDocumentItem(item);
return true;
}
}
}
return false;
}
};
/***********************************************************************
GuiDocumentViewerInstanceLoader
***********************************************************************/
class GuiDocumentViewerInstanceLoader : public GuiDocumentCommonInterfaceInstanceLoader
{
protected:
GlobalStringKey typeName;
public:
GuiDocumentViewerInstanceLoader()
{
typeName = GlobalStringKey::Get(description::GetTypeDescriptor<GuiDocumentViewer>()->GetTypeName());
}
GlobalStringKey GetTypeName()override
{
return typeName;
}
bool IsCreatable(const TypeInfo& typeInfo)override
{
return GetTypeName() == typeInfo.typeName;
}
description::Value CreateInstance(Ptr<GuiInstanceEnvironment> env, const TypeInfo& typeInfo, collections::Group<GlobalStringKey, description::Value>& constructorArguments)override
{
if(GetTypeName() == typeInfo.typeName)
{
vint indexControlTemplate = constructorArguments.Keys().IndexOf(GlobalStringKey::_ControlTemplate);
if (indexControlTemplate == -1)
{
return Value::From(g::NewDocumentViewer());
}
else
{
auto factory = CreateTemplateFactory(constructorArguments.GetByIndex(indexControlTemplate)[0].GetText());
return Value::From(new GuiDocumentViewer(new GuiDocumentViewerTemplate_StyleProvider(factory)));
}
}
return Value();
}
void GetConstructorParameters(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
{
propertyNames.Add(GlobalStringKey::_ControlTemplate);
}
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
{
if (propertyInfo.propertyName == GlobalStringKey::_ControlTemplate)
{
auto info = GuiInstancePropertyInfo::Assign(description::GetTypeDescriptor<WString>());
info->scope = GuiInstancePropertyInfo::Constructor;
return info;
}
return GuiDocumentCommonInterfaceInstanceLoader::GetPropertyType(propertyInfo);
}
};
/***********************************************************************
GuiDocumentLabelInstanceLoader
***********************************************************************/
class GuiDocumentLabelInstanceLoader : public GuiDocumentCommonInterfaceInstanceLoader
{
protected:
GlobalStringKey typeName;
public:
GuiDocumentLabelInstanceLoader()
{
typeName = GlobalStringKey::Get(description::GetTypeDescriptor<GuiDocumentLabel>()->GetTypeName());
}
GlobalStringKey GetTypeName()override
{
return typeName;
}
bool IsCreatable(const TypeInfo& typeInfo)override
{
return GetTypeName() == typeInfo.typeName;
}
description::Value CreateInstance(Ptr<GuiInstanceEnvironment> env, const TypeInfo& typeInfo, collections::Group<GlobalStringKey, description::Value>& constructorArguments)override
{
if(GetTypeName() == typeInfo.typeName)
{
vint indexControlTemplate = constructorArguments.Keys().IndexOf(GlobalStringKey::_ControlTemplate);
if (indexControlTemplate == -1)
{
return Value::From(g::NewDocumentLabel());
}
else
{
auto factory = CreateTemplateFactory(constructorArguments.GetByIndex(indexControlTemplate)[0].GetText());
return Value::From(new GuiDocumentLabel(new GuiDocumentLabelTemplate_StyleProvider(factory)));
}
}
return Value();
}
void GetConstructorParameters(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
{
propertyNames.Add(GlobalStringKey::_ControlTemplate);
}
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
{
if (propertyInfo.propertyName == GlobalStringKey::_ControlTemplate)
{
auto info = GuiInstancePropertyInfo::Assign(description::GetTypeDescriptor<WString>());
info->scope = GuiInstancePropertyInfo::Constructor;
return info;
}
return GuiDocumentCommonInterfaceInstanceLoader::GetPropertyType(propertyInfo);
}
};
/***********************************************************************
GuiAxisInstanceLoader
***********************************************************************/
@@ -5615,6 +5870,10 @@ GuiPredefinedInstanceLoadersPlugin
manager->SetLoader(new GuiBindableDataColumnInstanceLoader); // VisualizerTemplates, EditorTemplate
manager->SetLoader(new GuiBindableDataGridInstanceLoader); // ControlTemplate, ItemSource
manager->SetLoader(new GuiDocumentItemInstanceLoader);
manager->SetLoader(new GuiDocumentViewerInstanceLoader); // ControlTemplate
manager->SetLoader(new GuiDocumentLabelInstanceLoader); // ControlTemplate
manager->SetLoader(new GuiAxisInstanceLoader);
manager->SetLoader(new GuiCompositionInstanceLoader);
manager->SetLoader(new GuiTableCompositionInstanceLoader);
@@ -5629,8 +5888,6 @@ GuiPredefinedInstanceLoadersPlugin
ADD_TEMPLATE_CONTROL ( GuiScrollContainer, g::NewScrollContainer, GuiScrollViewTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiWindow, g::NewWindow, GuiWindowTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL_2 ( GuiTextList, g::NewTextList, GuiTextListTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiDocumentViewer, g::NewDocumentViewer, GuiDocumentViewerTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiDocumentLabel, g::NewDocumentLabel, GuiDocumentLabelTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiMultilineTextBox, g::NewMultilineTextBox, GuiMultilineTextBoxTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiSinglelineTextBox, g::NewTextBox, GuiSinglelineTextBoxTemplate); // ControlTemplate
ADD_TEMPLATE_CONTROL ( GuiDatePicker, g::NewDatePicker, GuiDatePickerTemplate); // ControlTemplate
@@ -9800,6 +10057,13 @@ Type Declaration
CLASS_MEMBER_FIELD(source)
END_CLASS_MEMBER(DocumentImageRun)
BEGIN_CLASS_MEMBER(DocumentEmbeddedObjectRun)
CLASS_MEMBER_BASE(DocumentInlineObjectRun)
CLASS_MEMBER_CONSTRUCTOR(Ptr<DocumentEmbeddedObjectRun>(), NO_PARAMETER)
CLASS_MEMBER_FIELD(name)
END_CLASS_MEMBER(DocumentEmbeddedObjectRun)
BEGIN_CLASS_MEMBER(DocumentStylePropertiesRun)
CLASS_MEMBER_BASE(DocumentContainerRun)
CLASS_MEMBER_CONSTRUCTOR(Ptr<DocumentStylePropertiesRun>(), NO_PARAMETER)
@@ -10365,7 +10629,7 @@ Type Declaration
CLASS_MEMBER_BASE(IGuiAxis)
CLASS_MEMBER_CONSTRUCTOR(Ptr<GuiAxis>(AxisDirection), {L"axisDirection"})
CLASS_MEMBER_PROPERTY_READONLY_FAST(Alignment)
CLASS_MEMBER_PROPERTY_READONLY_FAST(Direction)
END_CLASS_MEMBER(GuiAxis)
BEGIN_CLASS_MEMBER(GuiStackComposition)
@@ -11869,6 +12133,13 @@ Type Declaration
CLASS_MEMBER_METHOD(CreateToolstripSubMenu, {L"subMenuStyleController"})
END_CLASS_MEMBER(GuiToolstripButton)
BEGIN_CLASS_MEMBER(GuiDocumentItem)
CLASS_MEMBER_CONSTRUCTOR(Ptr<GuiDocumentItem>(const WString&), { L"name" })
CLASS_MEMBER_PROPERTY_READONLY_FAST(Container)
CLASS_MEMBER_PROPERTY_READONLY_FAST(Name)
END_CLASS_MEMBER(GuiDocumentItem)
BEGIN_CLASS_MEMBER(GuiDocumentCommonInterface)
CLASS_MEMBER_PROPERTY_FAST(Document)
CLASS_MEMBER_PROPERTY_FAST(EditMode)
@@ -11877,6 +12148,10 @@ Type Declaration
CLASS_MEMBER_GUIEVENT(ActiveHyperlinkExecuted)
CLASS_MEMBER_GUIEVENT(SelectionChanged)
CLASS_MEMBER_METHOD(AddDocumentItem, { L"value" })
CLASS_MEMBER_METHOD(RemoveDocumentItem, { L"value" })
CLASS_MEMBER_PROPERTY_READONLY_FAST(DocumentItems)
CLASS_MEMBER_PROPERTY_READONLY_FAST(CaretBegin)
CLASS_MEMBER_PROPERTY_READONLY_FAST(CaretEnd)
CLASS_MEMBER_PROPERTY_READONLY_FAST(ActiveHyperlinkReference)
+2
View File
@@ -941,6 +941,7 @@ Type List
F(presentation::DocumentTextRun)\
F(presentation::DocumentInlineObjectRun)\
F(presentation::DocumentImageRun)\
F(presentation::DocumentEmbeddedObjectRun)\
F(presentation::DocumentStylePropertiesRun)\
F(presentation::DocumentStyleApplicationRun)\
F(presentation::DocumentHyperlinkRun)\
@@ -1506,6 +1507,7 @@ Type List
F(presentation::controls::GuiToolstripMenuBar)\
F(presentation::controls::GuiToolstripToolBar)\
F(presentation::controls::GuiToolstripButton)\
F(presentation::controls::GuiDocumentItem)\
F(presentation::controls::GuiDocumentCommonInterface)\
F(presentation::controls::GuiDocumentCommonInterface::EditMode)\
F(presentation::controls::GuiDocumentViewer)\
+596 -147
View File
File diff suppressed because it is too large Load Diff
+64 -51
View File
@@ -627,6 +627,41 @@ Windows Platform Native Controller
#endif
/***********************************************************************
NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Native Window::Direct2D Provider for Windows Implementation
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION
#define VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION
#include <d2d1_1.h>
#include <dwrite_1.h>
namespace vl
{
namespace presentation
{
namespace windows
{
extern ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern void RecreateNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern bool PresentNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern ID2D1Factory* GetDirect2DFactory();
extern IDWriteFactory* GetDirectWriteFactory();
}
}
}
extern int WinMainDirect2D(HINSTANCE hInstance, void(*RendererMain)());
#endif
/***********************************************************************
NATIVEWINDOW\WINDOWS\SERVICESIMPL\WINDOWSRESOURCESERVICE.H
***********************************************************************/
@@ -1000,40 +1035,6 @@ namespace vl
#endif
/***********************************************************************
NATIVEWINDOW\WINDOWS\DIRECT2D\WINDIRECT2DAPPLICATION.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Native Window::Direct2D Provider for Windows Implementation
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION
#define VCZH_PRESENTATION_WINDOWS_GDI_WINDIRECT2DAPPLICATION
#include <D2D1.h>
#include <DWrite.h>
namespace vl
{
namespace presentation
{
namespace windows
{
extern ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern void RecreateNativeWindowDirect2DRenderTarget(INativeWindow* window);
extern ID2D1Factory* GetDirect2DFactory();
extern IDWriteFactory* GetDirectWriteFactory();
}
}
}
extern int WinMainDirect2D(HINSTANCE hInstance, void(*RendererMain)());
#endif
/***********************************************************************
NATIVEWINDOW\WINDOWS\GDI\WINGDIAPPLICATION.H
***********************************************************************/
@@ -1208,7 +1209,7 @@ namespace vl
class WindowsGDILayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider
{
public:
Ptr<elements::IGuiGraphicsParagraph> CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget)override;
Ptr<elements::IGuiGraphicsParagraph> CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override;
};
}
}
@@ -1293,6 +1294,8 @@ UniscribeColor
namespace elements_windows_gdi
{
typedef Nullable<IGuiGraphicsParagraph::InlineObjectProperties> InlineObject;
/***********************************************************************
UniscribeFragment
***********************************************************************/
@@ -1307,8 +1310,7 @@ UniscribeFragment
const WString text;
Ptr<WinFont> fontObject;
//***************************** Document Data (Element)
Ptr<IGuiGraphicsElement> element;
IGuiGraphicsParagraph::InlineObjectProperties inlineObjectProperties;
InlineObject inlineObjectProperties;
List<Ptr<UniscribeFragment>> cachedTextFragment;
UniscribeFragment(const WString& _text);
@@ -1379,6 +1381,14 @@ UniscribeRun
Rect bounds;
};
class IRendererCallback : public Interface
{
public:
virtual WinDC* GetWinDC() = 0;
virtual Point GetParagraphOffset() = 0;
virtual IGuiGraphicsParagraphCallback* GetParagraphCallback() = 0;
};
//***************************** Document Data
UniscribeFragment* documentFragment;
UniscribeItem* scriptItem;
@@ -1396,8 +1406,9 @@ UniscribeRun
virtual bool BuildUniscribeData(WinDC* dc, List<vint>& breakings)=0;
virtual vint SumWidth(vint charStart, vint charLength)=0;
virtual vint SumHeight()=0;
virtual vint SumTextHeight()=0;
virtual void SearchForLineBreak(vint tempStart, vint maxWidth, bool firstRun, vint& charLength, vint& charAdvances)=0;
virtual void Render(WinDC* dc, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)=0;
virtual void Render(IRendererCallback* callback, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)=0;
};
/***********************************************************************
@@ -1423,29 +1434,30 @@ UniscribeTextRun
bool BuildUniscribeData(WinDC* dc, List<vint>& breakings)override;
vint SumWidth(vint charStart, vint charLength)override;
vint SumHeight()override;
vint SumTextHeight()override;
void SearchForLineBreak(vint tempStart, vint maxWidth, bool firstRun, vint& charLength, vint& charAdvances)override;
void Render(WinDC* dc, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)override;
void Render(IRendererCallback* callback, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)override;
};
/***********************************************************************
UniscribeElementRun
***********************************************************************/
class UniscribeElementRun : public UniscribeRun
class UniscribeEmbeddedObjectRun : public UniscribeRun
{
public:
//***************************** Document Data
Ptr<IGuiGraphicsElement> element;
IGuiGraphicsParagraph::InlineObjectProperties properties;
UniscribeElementRun();
~UniscribeElementRun();
UniscribeEmbeddedObjectRun();
~UniscribeEmbeddedObjectRun();
bool BuildUniscribeData(WinDC* dc, List<vint>& breakings)override;
vint SumWidth(vint charStart, vint charLength)override;
vint SumHeight()override;
vint SumTextHeight()override;
void SearchForLineBreak(vint tempStart, vint maxWidth, bool firstRun, vint& charLength, vint& charAdvances)override;
void Render(WinDC* dc, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)override;
void Render(IRendererCallback* callback, vint fragmentBoundsIndex, vint offsetX, vint offsetY, bool renderBackground)override;
};
/***********************************************************************
@@ -1492,7 +1504,7 @@ UniscribeLine
void ClearUniscribeData();
bool BuildUniscribeData(WinDC* dc);
void Layout(vint availableWidth, Alignment alignment, vint top, vint& totalHeight);
void Render(WinDC* dc, vint offsetX, vint offsetY, bool renderBackground);
void Render(UniscribeRun::IRendererCallback* callback, vint offsetX, vint offsetY, bool renderBackground);
};
/***********************************************************************
@@ -1519,7 +1531,7 @@ UniscribeParagraph
void ClearUniscribeData();
bool BuildUniscribeData(WinDC* dc);
void Layout(vint availableWidth, Alignment alignment);
void Render(WinDC* dc, vint offsetX, vint offsetY, bool renderBackground);
void Render(UniscribeRun::IRendererCallback* callback, bool renderBackground);
void SearchFragment(vint start, vint length, vint& fs, vint& ss, vint& fe, vint& se);
bool CutFragment(vint fs, vint ss, vint fe, vint se, vint& f1, vint& f2);
@@ -1530,8 +1542,8 @@ UniscribeParagraph
bool SetStyle(vint start, vint length, bool bold, bool italic, bool underline, bool strikeline);
bool SetColor(vint start, vint length, Color value);
bool SetBackgroundColor(vint start, vint length, Color value);
bool SetInlineObject(vint start, vint length, const IGuiGraphicsParagraph::InlineObjectProperties& properties, Ptr<IGuiGraphicsElement> value);
Ptr<IGuiGraphicsElement> ResetInlineObject(vint start, vint length);
bool SetInlineObject(vint start, vint length, const IGuiGraphicsParagraph::InlineObjectProperties& properties);
InlineObject ResetInlineObject(vint start, vint length);
void GetLineIndexFromTextPos(vint textPos, vint& frontLine, vint& backLine);
void GetVirtualLineIndexFromTextPos(vint textPos, vint lineIndex, vint& frontLine, vint& backLine);
@@ -1539,7 +1551,7 @@ UniscribeParagraph
Rect GetCaretBoundsWithLine(vint caret, vint lineIndex, vint virtualLineIndex, bool frontSide);
vint GetCaretFromXWithTextRunBounds(vint x, vint lineIndex, vint runIndex, vint runBoundsIndex);
vint GetCaretFromXWithLine(vint x, vint lineIndex, vint virtualLineIndex);
Ptr<IGuiGraphicsElement> GetInlineObjectFromXWithLine(vint x, vint lineIndex, vint virtualLineIndex, vint& start, vint& length);
InlineObject GetInlineObjectFromXWithLine(vint x, vint lineIndex, vint virtualLineIndex, vint& start, vint& length);
vint GetLineY(vint lineIndex);
vint GetVirtualLineY(vint lineIndex, vint virtualLineIndex);
vint GetLineIndexFromY(vint y);
@@ -1548,7 +1560,7 @@ UniscribeParagraph
vint GetCaret(vint comparingCaret, IGuiGraphicsParagraph::CaretRelativePosition position, bool& preferFrontSide);
Rect GetCaretBounds(vint caret, bool frontSide);
vint GetCaretFromPoint(Point point);
Ptr<IGuiGraphicsElement> GetInlineObjectFromPoint(Point point, vint& start, vint& length);
InlineObject GetInlineObjectFromPoint(Point point, vint& start, vint& length);
vint GetNearestCaretFromTextPos(vint textPos, bool frontSide);
bool IsValidCaret(vint caret);
bool IsValidTextPos(vint textPos);
@@ -1926,6 +1938,7 @@ OS Supporting
{
public:
virtual void RecreateRenderTarget(INativeWindow* window)=0;
virtual bool PresentRenderTarget(INativeWindow* window)=0;
virtual ID2D1RenderTarget* GetNativeWindowDirect2DRenderTarget(INativeWindow* window)=0;
virtual ID2D1Factory* GetDirect2DFactory()=0;
virtual IDWriteFactory* GetDirectWriteFactory()=0;
@@ -1969,7 +1982,7 @@ namespace vl
class WindowsDirect2DLayoutProvider : public Object, public elements::IGuiGraphicsLayoutProvider
{
public:
Ptr<elements::IGuiGraphicsParagraph> CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget)override;
Ptr<elements::IGuiGraphicsParagraph> CreateParagraph(const WString& text, elements::IGuiGraphicsRenderTarget* renderTarget, elements::IGuiGraphicsParagraphCallback* callback)override;
};
}
}
+14 -6
View File
@@ -10608,6 +10608,8 @@ ValidateStructure(Declaration)
{
switch (classMember->kind)
{
case WfClassMemberKind::Normal:
break;
case WfClassMemberKind::Static:
manager->errors.Add(WfErrors::NonFunctionClassMemberCannotBeStatic(classMember));
break;
@@ -10630,9 +10632,9 @@ ValidateStructure(Declaration)
switch (classDecl->kind)
{
case WfClassKind::Class:
{
manager->errors.Add(WfErrors::ClassFeatureNotSupported(classMember, L"event"));
}
manager->errors.Add(WfErrors::ClassFeatureNotSupported(classMember, L"event"));
break;
case WfClassKind::Interface:
break;
}
@@ -10654,9 +10656,9 @@ ValidateStructure(Declaration)
switch (classDecl->kind)
{
case WfClassKind::Class:
{
manager->errors.Add(WfErrors::ClassFeatureNotSupported(classMember, L"property"));
}
manager->errors.Add(WfErrors::ClassFeatureNotSupported(classMember, L"property"));
break;
case WfClassKind::Interface:
break;
}
@@ -10735,6 +10737,8 @@ ValidateStructure(Declaration)
{
switch (classMember->kind)
{
case WfClassMemberKind::Normal:
break;
case WfClassMemberKind::Static:
manager->errors.Add(WfErrors::NonFunctionClassMemberCannotBeStatic(classMember));
break;
@@ -10751,6 +10755,8 @@ ValidateStructure(Declaration)
}
}
break;
case WfClassKind::Interface:
break;
}
FOREACH(Ptr<WfType>, type, node->baseTypes)
@@ -12527,6 +12533,8 @@ Print (Declaration)
writer.WriteString(indent + L" ");
switch (member->kind)
{
case WfClassMemberKind::Normal:
break;
case WfClassMemberKind::Static:
writer.WriteString(L"static ");
break;
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.