diff --git a/DesktopEditor/doctrenderer/jsgraphics/graphics.h b/DesktopEditor/doctrenderer/jsgraphics/graphics.h index fe519a71ff..6759385cea 100644 --- a/DesktopEditor/doctrenderer/jsgraphics/graphics.h +++ b/DesktopEditor/doctrenderer/jsgraphics/graphics.h @@ -191,87 +191,87 @@ public: void DrawPolygon(const v8::Local& oPath, int lineWidth, double shift); void DrawFootnoteRect(double x, double y, double w, double h); - v8::Local* m_oContext_get() { return m_oContext; } - double m_dWidthMM_get() { return m_dWidthMM; } - double m_dHeightMM_get() { return m_dHeightMM; } - double m_lWidthPix_get() { return m_lWidthPix; } - double m_lHeightPix_get() { return m_lHeightPix; } - double m_dDpiX_get() { return m_dDpiX; } - double m_dDpiY_get() { return m_dDpiY; } - bool m_bIsBreak_get() { return m_bIsBreak; } - v8::Local* m_oPen_get() { return m_oPen; } - bool m_bPenColorInit_get() { return m_bPenColorInit; } - v8::Local* m_oBrush_get() { return m_oBrush; } - bool m_bBrushColorInit_get() { return m_bBrushColorInit; } - v8::Local* m_oFontManager_get() { return m_oFontManager; } - v8::Local* m_oCoordTransform_get() { return m_oCoordTransform; } - v8::Local* m_oBaseTransform_get() { return m_oBaseTransform; } - v8::Local* m_oTransform_get() { return m_oTransform; } - v8::Local* m_oFullTransform_get() { return m_oFullTransform; } + v8::Local* m_oContext_get() { return m_oContext; } + v8::Local* m_oPen_get() { return m_oPen; } + v8::Local* m_oBrush_get() { return m_oBrush; } + v8::Local* m_oFontManager_get() { return m_oFontManager; } + v8::Local* m_oCoordTransform_get() { return m_oCoordTransform; } + v8::Local* m_oBaseTransform_get() { return m_oBaseTransform; } + v8::Local* m_oTransform_get() { return m_oTransform; } + v8::Local* m_oFullTransform_get() { return m_oFullTransform; } v8::Local* m_oInvertFullTransform_get() { return m_oInvertFullTransform; } - v8::Local* ArrayPoints_get() { return ArrayPoints; } - CFont m_oCurFont_get() { return m_oCurFont; } - v8::Local* m_oTextPr_get() { return m_oTextPr; } - v8::Local* m_oGrFonts_get() { return m_oGrFonts; } - v8::Local* m_oLastFont_get() { return m_oLastFont; } + v8::Local* ArrayPoints_get() { return ArrayPoints; } + v8::Local* m_oTextPr_get() { return m_oTextPr; } + v8::Local* m_oGrFonts_get() { return m_oGrFonts; } + v8::Local* m_oLastFont_get() { return m_oLastFont; } + v8::Local* ClipManager_get() { return ClipManager; } + v8::Local* GrState_get() { return GrState; } + v8::Local* TextClipRect_get() { return TextClipRect; } + v8::Local* m_oFontManager2_get() { return m_oFontManager2; } + v8::Local* m_oLastFont2_get() { return m_oLastFont2; } + v8::Local* dash_no_smart_get() { return dash_no_smart; } + double m_dWidthMM_get() { return m_dWidthMM; } + double m_dHeightMM_get() { return m_dHeightMM; } + double m_lWidthPix_get() { return m_lWidthPix; } + double m_lHeightPix_get() { return m_lHeightPix; } + double m_dDpiX_get() { return m_dDpiX; } + double m_dDpiY_get() { return m_dDpiY; } + bool m_bIsBreak_get() { return m_bIsBreak; } + bool m_bPenColorInit_get() { return m_bPenColorInit; } + bool m_bBrushColorInit_get() { return m_bBrushColorInit; } + bool m_bIntegerGrid_get() { return m_bIntegerGrid; } + bool IsThumbnail_get() { return IsThumbnail; } + bool IsDemonstrationMode_get() { return IsDemonstrationMode; } + bool IsClipContext_get() { return IsClipContext; } + bool IsUseFonts2_get() { return IsUseFonts2; } + bool ClearMode_get() { return ClearMode; } + bool IsRetina_get() { return IsRetina; } + CFont m_oCurFont_get() { return m_oCurFont; } CLastFontOriginInfo LastFontOriginInfo_get() { return LastFontOriginInfo; } - bool m_bIntegerGrid_get() { return m_bIntegerGrid; } - v8::Local* ClipManager_get() { return ClipManager; } int TextureFillTransformScaleX_get() { return TextureFillTransformScaleX; } int TextureFillTransformScaleY_get() { return TextureFillTransformScaleY; } - bool IsThumbnail_get() { return IsThumbnail; } - bool IsDemonstrationMode_get() { return IsDemonstrationMode; } - v8::Local* GrState_get() { return GrState; } - int globalAlpha_get() { return globalAlpha; } - v8::Local* TextClipRect_get() { return TextClipRect; } - bool IsClipContext_get() { return IsClipContext; } - bool IsUseFonts2_get() { return IsUseFonts2; } - v8::Local* m_oFontManager2_get() { return m_oFontManager2; } - v8::Local* m_oLastFont2_get() { return m_oLastFont2; } - bool ClearMode_get() { return ClearMode; } - bool IsRetina_get() { return IsRetina; } - v8::Local* dash_no_smart_get() { return dash_no_smart; } + int globalAlpha_get() { return globalAlpha; } - void m_oContext_set(v8::Local* a) { m_oContext = a; } - void m_dWidthMM_set(double a) { m_dWidthMM = a; } - void m_dHeightMM_set(double a) { m_dHeightMM = a; } - void m_lWidthPix_set(double a) { m_lWidthPix = a; } - void m_lHeightPix_set(double a) { m_lHeightPix = a; } - void m_dDpiX_set(double a) { m_dDpiX = a; } - void m_dDpiY_set(double a) { m_dDpiY = a; } - void m_bIsBreak_set(bool a) { m_bIsBreak = a; } - void m_oPen_set(v8::Local* a) { m_oPen = a; } - void m_bPenColorInit_set(bool a) { m_bPenColorInit = a; } - void m_oBrush_set(v8::Local* a) { m_oBrush = a; } - void m_bBrushColorInit_set(bool a) { m_bBrushColorInit = a; } - void m_oFontManager_set(v8::Local* a) { m_oFontManager = a; } - void m_oCoordTransform_set(v8::Local* a) { m_oCoordTransform = a; } - void m_oBaseTransform_set(v8::Local* a) { m_oBaseTransform = a; } - void m_oTransform_set(v8::Local* a) { m_oTransform = a; } - void m_oFullTransform_set(v8::Local* a) { m_oFullTransform = a; } + void m_oContext_set (v8::Local* a) { m_oContext = a; } + void m_oPen_set (v8::Local* a) { m_oPen = a; } + void m_oBrush_set (v8::Local* a) { m_oBrush = a; } + void m_oFontManager_set (v8::Local* a) { m_oFontManager = a; } + void m_oCoordTransform_set (v8::Local* a) { m_oCoordTransform = a; } + void m_oBaseTransform_set (v8::Local* a) { m_oBaseTransform = a; } + void m_oTransform_set (v8::Local* a) { m_oTransform = a; } + void m_oFullTransform_set (v8::Local* a) { m_oFullTransform = a; } void m_oInvertFullTransform_set(v8::Local* a) { m_oInvertFullTransform = a; } - void ArrayPoints_set(v8::Local* a) { ArrayPoints = a; } - void m_oCurFont_set(CFont a) { m_oCurFont = a; } - void m_oTextPr_set(v8::Local* a) { m_oTextPr = a; } - void m_oGrFonts_set(v8::Local* a) { m_oGrFonts = a; } - void m_oLastFont_set(v8::Local* a) { m_oLastFont = a; } + void ArrayPoints_set (v8::Local* a) { ArrayPoints = a; } + void m_oTextPr_set (v8::Local* a) { m_oTextPr = a; } + void m_oGrFonts_set (v8::Local* a) { m_oGrFonts = a; } + void m_oLastFont_set (v8::Local* a) { m_oLastFont = a; } + void ClipManager_set (v8::Local* a) { ClipManager = a; } + void GrState_set (v8::Local* a) { GrState = a; } + void TextClipRect_set (v8::Local* a) { TextClipRect = a; } + void m_oFontManager2_set (v8::Local* a) { m_oFontManager2 = a; } + void m_oLastFont2_set (v8::Local* a) { m_oLastFont2 = a; } + void dash_no_smart_set (v8::Local* a) { dash_no_smart = a; } + void m_dWidthMM_set (double a) { m_dWidthMM = a; } + void m_dHeightMM_set (double a) { m_dHeightMM = a; } + void m_lWidthPix_set (double a) { m_lWidthPix = a; } + void m_lHeightPix_set (double a) { m_lHeightPix = a; } + void m_dDpiX_set (double a) { m_dDpiX = a; } + void m_dDpiY_set (double a) { m_dDpiY = a; } + void m_bIsBreak_set (bool a) { m_bIsBreak = a; } + void m_bPenColorInit_set (bool a) { m_bPenColorInit = a; } + void m_bBrushColorInit_set (bool a) { m_bBrushColorInit = a; } + void m_bIntegerGrid_set (bool a) { m_bIntegerGrid = a; } + void IsThumbnail_set (bool a) { IsThumbnail = a; } + void IsDemonstrationMode_set(bool a) { IsDemonstrationMode = a; } + void IsClipContext_set (bool a) { IsClipContext = a; } + void IsUseFonts2_set (bool a) { IsUseFonts2 = a; } + void ClearMode_set (bool a) { ClearMode = a; } + void IsRetina_set (bool a) { IsRetina = a; } + void m_oCurFont_set (CFont a) { m_oCurFont = a; } void LastFontOriginInfo_set(CLastFontOriginInfo a) { LastFontOriginInfo = a; } - void m_bIntegerGrid_set(bool a) { m_bIntegerGrid = a; } - void ClipManager_set(v8::Local* a) { ClipManager = a; } void TextureFillTransformScaleX_set(int a) { TextureFillTransformScaleX = a; } void TextureFillTransformScaleY_set(int a) { TextureFillTransformScaleY = a; } - void IsThumbnail_set(bool a) { IsThumbnail = a; } - void IsDemonstrationMode_set(bool a) { IsDemonstrationMode = a; } - void GrState_set(v8::Local* a) { GrState = a; } - void globalAlpha_set(int a) { globalAlpha = a; } - void TextClipRect_set(v8::Local* a) { TextClipRect = a; } - void IsClipContext_set(bool a) { IsClipContext = a; } - void IsUseFonts2_set(bool a) { IsUseFonts2 = a; } - void m_oFontManager2_set(v8::Local* a) { m_oFontManager2 = a; } - void m_oLastFont2_set(v8::Local* a) { m_oLastFont2 = a; } - void ClearMode_set(bool a) { ClearMode = a; } - void IsRetina_set(bool a) { IsRetina = a; } - void dash_no_smart_set(v8::Local* a) { dash_no_smart = a; } + void globalAlpha_set (int a) { globalAlpha = a; } }; #endif // CJSGRAPHICS_H diff --git a/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.cpp b/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.cpp index bf9ae8f0fa..072756b5af 100644 --- a/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.cpp +++ b/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.cpp @@ -711,7 +711,9 @@ void DrawFootnoteRect_w (const v8::FunctionCallbackInfo& args) void m_oContext_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oContext_get()); + v8::Local* v = pGraphics->m_oContext_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_dWidthMM_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -751,7 +753,9 @@ void m_bIsBreak_get_w (v8::Local _name, const v8::Pro void m_oPen_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oPen_get()); + v8::Local* v = pGraphics->m_oPen_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_bPenColorInit_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -761,7 +765,9 @@ void m_bPenColorInit_get_w (v8::Local _name, const v8::Pro void m_oBrush_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oBrush_get()); + v8::Local* v = pGraphics->m_oBrush_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_bBrushColorInit_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -771,37 +777,51 @@ void m_bBrushColorInit_get_w (v8::Local _name, const v8::Pro void m_oFontManager_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oFontManager_get()); + v8::Local* v = pGraphics->m_oFontManager_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oCoordTransform_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oCoordTransform_get()); + v8::Local* v = pGraphics->m_oCoordTransform_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oBaseTransform_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oBaseTransform_get()); + v8::Local* v = pGraphics->m_oBaseTransform_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oTransform_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oTransform_get()); + v8::Local* v = pGraphics->m_oTransform_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oFullTransform_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oFullTransform_get()); + v8::Local* v = pGraphics->m_oFullTransform_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oInvertFullTransform_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oInvertFullTransform_get()); + v8::Local* v = pGraphics->m_oInvertFullTransform_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void ArrayPoints_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->ArrayPoints_get()); + v8::Local* v = pGraphics->ArrayPoints_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oCurFont_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -811,17 +831,23 @@ void m_oCurFont_get_w (v8::Local _name, const v8::Pro void m_oTextPr_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oTextPr_get()); + v8::Local* v = pGraphics->m_oTextPr_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oGrFonts_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oGrFonts_get()); + v8::Local* v = pGraphics->m_oGrFonts_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oLastFont_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oLastFont_get()); + v8::Local* v = pGraphics->m_oLastFont_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void LastFontOriginInfo_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -836,7 +862,9 @@ void m_bIntegerGrid_get_w (v8::Local _name, const v8::Pro void ClipManager_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->ClipManager_get()); + v8::Local* v = pGraphics->ClipManager_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void TextureFillTransformScaleX_get_w(v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -861,7 +889,9 @@ void IsDemonstrationMode_get_w (v8::Local _name, const v8::Pro void GrState_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->GrState_get()); + v8::Local* v = pGraphics->GrState_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void globalAlpha_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -871,7 +901,9 @@ void globalAlpha_get_w (v8::Local _name, const v8::Pro void TextClipRect_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->TextClipRect_get()); + v8::Local* v = pGraphics->TextClipRect_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void IsClipContext_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -886,12 +918,16 @@ void IsUseFonts2_get_w (v8::Local _name, const v8::Pro void m_oFontManager2_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oFontManager2_get()); + v8::Local* v = pGraphics->m_oFontManager2_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oLastFont2_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->m_oLastFont2_get()); + v8::Local* v = pGraphics->m_oLastFont2_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void ClearMode_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { @@ -906,7 +942,9 @@ void IsRetina_get_w (v8::Local _name, const v8::Pro void dash_no_smart_get_w (v8::Local _name, const v8::PropertyCallbackInfo& info) { CJSGraphics* pGraphics = unwrap_Graphics(info.Holder()); - info.GetReturnValue().Set(*pGraphics->dash_no_smart_get()); + v8::Local* v = pGraphics->dash_no_smart_get(); + if(v) info.GetReturnValue().Set(*v); + else info.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent())); } void m_oContext_set_w (v8::Local _name, v8::Local value, const v8::PropertyCallbackInfo& info) diff --git a/Test/Applications/V8CanvasContext/examples/test.js b/Test/Applications/V8CanvasContext/examples/test.js index b709fe917a..60d34ed9c0 100644 --- a/Test/Applications/V8CanvasContext/examples/test.js +++ b/Test/Applications/V8CanvasContext/examples/test.js @@ -1,5 +1,2 @@ var g = new CGraphics(); -var u = new User(); -g.init(u, 1.0, 2.0, 3.0, 4.0); -g.put_GlobalAlpha(true, 5); -g.globalAlpha; +g.m_oContext;