/***********************************************************************
THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY
DEVELOPER: Zihan Chen(vczh)
***********************************************************************/
#include "Vlpp.h"
#include "VlppWorkflowLibrary.h"
/***********************************************************************
.\GUITYPES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Common Types
Classes:
***********************************************************************/
#ifndef VCZH_PRESENTATION_GUITYPES
#define VCZH_PRESENTATION_GUITYPES
namespace vl
{
namespace presentation
{
/***********************************************************************
Enumerations
***********************************************************************/
///
/// Defines an alignment direction.
///
enum class Alignment
{
/// Aligned to the left side.
Left=0,
/// Aligned to the top side.
Top=0,
/// Aligned to the center.
Center=1,
/// Aligned to the right side.
Right=2,
/// Aligned to the bottom side.
Bottom=2,
};
/// Axis direction.
enum class AxisDirection
{
/// X:left, Y:down.
LeftDown,
/// X:right, Y:down.
RightDown,
/// X:left, Y:up.
LeftUp,
/// X:right, Y:up.
RightUp,
/// X:down, Y:left.
DownLeft,
/// X:down, Y:right.
DownRight,
/// X:up, Y:left.
UpLeft,
/// X:up, Y:right.
UpRight,
};
/***********************************************************************
TextPos
***********************************************************************/
///
/// Represents the position in multiple lines of text.
///
struct TextPos
{
///
/// Row number.
///
vint row;
///
/// Column number. If a line has 4 characters, there are 5 available column numbers(from 0 to 4) in this line.
///
vint column;
TextPos()
:row(0) ,column(0)
{
}
TextPos(vint _row, vint _column)
:row(_row) ,column(_column)
{
}
vint Compare(const TextPos& value)const
{
if(rowvalue.row) return 1;
if(columnvalue.column) return 1;
return 0;
}
bool operator==(const TextPos& value)const {return Compare(value)==0;}
bool operator!=(const TextPos& value)const {return Compare(value)!=0;}
bool operator<(const TextPos& value)const {return Compare(value)<0;}
bool operator<=(const TextPos& value)const {return Compare(value)<=0;}
bool operator>(const TextPos& value)const {return Compare(value)>0;}
bool operator>=(const TextPos& value)const {return Compare(value)>=0;}
};
/***********************************************************************
GridPos
***********************************************************************/
///
/// Represents the cell position in a grid.
///
struct GridPos
{
///
/// Row number.
///
vint row;
///
/// Column number. If a line has 4 characters, there are 5 available column numbers(from 0 to 4) in this line.
///
vint column;
GridPos()
:row(0) ,column(0)
{
}
GridPos(vint _row, vint _column)
:row(_row) ,column(_column)
{
}
vint Compare(const GridPos& value)const
{
if(rowvalue.row) return 1;
if(columnvalue.column) return 1;
return 0;
}
bool operator==(const GridPos& value)const {return Compare(value)==0;}
bool operator!=(const GridPos& value)const {return Compare(value)!=0;}
bool operator<(const GridPos& value)const {return Compare(value)<0;}
bool operator<=(const GridPos& value)const {return Compare(value)<=0;}
bool operator>(const GridPos& value)const {return Compare(value)>0;}
bool operator>=(const GridPos& value)const {return Compare(value)>=0;}
};
/***********************************************************************
Point
***********************************************************************/
///
/// Represents a position in a two dimensions space.
///
struct Point
{
///
/// Position in x dimension.
///
vint x;
///
/// Position in y dimension.
///
vint y;
Point()
:x(0) ,y(0)
{
}
Point(vint _x, vint _y)
:x(_x) ,y(_y)
{
}
bool operator==(Point point)const
{
return x==point.x && y==point.y;
}
bool operator!=(Point point)const
{
return x!=point.x || y!=point.y;
}
};
/***********************************************************************
Size
***********************************************************************/
///
/// Represents a size in a two dimensions space.
///
struct Size
{
///
/// Size in x dimension.
///
vint x;
///
/// Size in y dimension.
///
vint y;
Size()
:x(0) ,y(0)
{
}
Size(vint _x, vint _y)
:x(_x) ,y(_y)
{
}
bool operator==(Size size)const
{
return x==size.x && y==size.y;
}
bool operator!=(Size size)const
{
return x!=size.x || y!=size.y;
}
};
/***********************************************************************
Rectangle
***********************************************************************/
///
/// Represents a bounds in a two dimensions space.
///
struct Rect
{
///
/// Left.
///
vint x1;
///
/// Top.
///
vint y1;
///
/// Left + Width.
///
vint x2;
///
/// Top + Height.
///
vint y2;
Rect()
:x1(0), y1(0), x2(0), y2(0)
{
}
Rect(vint _x1, vint _y1, vint _x2, vint _y2)
:x1(_x1), y1(_y1), x2(_x2), y2(_y2)
{
}
Rect(Point p, Size s)
:x1(p.x), y1(p.y), x2(p.x+s.x), y2(p.y+s.y)
{
}
bool operator==(Rect rect)const
{
return x1==rect.x1 && y1==rect.y1 && x2==rect.x2 && y2==rect.y2;
}
bool operator!=(Rect rect)const
{
return x1!=rect.x1 || y1!=rect.y1 || x2!=rect.x2 || y2!=rect.y2;
}
Point LeftTop()const
{
return Point(x1, y1);
}
Point RightBottom()const
{
return Point(x2, y2);
}
Size GetSize()const
{
return Size(x2-x1, y2-y1);
}
vint Left()const
{
return x1;
}
vint Right()const
{
return x2;
}
vint Width()const
{
return x2-x1;
}
vint Top()const
{
return y1;
}
vint Bottom()const
{
return y2;
}
vint Height()const
{
return y2-y1;
}
void Expand(vint x, vint y)
{
x1-=x;
y1-=y;
x2+=x;
y2+=y;
}
void Expand(Size s)
{
x1-=s.x;
y1-=s.y;
x2+=s.x;
y2+=s.y;
}
void Move(vint x, vint y)
{
x1+=x;
y1+=y;
x2+=x;
y2+=y;
}
void Move(Size s)
{
x1+=s.x;
y1+=s.y;
x2+=s.x;
y2+=s.y;
}
bool Contains(Point p)
{
return x1<=p.x && p.xRepresents a 32bit RGBA color. Values of separate components can be accessed using fields "r", "g", "b" and "a".
struct Color
{
union
{
struct
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
vuint32_t value;
};
Color()
:r(0), g(0), b(0), a(255)
{
}
Color(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a=255)
:r(_r), g(_g), b(_b), a(_a)
{
}
vint Compare(Color color)const
{
return value-color.value;
}
static Color Parse(const WString& value)
{
const wchar_t* code=L"0123456789ABCDEF";
if((value.Length()==7 || value.Length()==9) && value[0]==L'#')
{
vint index[8]={15, 15, 15, 15, 15, 15, 15, 15};
for(vint i=0;i15)
{
return Color();
}
}
Color c;
c.r=(unsigned char)(index[0]*16+index[1]);
c.g=(unsigned char)(index[2]*16+index[3]);
c.b=(unsigned char)(index[4]*16+index[5]);
c.a=(unsigned char)(index[6]*16+index[7]);
return c;
}
return Color();
}
WString ToString()const
{
const wchar_t* code=L"0123456789ABCDEF";
wchar_t result[10]=L"#00000000";
result[1]=code[r/16];
result[2]=code[r%16];
result[3]=code[g/16];
result[4]=code[g%16];
result[5]=code[b/16];
result[6]=code[b%16];
if(a==255)
{
result[7]=L'\0';
}
else
{
result[7]=code[a/16];
result[8]=code[a%16];
}
return result;
}
bool operator==(Color color)const {return Compare(color)==0;}
bool operator!=(Color color)const {return Compare(color)!=0;}
bool operator<(Color color)const {return Compare(color)<0;}
bool operator<=(Color color)const {return Compare(color)<=0;}
bool operator>(Color color)const {return Compare(color)>0;}
bool operator>=(Color color)const {return Compare(color)>=0;}
};
/***********************************************************************
Margin
***********************************************************************/
///
/// Represents a margin in a two dimensions space.
///
struct Margin
{
///
/// The left margin.
///
vint left;
///
/// The top margin.
///
vint top;
///
/// The right margin.
///
vint right;
///
/// The bottom margin.
///
vint bottom;
Margin()
:left(0), top(0), right(0), bottom(0)
{
}
Margin(vint _left, vint _top, vint _right, vint _bottom)
:left(_left), top(_top), right(_right), bottom(_bottom)
{
}
bool operator==(Margin margin)const
{
return left==margin.left && top==margin.top && right==margin.right && bottom==margin.bottom;
}
bool operator!=(Margin margin)const
{
return left!=margin.left || top!=margin.top || right!=margin.right || bottom!=margin.bottom;
}
};
/***********************************************************************
Resources
***********************************************************************/
///
/// Represents a font configuration.
///
struct FontProperties
{
///
/// Font family (or font name, usually).
///
WString fontFamily;
///
/// Font size in pixel.
///
vint size;
///
/// True if the font is bold.
///
bool bold;
///
/// True if the font is italic.
///
bool italic;
///
/// True if the font has a underline.
///
bool underline;
///
/// True if the font has a strikeline.
///
bool strikeline;
///
/// True if the font has anti alias rendering.
///
bool antialias;
///
/// True if the font has anti alias rendering in vertical direction.
///
bool verticalAntialias;
FontProperties()
:size(0)
,bold(false)
,italic(false)
,underline(false)
,strikeline(false)
,antialias(true)
,verticalAntialias(false)
{
}
vint Compare(const FontProperties& value)const
{
vint result=0;
result=WString::Compare(fontFamily, value.fontFamily);
if(result!=0) return result;
result=size-value.size;
if(result!=0) return result;
result=(vint)bold-(vint)value.bold;
if(result!=0) return result;
result=(vint)italic-(vint)value.italic;
if(result!=0) return result;
result=(vint)underline-(vint)value.underline;
if(result!=0) return result;
result=(vint)strikeline-(vint)value.strikeline;
if(result!=0) return result;
result=(vint)antialias-(vint)value.antialias;
if(result!=0) return result;
return 0;
}
bool operator==(const FontProperties& value)const {return Compare(value)==0;}
bool operator!=(const FontProperties& value)const {return Compare(value)!=0;}
bool operator<(const FontProperties& value)const {return Compare(value)<0;}
bool operator<=(const FontProperties& value)const {return Compare(value)<=0;}
bool operator>(const FontProperties& value)const {return Compare(value)>0;}
bool operator>=(const FontProperties& value)const {return Compare(value)>=0;}
};
}
}
#endif
/***********************************************************************
.\GRAPHICSELEMENT\GUIGRAPHICSELEMENTINTERFACES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Element System and Infrastructure Interfaces
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSELEMENTINTERFACES
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSELEMENTINTERFACES
namespace vl
{
namespace presentation
{
using namespace reflection;
namespace compositions
{
class GuiGraphicsComposition;
extern void InvokeOnCompositionStateChanged(compositions::GuiGraphicsComposition* composition);
}
namespace elements
{
class IGuiGraphicsElement;
class IGuiGraphicsElementFactory;
class IGuiGraphicsRenderer;
class IGuiGraphicsRendererFactory;
class IGuiGraphicsRenderTarget;
/***********************************************************************
Basic Construction
***********************************************************************/
///
/// This is the interface for graphics elements.
/// Graphics elements usually contains some information and helper functions for visible things.
/// An graphics elements should be created using ElementType::Create.
///
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;
///
/// Access the associated for this graphics element.
///
/// Returns the related renderer.
virtual IGuiGraphicsRenderer* GetRenderer() = 0;
///
/// Get the owner composition.
///
/// The owner composition.
virtual compositions::GuiGraphicsComposition* GetOwnerComposition() = 0;
};
///
/// This is the interface for graphics element factories.
/// Graphics element factories should be registered using [M:vl.presentation.elements.GuiGraphicsResourceManager.RegisterElementFactory].
///
class IGuiGraphicsElementFactory : public Interface
{
public:
///
/// Get the name representing the kind of graphics element to be created.
///
/// Returns the name of graphics elements.
virtual WString GetElementTypeName()=0;
///
/// Create a .
///
/// Returns the created graphics elements.
virtual IGuiGraphicsElement* Create()=0;
};
///
/// This is the interface for graphics renderers.
///
class IGuiGraphicsRenderer : public Interface
{
public:
///
/// Access the graphics that is used to create this graphics renderer.
///
/// Returns the related factory.
virtual IGuiGraphicsRendererFactory* GetFactory()=0;
///
/// Initialize the grpahics renderer by binding a to it.
///
/// The graphics element to bind.
virtual void Initialize(IGuiGraphicsElement* element)=0;
///
/// Release all resources that used by this renderer.
///
virtual void Finalize()=0;
///
/// Set a to this element.
///
/// The graphics render target. It can be NULL.
virtual void SetRenderTarget(IGuiGraphicsRenderTarget* renderTarget)=0;
///
/// Render the graphics element using a specified bounds.
///
/// Bounds to decide the size and position of the binded graphics element.
virtual void Render(Rect bounds)=0;
///
/// Notify that the state in the binded graphics element is changed. This function is usually called by the element itself.
///
virtual void OnElementStateChanged()=0;
///
/// Calculate the minimum size using the binded graphics element and its state.
///
/// The minimum size.
virtual Size GetMinSize()=0;
};
///
/// This is the interface for graphics renderer factories.
/// Graphics renderers should be registered using [M:vl.presentation.elements.GuiGraphicsResourceManager.RegisterRendererFactory].
///
class IGuiGraphicsRendererFactory : public Interface
{
public:
///
/// Create a .
///
/// Returns the created graphics renderer.
virtual IGuiGraphicsRenderer* Create()=0;
};
enum RenderTargetFailure
{
None,
ResizeWhileRendering,
LostDevice,
};
///
/// This is the interface for graphics renderer targets.
///
class IGuiGraphicsRenderTarget : public Interface
{
public:
///
/// Notify the target to prepare for rendering.
///
virtual void StartRendering()=0;
///
/// Notify the target to stop rendering.
///
/// Returns false to recreate render target.
virtual RenderTargetFailure StopRendering()=0;
///
/// Apply a clipper to the render target.
/// The result clipper is combined by all clippers in the clipper stack maintained by the render target.
///
/// The clipper to push.
virtual void PushClipper(Rect clipper)=0;
///
/// Remove the last pushed clipper from the clipper stack.
///
virtual void PopClipper()=0;
///
/// Get the combined clipper
///
/// The combined clipper
virtual Rect GetClipper()=0;
///
/// Test is the combined clipper is as large as the render target.
///
/// Return true if the combined clipper is as large as the render target.
virtual bool IsClipperCoverWholeTarget()=0;
};
}
}
}
#endif
/***********************************************************************
.\GRAPHICSELEMENT\GUIGRAPHICSDOCUMENTINTERFACES.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Element System and Infrastructure Interfaces
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTINTERFACES
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSDOCUMENTINTERFACES
namespace vl
{
namespace presentation
{
using namespace reflection;
namespace elements
{
/***********************************************************************
Layout Engine
***********************************************************************/
class IGuiGraphicsParagraph;
class IGuiGraphicsLayoutProvider;
/// Represents a paragraph of a layouted rich text content.
class IGuiGraphicsParagraph : public IDescriptable, public Description
{
public:
static const vint NullInteractionId = -1;
/// Text style. Items in this enumeration type can be combined.
enum TextStyle
{
/// Bold.
Bold=1,
/// Italic.
Italic=2,
/// Underline.
Underline=4,
/// Strikeline.
Strikeline=8,
};
/// Inline object break condition.
enum BreakCondition
{
/// Stay together with the previous run if possible.
StickToPreviousRun,
/// Stay together with the next run if possible.
StickToNextRun,
/// Treat as a single run.
Alone,
};
/// Caret relative position.
enum CaretRelativePosition
{
/// The first caret position.
CaretFirst,
/// The last caret position.
CaretLast,
/// The first caret position of the current line.
CaretLineFirst,
/// The last caret position of the current line.
CaretLineLast,
/// The relative left caret position.
CaretMoveLeft,
/// The relative right caret position.
CaretMoveRight,
/// The relative up caret position.
CaretMoveUp,
/// The relative down caret position.
CaretMoveDown,
};
/// Inline object properties.
struct InlineObjectProperties
{
/// The size of the inline object.
Size size;
/// The baseline of the inline object.If the baseline is at the bottom, then set the baseline to -1.
vint baseline = -1;
/// The break condition of the inline object.
BreakCondition breakCondition;
/// The background image, nullable.
Ptr backgroundImage;
/// The id for callback. If the value is -1, then no callback will be received .
vint callbackId = -1;
InlineObjectProperties()
:baseline(-1)
{
}
};
/// Get the object that created this paragraph.
/// The layout provider object.
virtual IGuiGraphicsLayoutProvider* GetProvider()=0;
/// Get the associated to this paragraph.
/// The associated render target.
virtual IGuiGraphicsRenderTarget* GetRenderTarget()=0;
/// Get if line auto-wrapping is enabled for this paragraph.
/// Return true if line auto-wrapping is enabled for this paragraph.
virtual bool GetWrapLine()=0;
/// Set if line auto-wrapping is enabled for this paragraph.
/// True if line auto-wrapping is enabled for this paragraph.
virtual void SetWrapLine(bool value)=0;
/// Get the max width for this paragraph. If there is no max width limitation, it returns -1.
/// The max width for this paragraph.
virtual vint GetMaxWidth()=0;
/// Set the max width for this paragraph. If the max width is set to -1, the max width limitation will be removed.
/// The max width.
virtual void SetMaxWidth(vint value)=0;
/// Get the horizontal alignment for this paragraph.
/// The alignment.
virtual Alignment GetParagraphAlignment()=0;
/// Set the horizontal alignment for this paragraph.
/// The alignment.
virtual void SetParagraphAlignment(Alignment value)=0;
/// Replace the font within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The font.
/// Returns true if this operation succeeded.
virtual bool SetFont(vint start, vint length, const WString& value)=0;
/// Replace the size within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The size.
/// Returns true if this operation succeeded.
virtual bool SetSize(vint start, vint length, vint value)=0;
/// Replace the text style within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The text style.
/// Returns true if this operation succeeded.
virtual bool SetStyle(vint start, vint length, TextStyle value)=0;
/// Replace the color within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The color.
/// Returns true if this operation succeeded.
virtual bool SetColor(vint start, vint length, Color value)=0;
/// Replace the background color within the specified range.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The background color.
/// Returns true if this operation succeeded.
virtual bool SetBackgroundColor(vint start, vint length, Color value)=0;
/// Bind an to a range of text.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// The properties for the inline object.
/// Returns true if this operation succeeded.
virtual bool SetInlineObject(vint start, vint length, const InlineObjectProperties& properties)=0;
/// Unbind all inline objects to a range of text.
/// The position of the first character of the specified range.
/// The length of the specified range by character.
/// Returns true if this operation succeeded.
virtual bool ResetInlineObject(vint start, vint length)=0;
/// Get the layouted height of the text. The result depends on rich styled text and the two important properties that can be set using and .
/// The layouted height.
virtual vint GetHeight()=0;
/// Make the caret visible so that it will be rendered in the paragraph.
/// Returns true if this operation succeeded.
/// The caret.
/// The color of the caret.
/// Set to true to display the caret for the character before it.
virtual bool OpenCaret(vint caret, Color color, bool frontSide)=0;
/// Make the caret invisible.
/// Returns true if this operation succeeded.
virtual bool CloseCaret()=0;
/// Render the graphics element using a specified bounds.
/// Bounds to decide the size and position of the binded graphics element.
virtual void Render(Rect bounds)=0;
/// Get a new caret from the old caret with a relative position.
/// The new caret. Returns -1 if failed.
/// The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.
/// The relative position.
/// Only for CaretMoveUp and CaretMoveDown. Set to true to make the caret prefer to get closer to the character before it. After this function is called, this argument stored the suggested side for displaying the new caret.
virtual vint GetCaret(vint comparingCaret, CaretRelativePosition position, bool& preferFrontSide)=0;
/// Get the bounds of the caret.
/// The bounds whose width is 0. Returns an empty Rect value if failed.
/// The caret.
/// Set to true to get the bounds of the front side, otherwise the back side. If only one side is valid, this argument is ignored.
virtual Rect GetCaretBounds(vint caret, bool frontSide)=0;
/// Get the caret from a specified position.
/// The caret. Returns -1 if failed.
/// The point.
virtual vint GetCaretFromPoint(Point point)=0;
/// Get the inline object from a specified position.
/// The inline object. Returns null if failed.
/// The point.
/// Get the start position of this element.
/// Get the length of this element.
virtual Nullable GetInlineObjectFromPoint(Point point, vint& start, vint& length)=0;
/// Get the nearest caret from a text position.
/// 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.
/// The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.
/// Set to true to search in front of the text position, otherwise the opposite position.
virtual vint GetNearestCaretFromTextPos(vint textPos, bool frontSide)=0;
/// Test is the caret valid.
/// Returns true if the caret is valid.
/// The caret to test.
virtual bool IsValidCaret(vint caret)=0;
/// Test is the text position valid.
/// Returns true if the text position is valid.
/// The text position to test.
virtual bool IsValidTextPos(vint textPos)=0;
};
/// Paragraph callback
class IGuiGraphicsParagraphCallback : public IDescriptable, public Description
{
public:
/// Called when an inline object with a valid callback id is being rendered.
/// Returns the new size of the rendered inline object.
/// The callback id of the inline object
/// The location of the inline object, relative to the left-top corner of this paragraph.
virtual Size OnRenderInlineObject(vint callbackId, Rect location) = 0;
};
/// Renderer awared rich text document layout engine provider interface.
class IGuiGraphicsLayoutProvider : public IDescriptable, public Description
{
public:
/// Create a paragraph with internal renderer device dependent objects initialized.
/// The text used to fill the paragraph.
/// The render target that the created paragraph will render to.
/// A callback to receive necessary information when the paragraph is being rendered.
/// The created paragraph object.
virtual Ptr CreateParagraph(const WString& text, IGuiGraphicsRenderTarget* renderTarget, IGuiGraphicsParagraphCallback* callback)=0;
};
}
}
}
#endif
/***********************************************************************
.\NATIVEWINDOW\GUINATIVEWINDOW.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Native Window
Interfaces:
INativeController : Interface for Operating System abstraction
Renderers:
GUI_GRAPHICS_RENDERER_GDI
GUI_GRAPHICS_RENDERER_DIRECT2D
***********************************************************************/
#ifndef VCZH_PRESENTATION_GUINATIVEWINDOW
#define VCZH_PRESENTATION_GUINATIVEWINDOW
namespace vl
{
namespace presentation
{
using namespace reflection;
class INativeWindow;
class INativeWindowListener;
class INativeController;
class INativeControllerListener;
/***********************************************************************
System Object
***********************************************************************/
///
/// Represents a screen.
///
class INativeScreen : public virtual IDescriptable, Description
{
public:
///
/// Get the bounds of the screen.
///
/// The bounds of the screen.
virtual Rect GetBounds()=0;
///
/// Get the bounds of the screen client area.
///
/// The bounds of the screen client area.
virtual Rect GetClientBounds()=0;
///
/// Get the name of the screen.
///
/// The name of the screen.
virtual WString GetName()=0;
///
/// Test is the screen is a primary screen.
///
/// Returns true if the screen is a primary screen.
virtual bool IsPrimary()=0;
};
///
/// Represents a cursor.
///
class INativeCursor : public virtual IDescriptable, Description
{
public:
///
/// Represents a predefined cursor type.
///
enum SystemCursorType
{
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Small waiting cursor.
///
SmallWaiting,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]large waiting cursor.
///
LargeWaiting,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Arrow cursor.
///
Arrow,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Cross cursor.
///
Cross,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Hand cursor.
///
Hand,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Help cursor.
///
Help,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]I beam cursor.
///
IBeam,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Sizing in all direction cursor.
///
SizeAll,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Sizing NE-SW cursor.
///
SizeNESW,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Sizing N-S cursor.
///
SizeNS,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Sizing NW-SE cursor.
///
SizeNWSE,
///
/// [T:vl.presentation.INativeCursor.SystemCursorType]Sizing W-E cursor.
///
SizeWE,
LastSystemCursor=SizeWE,
};
static const vint SystemCursorCount=LastSystemCursor+1;
public:
///
/// Test is the cursor a system provided cursor.
///
/// Returns true if the cursor a system provided cursor.
virtual bool IsSystemCursor()=0;
///
/// Get the cursor type if the cursor a system provided cursor.
///
/// The cursor type.
virtual SystemCursorType GetSystemCursorType()=0;
};
/***********************************************************************
Image Object
***********************************************************************/
class INativeImageService;
class INativeImage;
class INativeImageFrame;
///
/// Represents a customized cache object for an image frame.
///
class INativeImageFrameCache : public Interface
{
public:
///
/// Called when this cache object is attached to an image frame.
///
/// The image frame that attached to.
virtual void OnAttach(INativeImageFrame* frame)=0;
///
/// Called when this cache object is detached to an image frame.
///
/// The image frame that detached from.
virtual void OnDetach(INativeImageFrame* frame)=0;
};
///
/// Represents an image frame.
///
class INativeImageFrame : public virtual IDescriptable, public Description
{
public:
///
/// Get the image that owns this frame.
///
/// The image that owns this frame.
virtual INativeImage* GetImage()=0;
///
/// Get the size of this frame.
///
/// The size of this frame.
virtual Size GetSize()=0;
///
/// Attach a customized cache object to this image frame and bind to a key.
///
/// Returns true if this operation succeeded.
/// The key binded with the customized cache object.
/// The customized cache object.
virtual bool SetCache(void* key, Ptr cache)=0;
///
/// Get the attached customized cache object that is already binded to a key.
///
/// The attached customized cache object.
/// The key binded with the customized cache object.
virtual Ptr GetCache(void* key)=0;
///
/// Get the attached customized cache object that is already binded to a key, and then detach it.
///
/// The detached customized cache object.
/// The key binded with the customized cache object.
virtual Ptr RemoveCache(void* key)=0;
};
///
/// Represents an image.
///
class INativeImage : public virtual IDescriptable, public Description
{
public:
///
/// Represents an image format.
///
enum FormatType
{
///
/// [T:vl.presentation.INativeImage.FormatType]Bitmap format.
///
Bmp,
///
/// [T:vl.presentation.INativeImage.FormatType]GIF format.
///
Gif,
///
/// [T:vl.presentation.INativeImage.FormatType]Icon format.
///
Icon,
///
/// [T:vl.presentation.INativeImage.FormatType]JPEG format.
///
Jpeg,
///
/// [T:vl.presentation.INativeImage.FormatType]PNG format.
///
Png,
///
/// [T:vl.presentation.INativeImage.FormatType]TIFF format.
///
Tiff,
///
/// [T:vl.presentation.INativeImage.FormatType]WMP format.
///
Wmp,
///
/// [T:vl.presentation.INativeImage.FormatType]Unknown format.
///
Unknown,
};
///
/// Get the image service that creates this image.
///
/// The image service that creates this image.
virtual INativeImageService* GetImageService()=0;
///
/// Get the image format.
///
/// The image format.
virtual FormatType GetFormat()=0;
///
/// Get the number of frames in this image.
///
/// The number of frames in this image.
virtual vint GetFrameCount()=0;
///
/// Get the frame in this image by a specified frame index.
///
/// The frame in this image by a specified frame index.
/// The specified frame index.
virtual INativeImageFrame* GetFrame(vint index)=0;
};
///
/// Image service. To access this service, use [M:vl.presentation.INativeController.ImageService].
///
class INativeImageService : public virtual IDescriptable, public Description
{
public:
///
/// Create an image from file.
///
/// The created image.
/// The file path.
virtual Ptr CreateImageFromFile(const WString& path)=0;
///
/// Create an image from memory.
///
/// The created image.
/// The memory pointer.
/// The memory length.
virtual Ptr CreateImageFromMemory(void* buffer, vint length)=0;
///
/// Create an image from stream.
///
/// The created image.
/// The stream.
virtual Ptr CreateImageFromStream(stream::IStream& stream)=0;
};
/***********************************************************************
Native Window
***********************************************************************/
///
/// Represents a window.
///
class INativeWindow : public Interface, public Description
{
public:
///
/// Get the bounds of the window.
///
/// The bounds of the window.
virtual Rect GetBounds()=0;
///
/// Set the bounds of the window.
///
/// The bounds of the window.
virtual void SetBounds(const Rect& bounds)=0;
///
/// Get the client size of the window.
///
/// The client size of the window.
virtual Size GetClientSize()=0;
///
/// Set the client size of the window.
///
/// The client size of the window.
virtual void SetClientSize(Size size)=0;
///
/// Get the client bounds in screen space.
///
/// The client bounds in screen space.
virtual Rect GetClientBoundsInScreen()=0;
///
/// Get the title of the window. A title will be displayed as a name of this window.
///
/// The title of the window.
virtual WString GetTitle()=0;
///
/// Set the title of the window. A title will be displayed as a name of this window.
///
/// The title of the window.
virtual void SetTitle(WString title)=0;
///
/// Get the mouse cursor of the window. When the mouse is on the window, the mouse cursor will be rendered.
///
/// The mouse cursor of the window.
virtual INativeCursor* GetWindowCursor()=0;
///
/// Set the mouse cursor of the window. When the mouse is on the window, the mouse cursor will be rendered.
///
/// The mouse cursor of the window.
virtual void SetWindowCursor(INativeCursor* cursor)=0;
///
/// Get the caret point of the window. When an input method editor is opened, the input text box will be located to the caret point.
///
/// The caret point of the window.
virtual Point GetCaretPoint()=0;
///
/// Set the caret point of the window. When an input method editor is opened, the input text box will be located to the caret point.
///
/// The caret point of the window.
virtual void SetCaretPoint(Point point)=0;
///
/// Get the parent window. A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows.
///
/// The parent window.
virtual INativeWindow* GetParent()=0;
///
/// Set the parent window. A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows.
///
/// The parent window.
virtual void SetParent(INativeWindow* parent)=0;
///
/// Test is the window always pass the focus to its parent window.
///
/// Returns true if the window always pass the focus to its parent window.
virtual bool GetAlwaysPassFocusToParent()=0;
///
/// Enable or disble always passing the focus to its parent window.
///
/// True to enable always passing the focus to its parent window.
virtual void SetAlwaysPassFocusToParent(bool value)=0;
///
/// Enable the window customized frame mode.
///
virtual void EnableCustomFrameMode()=0;
///
/// Disable the window customized frame mode.
///
virtual void DisableCustomFrameMode()=0;
///
/// Test is the window customized frame mode enabled.
///
/// Returns true if the window customized frame mode is enabled.
virtual bool IsCustomFrameModeEnabled()=0;
/// Window size state.
enum WindowSizeState
{
/// Minimized.
Minimized,
/// Restored.
Restored,
/// Maximized.
Maximized,
};
///
/// Get the window size state.
///
/// Returns the window size state.
virtual WindowSizeState GetSizeState()=0;
///
/// Show the window.
///
virtual void Show()=0;
///
/// Show the window without activation.
///
virtual void ShowDeactivated()=0;
///
/// Restore the window.
///
virtual void ShowRestored()=0;
///
/// Maximize the window.
///
virtual void ShowMaximized()=0;
///
/// Minimize the window.
///
virtual void ShowMinimized()=0;
///
/// Hide the window.
///
virtual void Hide()=0;
///
/// Test is the window visible.
///
/// Returns true if the window is visible.
virtual bool IsVisible()=0;
///
/// Enable the window.
///
virtual void Enable()=0;
///
/// Disable the window.
///
virtual void Disable()=0;
///
/// Test is the window enabled.
///
/// Returns true if the window is enabled.
virtual bool IsEnabled()=0;
///
/// Set focus to the window.
///
virtual void SetFocus()=0;
///
/// Test is the window focused.
///
/// Returns true if the window is focused.
virtual bool IsFocused()=0;
///
/// Activate to the window.
///
virtual void SetActivate()=0;
///
/// Test is the window activated.
///
/// Returns true if the window is activated.
virtual bool IsActivated()=0;
///
/// Show the icon in the task bar.
///
virtual void ShowInTaskBar()=0;
///
/// Hide the icon in the task bar.
///
virtual void HideInTaskBar()=0;
///
/// Test is the window icon appeared in the task bar.
///
/// Returns true if the window icon appears in the task bar.
virtual bool IsAppearedInTaskBar()=0;
///
/// Enable activation to the window.
///
virtual void EnableActivate()=0;
///
/// Disable activation to the window.
///
virtual void DisableActivate()=0;
///
/// Test is the window allowed to be activated.
///
/// Returns true if the window is allowed to be activated.
virtual bool IsEnabledActivate()=0;
///
/// Require mouse message capturing to this window. If the capture is required, all mouse message will be send to this window.
///
/// Returns true if this operation succeeded.
virtual bool RequireCapture()=0;
///
/// Release mouse message capturing to this window. If the capture is required, all mouse message will be send to this window.
///
/// Returns true if this operation succeeded.
virtual bool ReleaseCapture()=0;
///
/// Test if the window is capturing mouse messages.
///
/// Returns true if the window is capturing mouse messages.
virtual bool IsCapturing()=0;
///
/// Test is the maximize box visible.
///
/// Returns true if the maximize box is visible.
virtual bool GetMaximizedBox()=0;
///
/// Make the maximize box visible or invisible.
///
/// True to make the maximize box visible.
virtual void SetMaximizedBox(bool visible)=0;
///
/// Test is the minimize box visible.
///
/// Returns true if the minimize box is visible.
virtual bool GetMinimizedBox()=0;
///
/// Make the minimize box visible or invisible.
///
/// True to make the minimize box visible.
virtual void SetMinimizedBox(bool visible)=0;
///
/// Test is the border visible.
///
/// Returns true if the border is visible.
virtual bool GetBorder()=0;
///
/// Make the border visible or invisible.
///
/// True to make the border visible.
virtual void SetBorder(bool visible)=0;
///
/// Test is the size box visible.
///
/// Returns true if the size box is visible.
virtual bool GetSizeBox()=0;
///
/// Make the size box visible or invisible.
///
/// True to make the size box visible.
virtual void SetSizeBox(bool visible)=0;
///
/// Test is the icon visible.
///
/// Returns true if the icon is visible.
virtual bool GetIconVisible()=0;
///
/// Make the icon visible or invisible.
///
/// True to make the icon visible.
virtual void SetIconVisible(bool visible)=0;
///
/// Test is the title bar visible.
///
/// Returns true if the title bar is visible.
virtual bool GetTitleBar()=0;
///
/// Make the title bar visible or invisible.
///
/// True to make the title bar visible.
virtual void SetTitleBar(bool visible)=0;
///
/// Test is the window always on top of the desktop.
///
/// Returns true if the window is always on top of the desktop.
virtual bool GetTopMost()=0;
///
/// Make the window always or never on top of the desktop.
///
/// True to make the window always on top of the desktop.
virtual void SetTopMost(bool topmost)=0;
///
/// Supress the system's Alt+X hot key
///
virtual void SupressAlt() = 0;
///
/// Install an message listener.
///
/// Returns true if this operation succeeded.
/// The listener to install.
virtual bool InstallListener(INativeWindowListener* listener)=0;
///
/// Uninstall an message listener.
///
/// Returns true if this operation succeeded.
/// The listener to uninstall.
virtual bool UninstallListener(INativeWindowListener* listener)=0;
///
/// Redraw the content of the window.
///
virtual void RedrawContent()=0;
};
///
/// Mouse message information.
///
struct NativeWindowMouseInfo
{
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the left mouse button is pressed.
bool left;
/// True if the middle mouse button is pressed.
bool middle;
/// True if the right mouse button is pressed.
bool right;
/// The mouse position of x dimension.
vint x;
/// The mouse position of y dimension.
vint y;
/// The delta of the wheel.
vint wheel;
/// True if the mouse is in the non-client area.
bool nonClient;
};
///
/// Key message information.
///
struct NativeWindowKeyInfo
{
/// Key code of the key that sends this message, using VKEY_* macros.
vint code;
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the alt button is pressed.
bool alt;
/// True if the capslock button is pressed.
bool capslock;
};
///
/// Character message information.
///
struct NativeWindowCharInfo
{
/// Character that sends this message.
wchar_t code;
/// True if the control button is pressed.
bool ctrl;
/// True if the shift button is pressed.
bool shift;
/// True if the alt button is pressed.
bool alt;
/// True if the capslock button is pressed.
bool capslock;
};
///
/// Represents a message listener to an .
///
class INativeWindowListener : public Interface
{
public:
/// Hit test result for a native window.
enum HitTestResult
{
/// Border that doesn't contain sizing functionalitiy.
BorderNoSizing,
/// Left border.
BorderLeft,
/// Right border.
BorderRight,
/// Top border.
BorderTop,
/// Bottom border.
BorderBottom,
/// Left top border.
BorderLeftTop,
/// Right top border.
BorderRightTop,
/// Left bottom border.
BorderLeftBottom,
/// Right bottom border.
BorderRightBottom,
/// Title
Title,
/// Minimum button.
ButtonMinimum,
/// Maximum button.
ButtonMaximum,
/// Close button.
ButtonClose,
/// Client button.
Client,
/// Icon.
Icon,
/// Let the OS window layer decide.
NoDecision,
};
///
/// Perform a hit test.
///
/// Returns the hit test result. If "NoDecision" is returned, the native window provider should call the OS window layer to do the hit test.
/// The location to do the hit test. This location is in the window space (not the client space).
virtual HitTestResult HitTest(Point location);
///
/// Called when the window is moving.
///
/// The bounds. Message handler can change the bounds.
/// True if the message raise only want the message handler to change the size.
virtual void Moving(Rect& bounds, bool fixSizeOnly);
///
/// Called when the window is moved.
///
virtual void Moved();
///
/// Called when the window is enabled.
///
virtual void Enabled();
///
/// Called when the window is disabled.
///
virtual void Disabled();
///
/// Called when the window got the focus.
///
virtual void GotFocus();
///
/// Called when the window lost the focus.
///
virtual void LostFocus();
///
/// Called when the window is activated.
///
virtual void Activated();
///
/// Called when the window is deactivated.
///
virtual void Deactivated();
///
/// Called when the window is opened.
///
virtual void Opened();
///
/// Called when the window is closing.
///
/// Change the value to true to prevent the windows from being closed.
virtual void Closing(bool& cancel);
///
/// Called when the window is closed.
///
virtual void Closed();
///
/// Called when the window is painting.
///
virtual void Paint();
///
/// Called when the window is destroying.
///
virtual void Destroying();
///
/// Called when the window is destroyed.
///
virtual void Destroyed();
///
/// Called when the left mouse button is pressed.
///
/// Detailed information to this message.
virtual void LeftButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the left mouse button is released.
///
/// Detailed information to this message.
virtual void LeftButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the left mouse button performed a double click.
///
/// Detailed information to this message.
virtual void LeftButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button is pressed.
///
/// Detailed information to this message.
virtual void RightButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button is released.
///
/// Detailed information to this message.
virtual void RightButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the right mouse button performed a double click.
///
/// Detailed information to this message.
virtual void RightButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button is pressed.
///
/// Detailed information to this message.
virtual void MiddleButtonDown(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button is released.
///
/// Detailed information to this message.
virtual void MiddleButtonUp(const NativeWindowMouseInfo& info);
///
/// Called when the middle mouse button performed a double click.
///
/// Detailed information to this message.
virtual void MiddleButtonDoubleClick(const NativeWindowMouseInfo& info);
///
/// Called when the horizontal mouse wheel scrolls.
///
/// Detailed information to this message.
virtual void HorizontalWheel(const NativeWindowMouseInfo& info);
///
/// Called when the horizontal vertical wheel scrolls.
///
/// Detailed information to this message.
virtual void VerticalWheel(const NativeWindowMouseInfo& info);
///
/// Called when the mouse is moving on the window.
///
/// Detailed information to this message.
virtual void MouseMoving(const NativeWindowMouseInfo& info);
///
/// Called when the mouse entered the window.
///
virtual void MouseEntered();
///
/// Called when the mouse leaved the window.
///
virtual void MouseLeaved();
///
/// Called a key is pressed.
///
/// Detailed information to this message.
virtual void KeyDown(const NativeWindowKeyInfo& info);
///
/// Called a key is released.
///
/// Detailed information to this message.
virtual void KeyUp(const NativeWindowKeyInfo& info);
///
/// Called a system key is pressed.
///
/// Detailed information to this message.
virtual void SysKeyDown(const NativeWindowKeyInfo& info);
///
/// Called a system key is released.
///
/// Detailed information to this message.
virtual void SysKeyUp(const NativeWindowKeyInfo& info);
///
/// Called an input character is generated.
///
/// Detailed information to this message.
virtual void Char(const NativeWindowCharInfo& info);
};
/***********************************************************************
Native Window Services
***********************************************************************/
///
/// System resource service. To access this service, use [M:vl.presentation.INativeController.ResourceService].
///
class INativeResourceService : public virtual IDescriptable, public Description
{
public:
///
/// Get a cached cursor object using a predefined system cursor type;
///
/// The cached cursor object.
/// The predefined system cursor type.
virtual INativeCursor* GetSystemCursor(INativeCursor::SystemCursorType type)=0;
///
/// Get a cached cursor object using a default system cursor type;
///
/// The cached cursor object.
virtual INativeCursor* GetDefaultSystemCursor()=0;
///
/// Get the default font configuration of the system.
///
/// The default font configuration of the system.
virtual FontProperties GetDefaultFont()=0;
///
/// Override the default font configuration for the current process, only available GacUI library.
///
/// The font configuration to override.
virtual void SetDefaultFont(const FontProperties& value)=0;
};
///
/// Delay execution controller.
///
class INativeDelay : public virtual IDescriptable, public Description
{
public:
/// Delay execution controller status.
enum ExecuteStatus
{
/// Pending.
Pending,
/// Executing.
Executing,
/// Executed.
Executed,
/// Canceled.
Canceled,
};
/// Get the current status.
/// The current status.
virtual ExecuteStatus GetStatus()=0;
/// If the current task is pending, execute the task after a specified period.
/// Returns true if this operation succeeded.
/// A specified period.
virtual bool Delay(vint milliseconds)=0;
/// If the current task is pending, cancel the task.
/// Returns true if this operation succeeded.
virtual bool Cancel()=0;
};
///
/// Asynchronized operation service. GacUI is not a thread safe library except for this service. To access this service, use [M:vl.presentation.INativeController.AsyncService].
///
class INativeAsyncService : public virtual IDescriptable, public Description
{
public:
///
/// Test is the current thread the main thread.
///
/// Returns true if the current thread is the main thread.
virtual bool IsInMainThread(INativeWindow* window)=0;
///
/// Invoke a specified function with an specified argument asynchronisly.
///
/// The specified function.
virtual void InvokeAsync(const Func& proc)=0;
///
/// Invoke a specified function with an specified argument in the main thread.
///
/// The specified function.
virtual void InvokeInMainThread(INativeWindow* window, const Func& proc)=0;
///
/// Invoke a specified function with an specified argument in the main thread and wait for the function to complete or timeout.
///
/// Return true if the function complete. Return false if the function has not completed during a specified period of time.
/// The specified function.
/// The specified period of time to wait. Set to -1 (default value) to wait forever until the function completed.
virtual bool InvokeInMainThreadAndWait(INativeWindow* window, const Func& proc, vint milliseconds=-1)=0;
///
/// Delay execute a specified function with an specified argument asynchronisly.
///
/// The Delay execution controller for this task.
/// The specified function.
/// Time to delay.
virtual Ptr DelayExecute(const Func& proc, vint milliseconds)=0;
///
/// Delay execute a specified function with an specified argument in the main thread.
///
/// The Delay execution controller for this task.
/// The specified function.
/// Time to delay.
virtual Ptr DelayExecuteInMainThread(const Func& proc, vint milliseconds)=0;
};
///
/// Clipboard service. To access this service, use [M:vl.presentation.INativeController.ClipboardService].
///
class INativeClipboardService : public virtual IDescriptable, public Description
{
public:
///
/// Test is there a text in the clipboard.
///
/// Returns true if there is a text in the clipboard.
virtual bool ContainsText()=0;
///
/// Get the text in the clipboard.
///
/// The text in the clipboard.
virtual WString GetText()=0;
///
/// Copy the text to the clipboard.
///
/// Returns true if this operation succeeded.
/// The text to copy to the clipboard.
virtual bool SetText(const WString& value)=0;
};
///
/// Screen information service. To access this service, use [M:vl.presentation.INativeController.ScreenService].
///
class INativeScreenService : public virtual IDescriptable, public Description
{
public:
///
/// Get the number of all available screens.
///
/// The number of all available screens.
virtual vint GetScreenCount()=0;
///
/// Get the screen object by a specified screen index.
///
/// The screen object.
/// The specified screen index.
virtual INativeScreen* GetScreen(vint index)=0;
///
/// Get the screen object where the main part of the specified window is inside.
///
/// The screen object.
/// The specified window.
virtual INativeScreen* GetScreen(INativeWindow* window)=0;
};
///
/// Window service. To access this service, use [M:vl.presentation.INativeController.WindowService].
///
class INativeWindowService : public virtual Interface
{
public:
///
/// Create a window.
///
/// The created window.
virtual INativeWindow* CreateNativeWindow()=0;
///
/// Destroy a window.
///
/// The window to destroy.
virtual void DestroyNativeWindow(INativeWindow* window)=0;
///
/// Get the main window.
///
/// The main window.
virtual INativeWindow* GetMainWindow()=0;
///
/// Get the window that under a specified position in screen space.
///
/// The window that under a specified position in screen space.
/// The specified position in screen space.
virtual INativeWindow* GetWindow(Point location)=0;
///
/// Make the specified window a main window, show that window, and wait until the windows is closed.
///
/// The specified window.
virtual void Run(INativeWindow* window)=0;
};
///
/// User input service. To access this service, use [M:vl.presentation.INativeController.InputService].
///
class INativeInputService : public virtual IDescriptable, public Description
{
public:
///
/// Start to reveive global mouse message.
///
virtual void StartHookMouse()=0;
///
/// Stop to receive global mouse message.
///
virtual void StopHookMouse()=0;
///
/// Test is the global mouse message receiving enabled.
///
/// Returns true if the global mouse message receiving is enabled.
virtual bool IsHookingMouse()=0;
///
/// Start to reveive global timer message.
///
virtual void StartTimer()=0;
///
/// Stop to receive global timer message.
///
virtual void StopTimer()=0;
///
/// Test is the global timer message receiving enabled.
///
/// Returns true if the global timer message receiving is enabled.
virtual bool IsTimerEnabled()=0;
///
/// Test is the specified key pressing.
///
/// Returns true if the specified key is pressing.
/// The key code to test, using VKEY_* macros.
virtual bool IsKeyPressing(vint code)=0;
///
/// Test is the specified key toggled.
///
/// Returns true if the specified key is toggled.
/// The key code to test, using VKEY_* macros.
virtual bool IsKeyToggled(vint code)=0;
///
/// Get the name of a key.
///
/// The name of a key.
/// The key code, using VKEY_* macros.
virtual WString GetKeyName(vint code)=0;
///
/// Get the key from a name.
///
/// The key, returns -1 if the key name doesn't exist.
/// Key name
virtual vint GetKey(const WString& name)=0;
};
///
/// Callback service. To access this service, use [M:vl.presentation.INativeController.CallbackService].
///
class INativeCallbackService : public virtual Interface
{
public:
///
/// Install a global message listener.
///
/// Returns true if this operation succeeded.
/// The global message listener to install.
virtual bool InstallListener(INativeControllerListener* listener)=0;
///
/// Uninstall a global message listener.
///
/// Returns true if this operation succeeded.
/// The global message listener to uninstall.
virtual bool UninstallListener(INativeControllerListener* listener)=0;
};
///
/// Dialog service. To access this service, use [M:vl.presentation.INativeController.DialogService].
///
class INativeDialogService : public virtual Interface
{
public:
///
/// Message box button combination for displaying a message box.
///
enum MessageBoxButtonsInput
{
/// Display OK.
DisplayOK,
/// Display OK, Cancel.
DisplayOKCancel,
/// Display Yes, No.
DisplayYesNo,
/// Display Yes, No, Cancel.
DisplayYesNoCancel,
/// Display Retry, Cancel.
DisplayRetryCancel,
/// Display Abort, Retry, Ignore.
DisplayAbortRetryIgnore,
/// Display Cancel, TryAgain, Continue.
DisplayCancelTryAgainContinue,
};
///
/// Message box button to indicate what the user selected.
///
enum MessageBoxButtonsOutput
{
/// Select OK.
SelectOK,
/// Select Cancel.
SelectCancel,
/// Select Yes.
SelectYes,
/// Select No.
SelectNo,
/// Select Retry.
SelectRetry,
/// Select Abort.
SelectAbort,
/// Select Ignore.
SelectIgnore,
/// Select TryAgain.
SelectTryAgain,
/// Select Continue.
SelectContinue,
};
///
/// Message box default button.
///
enum MessageBoxDefaultButton
{
/// First.
DefaultFirst,
/// Second.
DefaultSecond,
/// Third.
DefaultThird,
};
///
/// Message box icons.
///
enum MessageBoxIcons
{
/// No icon.
IconNone,
/// Error icon.
IconError,
/// Question icon.
IconQuestion,
/// Warning icon.
IconWarning,
/// Information icon.
IconInformation,
};
///
/// Message box model options.
///
enum MessageBoxModalOptions
{
/// Disable the current window.
ModalWindow,
/// Disable all windows in the application.
ModalTask,
/// Top most message box in the whole system.
ModalSystem,
};
/// Show a message box.
/// Returns the user selected button.
/// The current window. This argument can be null.
/// The content of the message box.
/// The title of the message box.
/// The display button combination of the message box.
/// The default button of the message box.
/// The icon of the message box.
/// The modal option of the message box.
virtual MessageBoxButtonsOutput ShowMessageBox(INativeWindow* window, const WString& text, const WString& title=L"", MessageBoxButtonsInput buttons=DisplayOK, MessageBoxDefaultButton defaultButton=DefaultFirst, MessageBoxIcons icon=IconNone, MessageBoxModalOptions modal=ModalWindow)=0;
///
/// Color dialog custom color options
///
enum ColorDialogCustomColorOptions
{
/// Disable the custom color panel.
CustomColorDisabled,
/// Enable the custom color panel.
CustomColorEnabled,
/// Open the custom color panel at the beginning.
CustomColorOpened,
};
/// Show a color dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The color that the user selected.
/// Make the color dialog selected the color specified in the "selection" parameter at the beginning.
/// Custom color panel options.
/// The initial 16 colors in custom color boxes. This argument can be null.
virtual bool ShowColorDialog(INativeWindow* window, Color& selection, bool selected=false, ColorDialogCustomColorOptions customColorOptions=CustomColorEnabled, Color* customColors=0)=0;
/// Show a font dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The font that the user selected.
/// The color that the user selected.
/// Make the font dialog selected the font specified in the "selectionFont" and "selectionColor" parameters at the beginning.
/// Enable the user to edit some extended font properties.
/// Force the user to select existing font.
virtual bool ShowFontDialog(INativeWindow* window, FontProperties& selectionFont, Color& selectionColor, bool selected=false, bool showEffect=true, bool forceFontExist=true)=0;
///
/// File dialog type.
///
enum FileDialogTypes
{
/// Open file dialog.
FileDialogOpen,
/// Open file dialog with preview.
FileDialogOpenPreview,
/// Save file dialog.
FileDialogSave,
/// Save file dialog with preview.
FileDialogSavePreview,
};
///
/// File dialog options.
///
enum FileDialogOptions
{
/// Allow multiple selection.
FileDialogAllowMultipleSelection = 1,
/// Prevent the user to select unexisting files.
FileDialogFileMustExist = 2,
/// Show the "Read Only" check box.
FileDialogShowReadOnlyCheckBox = 4,
/// Dereference link files.
FileDialogDereferenceLinks = 8,
/// Show the "Network" button.
FileDialogShowNetworkButton = 16,
/// Prompt if a new file is going to be created.
FileDialogPromptCreateFile = 32,
/// Promt if a existing file is going to be overwritten.
FileDialogPromptOverwriteFile = 64,
/// Prevent the user to select an unexisting directory.
FileDialogDirectoryMustExist = 128,
/// Add user selected files to "Recent" directory.
FileDialogAddToRecent = 256,
};
/// Show a file dialog.
/// Returns true if the user selected the OK button.
/// The current window.
/// The file names that the user selected.
/// The filter that the user selected.
/// The type of the file dialog.
/// The title of the file dialog.
/// The initial file name.
/// The initial directory.
/// The default file extension.
/// The file name filter like L"Text Files|*.txt|All Files|*.*".
/// File dialog options. Multiple options can be combined using the "|" operator.
virtual bool ShowFileDialog(INativeWindow* window, collections::List& selectionFileNames, vint& selectionFilterIndex, FileDialogTypes dialogType, const WString& title, const WString& initialFileName, const WString& initialDirectory, const WString& defaultExtension, const WString& filter, FileDialogOptions options)=0;
};
inline INativeDialogService::FileDialogOptions operator|(INativeDialogService::FileDialogOptions a, INativeDialogService::FileDialogOptions b)
{
return static_cast(static_cast(a) | static_cast(b));
}
inline INativeDialogService::FileDialogOptions operator&(INativeDialogService::FileDialogOptions a, INativeDialogService::FileDialogOptions b)
{
return static_cast(static_cast(a) & static_cast(b));
}
/***********************************************************************
Native Window Controller
***********************************************************************/
///
/// Global native system service controller. Use [M:vl.presentation.GetCurrentController] to access this controller.
///
class INativeController : public virtual IDescriptable, public Description
{
public:
///
/// Get the callback service.
///
/// The callback service
virtual INativeCallbackService* CallbackService()=0;
///
/// Get the system resource service.
///
/// The system resource service
virtual INativeResourceService* ResourceService()=0;
///
/// Get the asynchronized operation service.
///
/// The asynchronized operation service
virtual INativeAsyncService* AsyncService()=0;
///
/// Get the clipboard service.
///
/// The clipboard service
virtual INativeClipboardService* ClipboardService()=0;
///
/// Get the image service.
///
/// The image service
virtual INativeImageService* ImageService()=0;
///
/// Get the screen information service.
///
/// The screen information service
virtual INativeScreenService* ScreenService()=0;
///
/// Get the window service.
///
/// The window service
virtual INativeWindowService* WindowService()=0;
///
/// Get the user input service.
///
/// The user input service
virtual INativeInputService* InputService()=0;
///
/// Get the dialog service.
///
/// The user dialog service
virtual INativeDialogService* DialogService()=0;
///
/// Get the file path of the current executable.
///
/// The file path of the current executable.
virtual WString GetExecutablePath()=0;
};
///
/// Represents a global message listener to an .
///
class INativeControllerListener : public Interface
{
public:
///
/// Called when the left mouse button is pressed. To receive or not receive this message, use or .
///
/// The mouse position in the screen space.
virtual void LeftButtonDown(Point position);
///
/// Called when the left mouse button is released. To receive or not receive this message, use or
///
/// The mouse position in the screen space.
virtual void LeftButtonUp(Point position);
///
/// Called when the right mouse button is pressed. To receive or not receive this message, use or
///
/// The mouse position in the screen space.
virtual void RightButtonDown(Point position);
///
/// Called when the right mouse button is released. To receive or not receive this message, use or
///
/// The mouse position in the screen space.
virtual void RightButtonUp(Point position);
///
/// Called when the mouse is moving. To receive or not receive this message, use or
///
/// The mouse position in the screen space.
virtual void MouseMoving(Point position);
///
/// Called when the global timer message raised. To receive or not receive this message, use or
///
virtual void GlobalTimer();
///
/// Called when the content of the clipboard is updated.
///
virtual void ClipboardUpdated();
///
/// Called when a window is created.
///
/// The created window.
virtual void NativeWindowCreated(INativeWindow* window);
///
/// Called when a window is destroying.
///
/// The destroying window.
virtual void NativeWindowDestroying(INativeWindow* window);
};
///
/// Get the global native system service controller.
///
/// The global native system service controller.
extern INativeController* GetCurrentController();
///
/// Set the global native system service controller.
///
/// The global native system service controller.
extern void SetCurrentController(INativeController* controller);
}
}
/***********************************************************************
Native Window Provider
***********************************************************************/
/*
* Virtual Keys, Standard Set
*/
#define VKEY_LBUTTON 0x01
#define VKEY_RBUTTON 0x02
#define VKEY_CANCEL 0x03
#define VKEY_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */
#define VKEY_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */
#define VKEY_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */
/*
* 0x07 : unassigned
*/
#define VKEY_BACK 0x08
#define VKEY_TAB 0x09
/*
* 0x0A - 0x0B : reserved
*/
#define VKEY_CLEAR 0x0C
#define VKEY_RETURN 0x0D
#define VKEY_SHIFT 0x10
#define VKEY_CONTROL 0x11
#define VKEY_MENU 0x12
#define VKEY_PAUSE 0x13
#define VKEY_CAPITAL 0x14
#define VKEY_KANA 0x15
#define VKEY_HANGEUL 0x15 /* old name - should be here for compatibility */
#define VKEY_HANGUL 0x15
#define VKEY_JUNJA 0x17
#define VKEY_FINAL 0x18
#define VKEY_HANJA 0x19
#define VKEY_KANJI 0x19
#define VKEY_ESCAPE 0x1B
#define VKEY_CONVERT 0x1C
#define VKEY_NONCONVERT 0x1D
#define VKEY_ACCEPT 0x1E
#define VKEY_MODECHANGE 0x1F
#define VKEY_SPACE 0x20
#define VKEY_PRIOR 0x21
#define VKEY_NEXT 0x22
#define VKEY_END 0x23
#define VKEY_HOME 0x24
#define VKEY_LEFT 0x25
#define VKEY_UP 0x26
#define VKEY_RIGHT 0x27
#define VKEY_DOWN 0x28
#define VKEY_SELECT 0x29
#define VKEY_PRINT 0x2A
#define VKEY_EXECUTE 0x2B
#define VKEY_SNAPSHOT 0x2C
#define VKEY_INSERT 0x2D
#define VKEY_DELETE 0x2E
#define VKEY_HELP 0x2F
/*
* VKEY_0 - VKEY_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
* 0x40 : unassigned
* VKEY_A - VKEY_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
*/
#define VKEY_0 0x30
#define VKEY_1 0x31
#define VKEY_2 0x32
#define VKEY_3 0x33
#define VKEY_4 0x34
#define VKEY_5 0x35
#define VKEY_6 0x36
#define VKEY_7 0x37
#define VKEY_8 0x38
#define VKEY_9 0x39
#define VKEY_A 0x41
#define VKEY_B 0x42
#define VKEY_C 0x43
#define VKEY_D 0x44
#define VKEY_E 0x45
#define VKEY_F 0x46
#define VKEY_G 0x47
#define VKEY_H 0x48
#define VKEY_I 0x49
#define VKEY_J 0x4A
#define VKEY_K 0x4B
#define VKEY_L 0x4C
#define VKEY_M 0x4D
#define VKEY_N 0x4E
#define VKEY_O 0x4F
#define VKEY_P 0x50
#define VKEY_Q 0x51
#define VKEY_R 0x52
#define VKEY_S 0x53
#define VKEY_T 0x54
#define VKEY_U 0x55
#define VKEY_V 0x56
#define VKEY_W 0x57
#define VKEY_X 0x58
#define VKEY_Y 0x59
#define VKEY_Z 0x5A
#define VKEY_LWIN 0x5B
#define VKEY_RWIN 0x5C
#define VKEY_APPS 0x5D
/*
* 0x5E : reserved
*/
#define VKEY_SLEEP 0x5F
#define VKEY_NUMPAD0 0x60
#define VKEY_NUMPAD1 0x61
#define VKEY_NUMPAD2 0x62
#define VKEY_NUMPAD3 0x63
#define VKEY_NUMPAD4 0x64
#define VKEY_NUMPAD5 0x65
#define VKEY_NUMPAD6 0x66
#define VKEY_NUMPAD7 0x67
#define VKEY_NUMPAD8 0x68
#define VKEY_NUMPAD9 0x69
#define VKEY_MULTIPLY 0x6A
#define VKEY_ADD 0x6B
#define VKEY_SEPARATOR 0x6C
#define VKEY_SUBTRACT 0x6D
#define VKEY_DECIMAL 0x6E
#define VKEY_DIVIDE 0x6F
#define VKEY_F1 0x70
#define VKEY_F2 0x71
#define VKEY_F3 0x72
#define VKEY_F4 0x73
#define VKEY_F5 0x74
#define VKEY_F6 0x75
#define VKEY_F7 0x76
#define VKEY_F8 0x77
#define VKEY_F9 0x78
#define VKEY_F10 0x79
#define VKEY_F11 0x7A
#define VKEY_F12 0x7B
#define VKEY_F13 0x7C
#define VKEY_F14 0x7D
#define VKEY_F15 0x7E
#define VKEY_F16 0x7F
#define VKEY_F17 0x80
#define VKEY_F18 0x81
#define VKEY_F19 0x82
#define VKEY_F20 0x83
#define VKEY_F21 0x84
#define VKEY_F22 0x85
#define VKEY_F23 0x86
#define VKEY_F24 0x87
/*
* 0x88 - 0x8F : unassigned
*/
#define VKEY_NUMLOCK 0x90
#define VKEY_SCROLL 0x91
/*
* NEC PC-9800 kbd definitions
*/
#define VKEY_OEM_NEC_EQUAL 0x92 // '=' key on numpad
/*
* Fujitsu/OASYS kbd definitions
*/
#define VKEY_OEM_FJ_JISHO 0x92 // 'Dictionary' key
#define VKEY_OEM_FJ_MASSHOU 0x93 // 'Unregister word' key
#define VKEY_OEM_FJ_TOUROKU 0x94 // 'Register word' key
#define VKEY_OEM_FJ_LOYA 0x95 // 'Left OYAYUBI' key
#define VKEY_OEM_FJ_ROYA 0x96 // 'Right OYAYUBI' key
/*
* 0x97 - 0x9F : unassigned
*/
/*
* VKEY_L* & VKEY_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
*/
#define VKEY_LSHIFT 0xA0
#define VKEY_RSHIFT 0xA1
#define VKEY_LCONTROL 0xA2
#define VKEY_RCONTROL 0xA3
#define VKEY_LMENU 0xA4
#define VKEY_RMENU 0xA5
#define VKEY_BROWSER_BACK 0xA6
#define VKEY_BROWSER_FORWARD 0xA7
#define VKEY_BROWSER_REFRESH 0xA8
#define VKEY_BROWSER_STOP 0xA9
#define VKEY_BROWSER_SEARCH 0xAA
#define VKEY_BROWSER_FAVORITES 0xAB
#define VKEY_BROWSER_HOME 0xAC
#define VKEY_VOLUME_MUTE 0xAD
#define VKEY_VOLUME_DOWN 0xAE
#define VKEY_VOLUME_UP 0xAF
#define VKEY_MEDIA_NEXT_TRACK 0xB0
#define VKEY_MEDIA_PREV_TRACK 0xB1
#define VKEY_MEDIA_STOP 0xB2
#define VKEY_MEDIA_PLAY_PAUSE 0xB3
#define VKEY_LAUNCH_MAIL 0xB4
#define VKEY_LAUNCH_MEDIA_SELECT 0xB5
#define VKEY_LAUNCH_APP1 0xB6
#define VKEY_LAUNCH_APP2 0xB7
/*
* 0xB8 - 0xB9 : reserved
*/
#define VKEY_OEM_1 0xBA // ';:' for US
#define VKEY_OEM_PLUS 0xBB // '+' any country
#define VKEY_OEM_COMMA 0xBC // ',' any country
#define VKEY_OEM_MINUS 0xBD // '-' any country
#define VKEY_OEM_PERIOD 0xBE // '.' any country
#define VKEY_OEM_2 0xBF // '/?' for US
#define VKEY_OEM_3 0xC0 // '`~' for US
/*
* 0xC1 - 0xD7 : reserved
*/
/*
* 0xD8 - 0xDA : unassigned
*/
#define VKEY_OEM_4 0xDB // '[{' for US
#define VKEY_OEM_5 0xDC // '\|' for US
#define VKEY_OEM_6 0xDD // ']}' for US
#define VKEY_OEM_7 0xDE // ''"' for US
#define VKEY_OEM_8 0xDF
/*
* 0xE0 : reserved
*/
/*
* Various extended or enhanced keyboards
*/
#define VKEY_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd
#define VKEY_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd.
#define VKEY_ICO_HELP 0xE3 // Help key on ICO
#define VKEY_ICO_00 0xE4 // 00 key on ICO
#define VKEY_PROCESSKEY 0xE5
#define VKEY_ICO_CLEAR 0xE6
#define VKEY_PACKET 0xE7
/*
* 0xE8 : unassigned
*/
/*
* Nokia/Ericsson definitions
*/
#define VKEY_OEM_RESET 0xE9
#define VKEY_OEM_JUMP 0xEA
#define VKEY_OEM_PA1 0xEB
#define VKEY_OEM_PA2 0xEC
#define VKEY_OEM_PA3 0xED
#define VKEY_OEM_WSCTRL 0xEE
#define VKEY_OEM_CUSEL 0xEF
#define VKEY_OEM_ATTN 0xF0
#define VKEY_OEM_FINISH 0xF1
#define VKEY_OEM_COPY 0xF2
#define VKEY_OEM_AUTO 0xF3
#define VKEY_OEM_ENLW 0xF4
#define VKEY_OEM_BACKTAB 0xF5
#define VKEY_ATTN 0xF6
#define VKEY_CRSEL 0xF7
#define VKEY_EXSEL 0xF8
#define VKEY_EREOF 0xF9
#define VKEY_PLAY 0xFA
#define VKEY_ZOOM 0xFB
#define VKEY_NONAME 0xFC
#define VKEY_PA1 0xFD
#define VKEY_OEM_CLEAR 0xFE
/*
* Friendly names for common keys (US)
*/
#define VKEY_SEMICOLON VKEY_OEM_1
#define VKEY_SLASH VKEY_OEM_2
#define VKEY_GRAVE_ACCENT VKEY_OEM_3
#define VKEY_RIGHT_BRACKET VKEY_OEM_4
#define VKEY_BACKSLASH VKEY_OEM_5
#define VKEY_LEFT_BRACKET VKEY_OEM_6
#define VKEY_APOSTROPHE VKEY_OEM_7
#endif
/***********************************************************************
.\GRAPHICSCOMPOSITION\GUIGRAPHICSEVENTRECEIVER.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Event Model
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSEVENTRECEIVER
namespace vl
{
namespace presentation
{
namespace controls
{
namespace tree
{
class INodeProvider;
}
}
}
}
namespace vl
{
namespace presentation
{
using namespace reflection;
namespace compositions
{
class GuiGraphicsComposition;
/***********************************************************************
Event
***********************************************************************/
class IGuiGraphicsEventHandler : public virtual IDescriptable, public Description
{
public:
class Container
{
public:
Ptr handler;
};
virtual bool IsAttached() = 0;
};
template
class GuiGraphicsEvent : public Object, public Description>
{
public:
typedef void(RawFunctionType)(GuiGraphicsComposition*, T&);
typedef Func FunctionType;
typedef T ArgumentType;
class FunctionHandler : public Object, public IGuiGraphicsEventHandler
{
public:
bool isAttached = true;
FunctionType handler;
FunctionHandler(const FunctionType& _handler)
:handler(_handler)
{
}
bool IsAttached()override
{
return isAttached;
}
void Execute(GuiGraphicsComposition* sender, T& argument)
{
handler(sender, argument);
}
};
protected:
struct HandlerNode
{
Ptr handler;
Ptr next;
};
GuiGraphicsComposition* sender;
Ptr handlers;
bool Attach(Ptr handler)
{
Ptr* currentHandler = &handlers;
while (*currentHandler)
{
if ((*currentHandler)->handler == handler)
{
return false;
}
else
{
currentHandler = &(*currentHandler)->next;
}
}
(*currentHandler) = new HandlerNode;
(*currentHandler)->handler = handler;
return true;
}
public:
GuiGraphicsEvent(GuiGraphicsComposition* _sender=0)
:sender(_sender)
{
}
~GuiGraphicsEvent()
{
}
GuiGraphicsComposition* GetAssociatedComposition()
{
return sender;
}
void SetAssociatedComposition(GuiGraphicsComposition* _sender)
{
sender=_sender;
}
template
Ptr AttachMethod(TClass* receiver, TMethod TClass::* method)
{
auto handler=MakePtr(FunctionType(receiver, method));
Attach(handler);
return handler;
}
Ptr AttachFunction(RawFunctionType* function)
{
auto handler = MakePtr(FunctionType(function));
Attach(handler);
return handler;
}
Ptr AttachFunction(const FunctionType& function)
{
auto handler = MakePtr(function);
Attach(handler);
return handler;
}
template
Ptr AttachLambda(const TLambda& lambda)
{
auto handler = MakePtr(FunctionType(lambda));
Attach(handler);
return handler;
}
bool Detach(Ptr handler)
{
auto typedHandler = handler.Cast();
if (!typedHandler)
{
return false;
}
auto currentHandler=&handlers;
while(*currentHandler)
{
if((*currentHandler)->handler == typedHandler)
{
(*currentHandler)->handler->isAttached = false;
auto next=(*currentHandler)->next;
(*currentHandler)=next;
return true;
}
else
{
currentHandler=&(*currentHandler)->next;
}
}
return false;
}
void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender)
{
auto currentHandler=&handlers;
while(*currentHandler)
{
(*currentHandler)->handler->Execute(newSender?newSender:sender, argument);
currentHandler=&(*currentHandler)->next;
}
}
void Execute(T& argument)
{
ExecuteWithNewSender(argument, 0);
}
void Execute(const T& argument)
{
auto t = argument;
ExecuteWithNewSender(t, 0);
}
};
/***********************************************************************
Predefined Events
***********************************************************************/
/// Notify event arguments.
struct GuiEventArgs : public Object, public AggregatableDescription
{
/// The event raiser composition.
GuiGraphicsComposition* compositionSource;
/// The nearest parent of the event raiser composition that contains an event receiver. If the event raiser composition contains an event receiver, it will be the event raiser composition.
GuiGraphicsComposition* eventSource;
/// Set this field to true will stop the event routing. This is a signal that the event is properly handeled, and the event handler want to override the default behavior.
bool handled;
/// Create an event arguments with and set to null.
GuiEventArgs()
:compositionSource(0)
,eventSource(0)
,handled(false)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiEventArgs(GuiGraphicsComposition* composition)
:compositionSource(composition)
,eventSource(composition)
,handled(false)
{
}
~GuiEventArgs()
{
FinalizeAggregation();
}
};
/// Request event arguments.
struct GuiRequestEventArgs : public GuiEventArgs, public Description
{
/// Set this field to false in event handlers will stop the corresponding action.
bool cancel;
/// Create an event arguments with and set to null.
GuiRequestEventArgs()
:cancel(false)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiRequestEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,cancel(false)
{
}
};
/// Keyboard event arguments.
struct GuiKeyEventArgs : public GuiEventArgs, public NativeWindowKeyInfo, public Description
{
/// Create an event arguments with and set to null.
GuiKeyEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiKeyEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
/// Char input event arguments.
struct GuiCharEventArgs : public GuiEventArgs, public NativeWindowCharInfo, public Description
{
/// Create an event arguments with and set to null.
GuiCharEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiCharEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
/// Mouse event arguments.
struct GuiMouseEventArgs : public GuiEventArgs, public NativeWindowMouseInfo, public Description
{
/// Create an event arguments with and set to null.
GuiMouseEventArgs()
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiMouseEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
{
}
};
typedef GuiGraphicsEvent GuiNotifyEvent;
typedef GuiGraphicsEvent GuiRequestEvent;
typedef GuiGraphicsEvent GuiKeyEvent;
typedef GuiGraphicsEvent GuiCharEvent;
typedef GuiGraphicsEvent GuiMouseEvent;
/***********************************************************************
Predefined Item Events
***********************************************************************/
/// Item event arguments.
struct GuiItemEventArgs : public GuiEventArgs, public Description
{
/// Item index.
vint itemIndex;
GuiItemEventArgs()
:itemIndex(-1)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiItemEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,itemIndex(-1)
{
}
};
/// Item mouse event arguments.
struct GuiItemMouseEventArgs : public GuiMouseEventArgs, public Description
{
/// Item index.
vint itemIndex;
GuiItemMouseEventArgs()
:itemIndex(-1)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiItemMouseEventArgs(GuiGraphicsComposition* composition)
:GuiMouseEventArgs(composition)
,itemIndex(-1)
{
}
};
typedef GuiGraphicsEvent GuiItemNotifyEvent;
typedef GuiGraphicsEvent GuiItemMouseEvent;
/***********************************************************************
Predefined Node Events
***********************************************************************/
/// Node event arguments.
struct GuiNodeEventArgs : public GuiEventArgs, public Description
{
/// Tree node.
controls::tree::INodeProvider* node;
GuiNodeEventArgs()
:node(0)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiNodeEventArgs(GuiGraphicsComposition* composition)
:GuiEventArgs(composition)
,node(0)
{
}
};
/// Node mouse event arguments.
struct GuiNodeMouseEventArgs : public GuiMouseEventArgs, public Description
{
/// Tree node.
controls::tree::INodeProvider* node;
GuiNodeMouseEventArgs()
:node(0)
{
}
/// Create an event arguments with and set to a specified value.
/// The speciied value to set and .
GuiNodeMouseEventArgs(GuiGraphicsComposition* composition)
:GuiMouseEventArgs(composition)
,node(0)
{
}
};
typedef GuiGraphicsEvent GuiNodeNotifyEvent;
typedef GuiGraphicsEvent GuiNodeMouseEvent;
/***********************************************************************
Event Receiver
***********************************************************************/
///
/// Contains all available user input events for a . Almost all events are routed events. Routed events means, not only the activated composition receives the event, all it direct or indirect parents receives the event. The argument(all derives from ) for the event will store the original event raiser composition.
///
class GuiGraphicsEventReceiver : public Object
{
protected:
GuiGraphicsComposition* sender;
public:
GuiGraphicsEventReceiver(GuiGraphicsComposition* _sender);
~GuiGraphicsEventReceiver();
GuiGraphicsComposition* GetAssociatedComposition();
/// Left mouse button down event.
GuiMouseEvent leftButtonDown;
/// Left mouse button up event.
GuiMouseEvent leftButtonUp;
/// Left mouse button double click event.
GuiMouseEvent leftButtonDoubleClick;
/// Middle mouse button down event.
GuiMouseEvent middleButtonDown;
/// Middle mouse button up event.
GuiMouseEvent middleButtonUp;
/// Middle mouse button double click event.
GuiMouseEvent middleButtonDoubleClick;
/// Right mouse button down event.
GuiMouseEvent rightButtonDown;
/// Right mouse button up event.
GuiMouseEvent rightButtonUp;
/// Right mouse button double click event.
GuiMouseEvent rightButtonDoubleClick;
/// Horizontal wheel scrolling event.
GuiMouseEvent horizontalWheel;
/// Vertical wheel scrolling event.
GuiMouseEvent verticalWheel;
/// Mouse move event.
GuiMouseEvent mouseMove;
/// Mouse enter event.
GuiNotifyEvent mouseEnter;
/// Mouse leave event.
GuiNotifyEvent mouseLeave;
/// Preview key event.
GuiKeyEvent previewKey;
/// Key down event.
GuiKeyEvent keyDown;
/// Key up event.
GuiKeyEvent keyUp;
/// System key down event.
GuiKeyEvent systemKeyDown;
/// System key up event.
GuiKeyEvent systemKeyUp;
/// Preview char input event.
GuiCharEvent previewCharInput;
/// Char input event.
GuiCharEvent charInput;
/// Got focus event.
GuiNotifyEvent gotFocus;
/// Lost focus event.
GuiNotifyEvent lostFocus;
/// Caret notify event. This event is raised when a caret graph need to change the visibility state.
GuiNotifyEvent caretNotify;
/// Clipboard notify event. This event is raised when the content in the system clipboard is changed.
GuiNotifyEvent clipboardNotify;
/// Render target changed event. This event is raised when the render target of this composition is changed.
GuiNotifyEvent renderTargetChanged;
};
}
}
/***********************************************************************
Workflow to C++ Codegen Helpers
***********************************************************************/
namespace __vwsn
{
template
struct EventHelper>
{
using Event = presentation::compositions::GuiGraphicsEvent;
using Sender = presentation::compositions::GuiGraphicsComposition;
using IGuiGraphicsEventHandler = presentation::compositions::IGuiGraphicsEventHandler;
using Handler = Func;
class EventHandlerImpl : public Object, public reflection::description::IEventHandler
{
public:
Ptr handler;
EventHandlerImpl(Ptr _handler)
:handler(_handler)
{
}
bool IsAttached()override
{
return handler->IsAttached();
}
};
static Ptr Attach(Event& e, Handler handler)
{
return MakePtr(e.AttachLambda([=](Sender* sender, T& args)
{
handler(sender, &args);
}));
}
static bool Detach(Event& e, Ptr handler)
{
auto impl = handler.Cast();
if (!impl) return false;
return e.Detach(impl->handler);
}
static auto Invoke(Event& e)
{
return [&](Sender* sender, T* args)
{
e.ExecuteWithNewSender(*args, sender);
};
}
};
}
}
#endif
/***********************************************************************
.\GRAPHICSELEMENT\GUIGRAPHICSRESOURCEMANAGER.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Element System and Infrastructure Interfaces
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRESOURCEMANAGER
#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSRESOURCEMANAGER
namespace vl
{
namespace presentation
{
namespace elements
{
/***********************************************************************
Resource Manager
***********************************************************************/
///
/// This is a class for managing grpahics element factories and graphics renderer factories
///
class GuiGraphicsResourceManager : public Object
{
typedef collections::Dictionary> elementFactoryMap;
typedef collections::Dictionary> rendererFactoryMap;
protected:
elementFactoryMap elementFactories;
rendererFactoryMap rendererFactories;
public:
///
/// Create a graphics resource manager without any predefined factories
///
GuiGraphicsResourceManager();
~GuiGraphicsResourceManager();
///
/// Register a using the element type from .
///
/// The instance of the graphics element factory to register.
/// Returns true if this operation succeeded.
virtual bool RegisterElementFactory(IGuiGraphicsElementFactory* factory);
///
/// Register a and bind it to a registered .
///
/// The element type to represent a graphics element factory.
/// The instance of the graphics renderer factory to register.
/// Returns true if this operation succeeded.
virtual bool RegisterRendererFactory(const WString& elementTypeName, IGuiGraphicsRendererFactory* factory);
///
/// Get the instance of a registered that is binded to a specified element type.
///
/// Returns the element factory.
/// The element type to get a corresponding graphics element factory.
virtual IGuiGraphicsElementFactory* GetElementFactory(const WString& elementTypeName);
///
/// Get the instance of a registered that is binded to a specified element type.
///
/// Returns the renderer factory.
/// The element type to get a corresponding graphics renderer factory.
virtual IGuiGraphicsRendererFactory* GetRendererFactory(const WString& elementTypeName);
///
/// Get the instance of a that is binded to an .
///
/// The specified window.
/// Returns the render target.
virtual IGuiGraphicsRenderTarget* GetRenderTarget(INativeWindow* window)=0;
///
/// Recreate the render target for the specified window.
///
/// The specified window.
virtual void RecreateRenderTarget(INativeWindow* window) = 0;
///
/// Resize the render target to fit the current window size.
///
/// The specified window.
virtual void ResizeRenderTarget(INativeWindow* window) = 0;
///
/// Get the renderer awared rich text document layout engine provider object.
///
/// Returns the layout provider.
virtual IGuiGraphicsLayoutProvider* GetLayoutProvider()=0;
};
///
/// Get the current .
///
/// Returns the current resource manager.
extern GuiGraphicsResourceManager* GetGuiGraphicsResourceManager();
///
/// Set the current .
///
/// The resource manager to set.
extern void SetGuiGraphicsResourceManager(GuiGraphicsResourceManager* resourceManager);
///
/// Helper function to register a with a and bind them together.
///
/// Returns true if this operation succeeded.
/// The element factory to register.
/// The renderer factory to register.
extern bool RegisterFactories(IGuiGraphicsElementFactory* elementFactory, IGuiGraphicsRendererFactory* rendererFactory);
/***********************************************************************
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()
{
auto factory = GetGuiGraphicsResourceManager()->GetElementFactory(TElement::GetElementTypeName());
CHECK_ERROR(factory != nullptr, L"This element is not supported by the selected renderer.");
return dynamic_cast(factory->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)\
friend class GuiElementBase;\
public:\
static WString GetElementTypeName()\
{\
return ELEMENT_TYPE_NAME;\
}\
#define DEFINE_GUI_GRAPHICS_RENDERER(TELEMENT, TRENDERER, TTARGET)\
public:\
class Factory : public Object, public IGuiGraphicsRendererFactory\
{\
public:\
IGuiGraphicsRenderer* Create()\
{\
TRENDERER* renderer=new TRENDERER;\
renderer->factory=this;\
renderer->element=0;\
renderer->renderTarget=0;\
return renderer;\
}\
};\
protected:\
IGuiGraphicsRendererFactory* factory;\
TELEMENT* element;\
TTARGET* renderTarget;\
Size minSize;\
public:\
static void Register()\
{\
RegisterFactories(new TELEMENT::Factory, new TRENDERER::Factory);\
}\
IGuiGraphicsRendererFactory* GetFactory()override\
{\
return factory;\
}\
void Initialize(IGuiGraphicsElement* _element)override\
{\
element=dynamic_cast(_element);\
InitializeInternal();\
}\
void Finalize()override\
{\
FinalizeInternal();\
}\
void SetRenderTarget(IGuiGraphicsRenderTarget* _renderTarget)override\
{\
TTARGET* oldRenderTarget=renderTarget;\
renderTarget=dynamic_cast(_renderTarget);\
RenderTargetChangedInternal(oldRenderTarget, renderTarget);\
}\
Size GetMinSize()override\
{\
return minSize;\
}\
#define DEFINE_CACHED_RESOURCE_ALLOCATOR(TKEY, TVALUE)\
public:\
static const vint DeadPackageMax=32;\
struct Package\
{\
TVALUE resource;\
vint counter;\
bool operator==(const Package& package)const{return false;}\
bool operator!=(const Package& package)const{return true;}\
};\
struct DeadPackage\
{\
TKEY key;\
TVALUE value;\
bool operator==(const DeadPackage& package)const{return false;}\
bool operator!=(const DeadPackage& package)const{return true;}\
};\
Dictionary aliveResources;\
List deadResources;\
public:\
TVALUE Create(const TKEY& key)\
{\
vint index=aliveResources.Keys().IndexOf(key);\
if(index!=-1)\
{\
Package package=aliveResources.Values().Get(index);\
package.counter++;\
aliveResources.Set(key, package);\
return package.resource;\
}\
TVALUE resource;\
for(vint i=0;iGet the folder path from a file path. The result folder path is ended with a separator.
/// The folder path.
/// The file path.
extern WString GetFolderPath(const WString& filePath);
/// Get the file name from a file path.
/// The file name.
/// The file path.
extern WString GetFileName(const WString& filePath);
/// Load a text file.
/// Returns true if the operation succeeded.
/// The text file path.
/// The text file content, if succeeded.
extern bool LoadTextFile(const WString& filePath, WString& text);
/// Test is a text a resource url and extract the protocol and the path.
/// Returns true if the text is a resource url.
/// The text.
/// The extracted protocol.
/// The extracted path.
extern bool IsResourceUrl(const WString& text, WString& protocol, WString& path);
extern void HexToBinary(stream::IStream& stream, const WString& hexText);
extern WString BinaryToHex(stream::IStream& stream);
/***********************************************************************
Global String Key
***********************************************************************/
struct GlobalStringKey
{
public:
static GlobalStringKey Empty;
static GlobalStringKey _InferType;
static GlobalStringKey _Set;
static GlobalStringKey _Ref;
static GlobalStringKey _Bind;
static GlobalStringKey _Format;
static GlobalStringKey _Str;
static GlobalStringKey _Eval;
static GlobalStringKey _Uri;
static GlobalStringKey _ControlTemplate;
static GlobalStringKey _ItemTemplate;
private:
vint key = -1;
public:
static vint Compare(GlobalStringKey a, GlobalStringKey b){ return a.key - b.key; }
bool operator==(GlobalStringKey g)const{ return key == g.key; }
bool operator!=(GlobalStringKey g)const{ return key != g.key; }
bool operator<(GlobalStringKey g)const{ return key < g.key; }
bool operator<=(GlobalStringKey g)const{ return key <= g.key; }
bool operator>(GlobalStringKey g)const{ return key > g.key; }
bool operator>=(GlobalStringKey g)const{ return key >= g.key; }
static GlobalStringKey Get(const WString& string);
vint ToKey()const;
WString ToString()const;
};
/***********************************************************************
Resource Image
***********************************************************************/
///
/// Represnets an image to display.
///
class GuiImageData : public Object, public Description
{
protected:
Ptr image;
vint frameIndex;
public:
/// Create an empty image data.
GuiImageData();
/// Create an image data with a specified image and a frame index.
/// The specified image.
/// The specified frame index.
/// The file path of the image. This parameter is only for metadata, it will not affect the content of the image.
GuiImageData(Ptr _image, vint _frameIndex);
~GuiImageData();
/// Get the specified image.
/// The specified image.
Ptr GetImage();
/// Get the specified frame index.
/// The specified frame index.
vint GetFrameIndex();
};
/***********************************************************************
Resource String
***********************************************************************/
/// Represents a text resource.
class GuiTextData : public Object, public Description
{
protected:
WString text;
public:
/// Create an empty text data.
GuiTextData();
/// Create a text data with a specified text.
/// The specified text.
GuiTextData(const WString& _text);
/// Get the specified text.
/// The specified text.
WString GetText();
};
/***********************************************************************
Resource Structure
***********************************************************************/
/// Resource node base.
class GuiResourceNodeBase : public Object, public Description
{
friend class GuiResourceFolder;
protected:
GuiResourceFolder* parent;
WString name;
WString fileContentPath;
WString fileAbsolutePath;
public:
GuiResourceNodeBase();
~GuiResourceNodeBase();
/// Get the containing folder. Returns null means that this is the root resource node.
/// The containing folder.
GuiResourceFolder* GetParent();
/// Get the name of this resource node.
/// The name of this resource node .
const WString& GetName();
/// Get the resource path of this resource node
/// The resource path of this resource node .
WString GetResourcePath();
/// Get the file content path of this resource node. When saving the resource, if the path is not empty, the path will be serialized instead of the content.
/// The file content path of this resource node .
const WString& GetFileContentPath();
/// Get the absolute file content path of this resource node. This path points to an existing file containing the content.
/// The file absolute path of this resource node .
const WString& GetFileAbsolutePath();
/// Set the file content path of this resource node.
/// The file content path of this resource node .
void SetFileContentPath(const WString& content, const WString& absolute);
};
struct GuiResourceLocation
{
WString resourcePath;
WString filePath;
GuiResourceLocation() = default;
GuiResourceLocation(const WString& _resourcePath, const WString& _filePath);
GuiResourceLocation(Ptr node);
bool operator==(const GuiResourceLocation& b)const { return resourcePath == b.resourcePath && filePath == b.filePath; }
bool operator!=(const GuiResourceLocation& b)const { return !(*this == b); }
};
struct GuiResourceTextPos
{
GuiResourceLocation originalLocation;
vint row = parsing::ParsingTextPos::UnknownValue;
vint column = parsing::ParsingTextPos::UnknownValue;
GuiResourceTextPos() = default;
GuiResourceTextPos(GuiResourceLocation location, parsing::ParsingTextPos position);
bool operator==(const GuiResourceTextPos& b)const { return originalLocation == b.originalLocation && row == b.row && column == b.column; }
bool operator!=(const GuiResourceTextPos& b)const { return !(*this == b); }
};
struct GuiResourceError
{
public:
using List = collections::List;
GuiResourceLocation location;
GuiResourceTextPos position;
WString message;
GuiResourceError() = default;
GuiResourceError(GuiResourceTextPos _position, const WString& _message);
GuiResourceError(GuiResourceLocation _location, const WString& _message);
GuiResourceError(GuiResourceLocation _location, GuiResourceTextPos _position, const WString& _message);
bool operator==(const GuiResourceError& b)const { return location == b.location && position == b.position && message == b.message; }
bool operator!=(const GuiResourceError& b)const { return !(*this == b); }
static void Transform(GuiResourceLocation _location, GuiResourceError::List& errors, collections::List>& parsingErrors);
static void Transform(GuiResourceLocation _location, GuiResourceError::List& errors, collections::List>& parsingErrors, parsing::ParsingTextPos offset);
static void Transform(GuiResourceLocation _location, GuiResourceError::List& errors, collections::List>& parsingErrors, GuiResourceTextPos offset);
static void SortAndLog(List& errors, collections::List& output, const WString& workingDirectory = WString::Empty);
};
class DocumentModel;
class GuiResourcePathResolver;
struct GuiResourcePrecompileContext;
struct GuiResourceInitializeContext;
class IGuiResourcePrecompileCallback;
/// Resource item.
class GuiResourceItem : public GuiResourceNodeBase, public Description
{
friend class GuiResourceFolder;
protected:
Ptr content;
WString typeName;
public:
/// Create a resource item.
GuiResourceItem();
~GuiResourceItem();
/// Get the type of this resource item.
/// The type name.
const WString& GetTypeName();
/// Get the contained object for this resource item.
/// The contained object.
Ptr GetContent();
/// Set the containd object for this resource item.
/// The type name of this contained object.
/// The contained object.
void SetContent(const WString& _typeName, Ptr value);
/// Get the contained object as an image.
/// The contained object.
Ptr AsImage();
/// Get the contained object as an xml.
/// The contained object.
Ptr AsXml();
/// Get the contained object as a string.
/// The contained object.
Ptr AsString();
/// Get the contained object as a document model.
/// The contained object.
Ptr AsDocument();
};
/// Resource folder. A resource folder contains many sub folders and sub items.
class GuiResourceFolder : public GuiResourceNodeBase, public Description
{
protected:
typedef collections::Dictionary> ItemMap;
typedef collections::Dictionary> FolderMap;
typedef collections::List> ItemList;
typedef collections::List> FolderList;
struct DelayLoading
{
WString type;
WString workingDirectory;
Ptr preloadResource;
};
typedef collections::List DelayLoadingList;
ItemMap items;
FolderMap folders;
void LoadResourceFolderFromXml(DelayLoadingList& delayLoadings, const WString& containingFolder, Ptr folderXml, GuiResourceError::List& errors);
void SaveResourceFolderToXml(Ptr xmlParent);
void CollectTypeNames(collections::List& typeNames);
void LoadResourceFolderFromBinary(DelayLoadingList& delayLoadings, stream::internal::ContextFreeReader& reader, collections::List& typeNames, GuiResourceError::List& errors);
void SaveResourceFolderToBinary(stream::internal::ContextFreeWriter& writer, collections::List& typeNames);
void PrecompileResourceFolder(GuiResourcePrecompileContext& context, IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors);
void InitializeResourceFolder(GuiResourceInitializeContext& context);
public:
/// Create a resource folder.
GuiResourceFolder();
~GuiResourceFolder();
/// Get all sub items.
/// All sub items.
const ItemList& GetItems();
/// Get the item of a specified name.
/// The item of a specified name.
/// The specified name.
Ptr GetItem(const WString& name);
/// Add a resource item.
/// Returns true if this operation succeeded.
/// The name of this resource item.
/// The resource item.
bool AddItem(const WString& name, Ptr item);
/// Remove a resource item of a specified name.
/// Returns the removed resource item if this operation succeeded.
/// The name of this resource item.
Ptr RemoveItem(const WString& name);
/// Remove all resource item.
void ClearItems();
/// Get all sub folders.
/// All sub folders.
const FolderList& GetFolders();
/// Get the folder of a specified name.
/// The folder of a specified name.
/// The specified name.
Ptr GetFolder(const WString& name);
/// Add a resource folder.
/// Returns true if this operation succeeded.
/// The name of this resource folder.
/// The resource folder.
bool AddFolder(const WString& name, Ptr folder);
/// Remove a resource folder of a specified name.
/// Returns the removed resource folder if this operation succeeded.
/// The name of this resource folder.
Ptr RemoveFolder(const WString& name);
/// Remove all resource folders.
void ClearFolders();
/// Get a contained resource object using a path like "Packages\Application\Name".
/// The containd resource object.
/// The path.
Ptr GetValueByPath(const WString& path);
/// Get a resource folder using a path like "Packages\Application\Name\".
/// The resource folder.
/// The path.
Ptr GetFolderByPath(const WString& path);
/// Create a contained resource object using a path like "Packages\Application\Name".
/// Returns true if this operation succeeded.
/// The path.
/// The type name of this contained object.
/// The contained object.
bool CreateValueByPath(const WString& path, const WString& typeName, Ptr value);
};
/***********************************************************************
Resource
***********************************************************************/
enum class GuiResourceUsage
{
DataOnly,
InstanceClass,
};
/// Resource. A resource is a root resource folder that does not have a name.
class GuiResource : public GuiResourceFolder, public Description
{
protected:
WString workingDirectory;
static void ProcessDelayLoading(Ptr resource, DelayLoadingList& delayLoadings, GuiResourceError::List& errors);
public:
/// Create a resource.
GuiResource();
~GuiResource();
/// Get the directory where the resource is load.
/// The directory.
WString GetWorkingDirectory();
/// Load a resource from an xml file. If the xml file refers other files, they will be loaded as well.
/// The loaded resource.
/// The xml document.
/// The working directory for loading image files.
/// All collected errors during loading a resource.
static Ptr LoadFromXml(Ptr xml, const WString& filePath, const WString& workingDirectory, GuiResourceError::List& errors);
/// Load a resource from an xml file. If the xml file refers other files, they will be loaded as well.
/// The loaded resource.
/// The file path of the xml file.
/// All collected errors during loading a resource.
static Ptr LoadFromXml(const WString& filePath, GuiResourceError::List& errors);
/// Save the resource to xml.
/// The xml.
Ptr SaveToXml();
/// Load a precompiled resource from a stream.
/// The loaded resource.
/// The stream.
/// All collected errors during loading a resource.
static Ptr LoadPrecompiledBinary(stream::IStream& stream, GuiResourceError::List& errors);
/// Load a precompiled resource from a stream. This function will hit an assert if there are errors.
/// The loaded resource.
/// The stream.
static Ptr LoadPrecompiledBinary(stream::IStream& stream);
/// Save the precompiled resource to a stream.
/// The stream.
void SavePrecompiledBinary(stream::IStream& stream);
/// Precompile this resource to improve performance.
/// The resource folder contains all precompiled result. The folder will be added to the resource if there is no error.
/// A callback to receive progress.
/// All collected errors during precompiling a resource.
Ptr Precompile(IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors);
/// Initialize a precompiled resource.
/// In which role an application is initializing this resource.
void Initialize(GuiResourceUsage usage);
/// Get a contained document model using a path like "Packages\Application\Name". If the path does not exists or the type does not match, an exception will be thrown.
/// The containd resource object.
/// The path.
Ptr GetDocumentByPath(const WString& path);
/// Get a contained image using a path like "Packages\Application\Name". If the path does not exists or the type does not match, an exception will be thrown.
/// The containd resource object.
/// The path.
Ptr GetImageByPath(const WString& path);
/// Get a contained xml using a path like "Packages\Application\Name". If the path does not exists or the type does not match, an exception will be thrown.
/// The containd resource object.
/// The path.
Ptr GetXmlByPath(const WString& path);
/// Get a contained string object using a path like "Packages\Application\Name". If the path does not exists or the type does not match, an exception will be thrown.
/// The containd resource object.
/// The path.
WString GetStringByPath(const WString& path);
};
/***********************************************************************
Resource Path Resolver
***********************************************************************/
/// Represents a symbol resolver for loading a resource of a certain protocol.
class IGuiResourcePathResolver : public IDescriptable, public Description
{
public:
/// Load a resource when the descriptor is something like a protocol-prefixed uri.
/// The loaded resource. Returns null if failed to load.
/// The path.
virtual Ptr ResolveResource(const WString& path)=0;
};
/// Represents an factory.
class IGuiResourcePathResolverFactory : public IDescriptable, public Description
{
public:
/// Get the protocol for this resolver.
/// The protocol.
virtual WString GetProtocol()=0;
/// Create an object.
/// The created resolver.
/// The resource context.
/// The working directory context.
virtual Ptr CreateResolver(Ptr resource, const WString& workingDirectory)=0;
};
/// Represents a symbol resolver for loading a resource.
class GuiResourcePathResolver : public Object, public Description
{
typedef collections::Dictionary> ResolverMap;
protected:
ResolverMap resolvers;
Ptr resource;
WString workingDirectory;
public:
/// Create a resolver.
/// The resource context.
/// The working directory context.
GuiResourcePathResolver(Ptr _resource, const WString& _workingDirectory);
~GuiResourcePathResolver();
/// Load a resource when the descriptor is something like a protocol-prefixed uri.
/// The loaded resource. Returns null if failed to load.
/// The protocol.
/// The path.
Ptr ResolveResource(const WString& protocol, const WString& path);
};
/***********************************************************************
Resource Type Resolver
***********************************************************************/
class IGuiResourceTypeResolver_Precompile;
class IGuiResourceTypeResolver_Initialize;
class IGuiResourceTypeResolver_DirectLoadXml;
class IGuiResourceTypeResolver_DirectLoadStream;
class IGuiResourceTypeResolver_IndirectLoad;
/// Represents a symbol type for loading a resource.
class IGuiResourceTypeResolver : public virtual IDescriptable, public Description
{
public:
/// Get the type of the resource that load by this resolver.
/// The type.
virtual WString GetType() = 0;
/// Test is this resource able to serialize in an XML resource or not.
/// Returns true if this resource is able to serialize in an XML resource.
virtual bool XmlSerializable() = 0;
/// Test is this resource able to serialize in a precompiled binary resource or not.
/// Returns true if this resource is able to serialize in a precompiled binary resource.
virtual bool StreamSerializable() = 0;
/// Get the precompiler for the type resolver.
/// Returns null if the type resolve does not support precompiling.
virtual IGuiResourceTypeResolver_Precompile* Precompile(){ return 0; }
/// Get the initializer for the type resolver.
/// Returns null if the type resolve does not support initializing.
virtual IGuiResourceTypeResolver_Initialize* Initialize(){ return 0; }
/// Get the object for convert the resource between xml and object.
/// Returns null if the type resolver does not have this ability.
virtual IGuiResourceTypeResolver_DirectLoadXml* DirectLoadXml(){ return 0; }
/// Get the object for convert the resource between stream and object.
/// Returns null if the type resolver does not have this ability.
virtual IGuiResourceTypeResolver_DirectLoadStream* DirectLoadStream(){ return 0; }
/// Get the object for convert the resource between the preload type and the current type.
/// Returns null if the type resolver does not have this ability.
virtual IGuiResourceTypeResolver_IndirectLoad* IndirectLoad(){ return 0; }
};
/// Provide a context for resource precompiling
struct GuiResourcePrecompileContext
{
typedef collections::Dictionary, Ptr> PropertyMap;
/// Progress callback.
workflow::IWfCompilerCallback* compilerCallback = nullptr;
/// The folder to contain compiled objects.
Ptr targetFolder;
/// The root resource object.
GuiResource* rootResource = nullptr;
/// Indicate the pass index of this precompiling pass.
vint passIndex = -1;
/// The path resolver. This is only for delay load resource.
Ptr resolver;
/// Additional properties for resource item contents
PropertyMap additionalProperties;
};
///
/// Represents a precompiler for resources of a specified type.
/// Current resources that needs precompiling:
/// Workflow:
/// Pass 0: Collect workflow scripts / Compile localized strings / Generate ClassNameRecord
/// Pass 1: Compile workflow scripts
/// Instance:
/// Pass 2: Collect instance types / Compile animation types
/// Pass 3: Compile
/// Pass 4: Generate instance types with event handler functions to TemporaryClass / Compile animation types
/// Pass 5: Compile
/// Pass 6: Generate instance types with everything to InstanceCtor / Compile animation types
/// Pass 7: Compile
///
class IGuiResourceTypeResolver_Precompile : public virtual IDescriptable, public Description
{
public:
enum PassNames
{
Workflow_Collect = 0,
Workflow_Compile = 1,
Workflow_Max = Workflow_Compile,
Instance_CollectInstanceTypes = 2,
Instance_CompileInstanceTypes = 3,
Instance_CollectEventHandlers = 4,
Instance_CompileEventHandlers = 5,
Instance_GenerateInstanceClass = 6,
Instance_CompileInstanceClass = 7,
Instance_Max = Instance_CompileInstanceClass,
};
enum PassSupport
{
NotSupported,
PerResource,
PerPass,
};
/// Get the maximum pass index that the precompiler needs.
/// Returns the maximum pass index. The precompiler doesn't not need to response to every pass.
virtual vint GetMaxPassIndex() = 0;
/// Get how this resolver supports precompiling.
/// The pass index.
/// Returns how this resolver supports precompiling.
virtual PassSupport GetPassSupport(vint passIndex) = 0;
/// Precompile the resource item.
/// The resource to precompile.
/// The context for precompiling.
/// All collected errors during loading a resource.
virtual void PerResourcePrecompile(Ptr resource, GuiResourcePrecompileContext& context, GuiResourceError::List& errors) = 0;
/// Precompile for a pass.
/// The context for precompiling.
/// All collected errors during loading a resource.
virtual void PerPassPrecompile(GuiResourcePrecompileContext& context, GuiResourceError::List& errors) = 0;
};
class IGuiResourcePrecompileCallback : public virtual IDescriptable, public Description
{
public:
virtual workflow::IWfCompilerCallback* GetCompilerCallback() = 0;
virtual void OnPerPass(vint passIndex) = 0;
virtual void OnPerResource(vint passIndex, Ptr resource) = 0;
};
/// Provide a context for resource initializing
struct GuiResourceInitializeContext : GuiResourcePrecompileContext
{
GuiResourceUsage usage;
};
///
/// Represents a precompiler for resources of a specified type.
/// Current resources that needs precompiling:
/// Pass 0: Script (initialize view model scripts)
/// Pass 1: Script (initialize shared scripts)
/// Pass 2: Script (initialize instance scripts)
///
class IGuiResourceTypeResolver_Initialize : public virtual IDescriptable, public Description
{
public:
/// Get the maximum pass index that the initializer needs.
/// Returns the maximum pass index. The initializer doesn't not need to response to every pass.
virtual vint GetMaxPassIndex() = 0;
/// Initialize the resource item.
/// The resource to initializer.
/// The context for initializing.
virtual void Initialize(Ptr resource, GuiResourceInitializeContext& context) = 0;
};
/// Represents a symbol type for loading a resource without a preload type.
class IGuiResourceTypeResolver_DirectLoadXml : public virtual IDescriptable, public Description
{
public:
/// Serialize a resource to an xml element. This function is called if this type resolver does not have a preload type.
/// The serialized xml element.
/// The resource.
virtual Ptr Serialize(Ptr resource, Ptr content) = 0;
/// Load a resource for a type inside an xml element.
/// The resource.
/// The xml element.
/// All collected errors during loading a resource.
virtual Ptr ResolveResource(Ptr resource, Ptr element, GuiResourceError::List& errors) = 0;
/// Load a resource for a type from a file.
/// The resource.
/// The file path.
/// All collected errors during loading a resource.
virtual Ptr ResolveResource(Ptr resource, const WString& path, GuiResourceError::List& errors) = 0;
};
/// Represents a symbol type for loading a resource without a preload type.
class IGuiResourceTypeResolver_DirectLoadStream : public virtual IDescriptable, public Description
{
public:
/// Serialize a precompiled resource to a stream.
/// The resource.
/// The stream.
virtual void SerializePrecompiled(Ptr resource, Ptr content, stream::IStream& stream) = 0;
/// Load a precompiled resource from a stream.
/// The resource.
/// The stream.
/// All collected errors during loading a resource.
virtual Ptr ResolveResourcePrecompiled(Ptr resource, stream::IStream& stream, GuiResourceError::List& errors) = 0;
};
/// Represents a symbol type for loading a resource with a preload type.
class IGuiResourceTypeResolver_IndirectLoad : public virtual IDescriptable, public Description
{
public:
/// Get the preload type to load the resource before loading itself.
/// The preload type. Returns an empty string to indicate that there is no preload type for this resolver.
virtual WString GetPreloadType() = 0;
/// Get the delay load feature for this resolver.
/// Returns true if this type need to delay load.
virtual bool IsDelayLoad() = 0;
/// Serialize a resource to a resource in preload type.
/// The serialized resource.
/// The resource.
virtual Ptr Serialize(Ptr resource, Ptr content) = 0;
/// Load a resource for a type from a resource loaded by the preload type resolver.
/// The resource.
/// The resource.
/// The path resolver. This is only for delay load resource.
/// All collected errors during loading a resource.
virtual Ptr ResolveResource(Ptr resource, Ptr resolver, GuiResourceError::List& errors) = 0;
};
/***********************************************************************
Resource Resolver Manager
***********************************************************************/
/// A resource resolver manager.
class IGuiResourceResolverManager : public IDescriptable, public Description
{
public:
/// Get the for a protocol.
/// The factory.
/// The protocol.
virtual IGuiResourcePathResolverFactory* GetPathResolverFactory(const WString& protocol) = 0;
/// Set the for a protocol.
/// Returns true if this operation succeeded.
/// The factory.
virtual bool SetPathResolverFactory(Ptr factory) = 0;
/// Get the for a resource type.
/// The resolver.
/// The resource type.
virtual IGuiResourceTypeResolver* GetTypeResolver(const WString& type) = 0;
/// Set the for a resource type.
/// Returns true if this operation succeeded.
/// The resolver.
virtual bool SetTypeResolver(Ptr resolver) = 0;
/// Get the maximum precompiling pass index.
/// The maximum precompiling pass index.
virtual vint GetMaxPrecompilePassIndex() = 0;
/// Get the maximum initializing pass index.
/// The maximum initializing pass index.
virtual vint GetMaxInitializePassIndex() = 0;
/// Get names of all per resource resolvers for a pass.
/// The pass index.
/// Names of resolvers
virtual void GetPerResourceResolverNames(vint passIndex, collections::List& names) = 0;
/// Get names of all per pass resolvers for a pass.
/// The pass index.
/// Names of resolvers
virtual void GetPerPassResolverNames(vint passIndex, collections::List& names) = 0;
};
extern IGuiResourceResolverManager* GetResourceResolverManager();
extern vint CopyStream(stream::IStream& inputStream, stream::IStream& outputStream);
extern void CompressStream(stream::IStream& inputStream, stream::IStream& outputStream);
extern void DecompressStream(stream::IStream& inputStream, stream::IStream& outputStream);
extern void DecompressStream(const char** buffer, bool compress, vint rows, vint block, vint remain, stream::IStream& outputStream);
}
}
#endif
/***********************************************************************
.\RESOURCES\GUIDOCUMENT.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Resource
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_RESOURCES_GUIDOCUMENT
#define VCZH_PRESENTATION_RESOURCES_GUIDOCUMENT
namespace vl
{
namespace presentation
{
using namespace reflection;
class DocumentTextRun;
class DocumentStylePropertiesRun;
class DocumentStyleApplicationRun;
class DocumentHyperlinkRun;
class DocumentImageRun;
class DocumentEmbeddedObjectRun;
class DocumentParagraphRun;
/***********************************************************************
Rich Content Document (style)
***********************************************************************/
struct DocumentFontSize
{
double size = 0;
bool relative = false;
DocumentFontSize()
{
}
DocumentFontSize(double _size, bool _relative)
:size(_size)
, relative(_relative)
{
}
static DocumentFontSize Parse(const WString& value);
WString ToString()const;
bool operator==(const DocumentFontSize& value)const
{
return size == value.size && relative == value.relative;
}
bool operator!=(const DocumentFontSize& value)const
{
return size != value.size || relative != value.relative;
}
};
/// Represents a text style.
class DocumentStyleProperties : public Object, public Description
{
public:
/// Font face.
Nullable face;
/// Font size.
Nullable size;
/// Font color.
Nullable color;
/// Font color.
Nullable backgroundColor;
/// Bold.
Nullable bold;
/// Italic.
Nullable italic;
/// Underline.
Nullable underline;
/// Strikeline.
Nullable strikeline;
/// Antialias.
Nullable antialias;
/// Vertical antialias.
Nullable verticalAntialias;
};
/***********************************************************************
Rich Content Document (run)
***********************************************************************/
/// Pepresents a logical run of a rich content document.
class DocumentRun : public Object, public Description
{
public:
/// A visitor interface for .
class IVisitor : public Interface
{
public:
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentTextRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentStylePropertiesRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentStyleApplicationRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentHyperlinkRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentImageRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentEmbeddedObjectRun* run)=0;
/// Visit operation for .
/// The run object.
virtual void Visit(DocumentParagraphRun* run)=0;
};
DocumentRun(){}
/// Accept a and trigger the selected visit operation.
/// The visitor.
virtual void Accept(IVisitor* visitor)=0;
};
/// Pepresents a container run.
class DocumentContainerRun : public DocumentRun, public Description
{
typedef collections::List> RunList;
public:
/// Sub runs.
RunList runs;
};
/// Pepresents a content run.
class DocumentContentRun : public DocumentRun, public Description
{
public:
/// Get representation text.
/// The representation text.
virtual WString GetRepresentationText()=0;
};
//-------------------------------------------------------------------------
/// Pepresents a text run.
class DocumentTextRun : public DocumentContentRun, public Description
{
public:
/// Run text.
WString text;
DocumentTextRun(){}
WString GetRepresentationText()override{return text;}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// Pepresents a inline object run.
class DocumentInlineObjectRun : public DocumentContentRun, public Description
{
public:
/// Size of the inline object.
Size size;
/// Baseline of the inline object.
vint baseline;
DocumentInlineObjectRun():baseline(-1){}
};
/// Pepresents a image run.
class DocumentImageRun : public DocumentInlineObjectRun, public Description
{
public:
static const wchar_t* RepresentationText;
/// The image.
Ptr image;
/// The frame index.
vint frameIndex;
/// The image source string.
WString source;
DocumentImageRun():frameIndex(0){}
WString GetRepresentationText()override{return RepresentationText;}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// Pepresents an embedded object run.
class DocumentEmbeddedObjectRun : public DocumentInlineObjectRun, public Description
{
public:
static const wchar_t* RepresentationText;
/// The object name.
WString name;
WString GetRepresentationText()override{return RepresentationText;}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
//-------------------------------------------------------------------------
/// Pepresents a style properties run.
class DocumentStylePropertiesRun : public DocumentContainerRun, public Description
{
public:
/// Style properties.
Ptr style;
DocumentStylePropertiesRun(){}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// Pepresents a style application run.
class DocumentStyleApplicationRun : public DocumentContainerRun, public Description
{
public:
/// Style name.
WString styleName;
DocumentStyleApplicationRun(){}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// Pepresents a hyperlink text run.
class DocumentHyperlinkRun : public DocumentStyleApplicationRun, public Description
{
public:
class Package : public Object, public Description
{
public:
collections::List> hyperlinks;
vint row = -1;
vint start = -1;
vint end = -1;
};
/// Style name for normal state.
WString normalStyleName;
/// Style name for active state.
WString activeStyleName;
/// The reference of the hyperlink.
WString reference;
DocumentHyperlinkRun(){}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
};
/// Pepresents a paragraph run.
class DocumentParagraphRun : public DocumentContainerRun, public Description
{
public:
/// Paragraph alignment.
Nullable alignment;
DocumentParagraphRun(){}
void Accept(IVisitor* visitor)override{visitor->Visit(this);}
WString GetText(bool skipNonTextContent);
void GetText(stream::TextWriter& writer, bool skipNonTextContent);
};
/***********************************************************************
Rich Content Document (model)
***********************************************************************/
/// Represents a text style.
class DocumentStyle : public Object, public Description
{
public:
/// Parent style name, could be #Default, #Context, #NormalLink, #ActiveLink or style name of others
WString parentStyleName;
/// Properties of this style.
Ptr styles;
/// Resolved properties of this style using parent styles.
Ptr resolvedStyles;
};
/// Represents a rich content document model.
class DocumentModel : public Object, public Description
{
public:
static const wchar_t* DefaultStyleName;
static const wchar_t* SelectionStyleName;
static const wchar_t* ContextStyleName;
static const wchar_t* NormalLinkStyleName;
static const wchar_t* ActiveLinkStyleName;
public:
/// Represents a resolved style.
struct ResolvedStyle
{
/// The style of the text.
FontProperties style;
/// The color of the text.
Color color;
/// The background color of the text.
Color backgroundColor;
ResolvedStyle()
{
}
ResolvedStyle(const FontProperties& _style, Color _color, Color _backgroundColor)
:style(_style)
,color(_color)
,backgroundColor(_backgroundColor)
{
}
};
struct RunRange
{
vint start;
vint end;
};
typedef collections::Dictionary RunRangeMap;
private:
typedef collections::List> ParagraphList;
typedef collections::Dictionary> StyleMap;
public:
/// All paragraphs.
ParagraphList paragraphs;
/// All available styles. These will not be persistant.
StyleMap styles;
DocumentModel();
static void MergeStyle(Ptr style, Ptr parent);
void MergeBaselineStyle(Ptr style, const WString& styleName);
void MergeBaselineStyle(Ptr baselineDocument, const WString& styleName);
void MergeBaselineStyles(Ptr baselineDocument);
void MergeDefaultFont(const FontProperties& defaultFont);
ResolvedStyle GetStyle(Ptr sp, const ResolvedStyle& context);
ResolvedStyle GetStyle(const WString& styleName, const ResolvedStyle& context);
WString GetText(bool skipNonTextContent);
void GetText(stream::TextWriter& writer, bool skipNonTextContent);
bool CheckEditRange(TextPos begin, TextPos end, RunRangeMap& relatedRanges);
Ptr CopyDocument(TextPos begin, TextPos end, bool deepCopy);
Ptr CopyDocument();
bool CutParagraph(TextPos position);
bool CutEditRange(TextPos begin, TextPos end);
bool EditContainer(TextPos begin, TextPos end, const Func& editor);
vint EditRun(TextPos begin, TextPos end, Ptr replaceToModel, bool copy);
vint EditRunNoCopy(TextPos begin, TextPos end, const collections::Array>& runs);
vint EditText(TextPos begin, TextPos end, bool frontSide, const collections::Array