public MyMiniAggCanvasRenderElement(RootGraphic rootgfx, int width, int height)
     : base(rootgfx, width, height)
 {
     this.actualImage = new ActualImage(width, height, PixelFarm.Agg.PixelFormat.ARGB32);
     this.gfx2d = Graphics2D.CreateFromImage(actualImage);
     needUpdate = true;
 }
Пример #2
0
 public RenderElementBridgeCssBox(BoxSpec spec,
     RenderElement containerElement,
     RootGraphic rootgfx)
     : base(spec, rootgfx)
 {
     this.containerElement = containerElement;
 }
Пример #3
0
 public EditableTextRun(RootGraphic gfx, char[] copyBuffer, TextSpanStyle style)
     : base(gfx)
 {   //check line break? 
     this.spanStyle = style;
     this.mybuffer = copyBuffer;
     UpdateRunWidth();
 }
Пример #4
0
        public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (primElement == null)
            {
                var renderE = new CustomRenderBox(rootgfx, this.Width, this.Height);
                renderE.HasSpecificHeight = this.HasSpecificHeight;
                renderE.HasSpecificWidth = this.HasSpecificWidth;
                renderE.SetController(this);
                renderE.SetVisible(this.Visible);
#if DEBUG
                //if (dbugBreakMe)
                //{
                //    renderE.dbugBreak = true;
                //}
#endif
                renderE.SetLocation(this.Left, this.Top);
                renderE.BackColor = backColor;
                renderE.HasSpecificSize = true;
                renderE.SetViewport(this.ViewportX, this.ViewportY);
                //------------------------------------------------
                //create visual layer

                int childCount = this.ChildCount;
                for (int m = 0; m < childCount; ++m)
                {
                    renderE.AddChild(this.GetChild(m));
                }
                //set primary render element
                //---------------------------------
                this.primElement = renderE;
            }
            return primElement;
        }
Пример #5
0
        public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (!this.HasReadyRenderElement)
            {
                //first time
                RenderElement baseRenderElement = base.GetPrimaryRenderElement(rootgfx);
                imageBox = new ImageBox(16, 16);
                if (this.isChecked)
                {
                    imageBox.ImageBinder = ResImageList.GetImageBinder(ImageName.CheckBoxChecked);
                }
                else
                {
                    imageBox.ImageBinder = ResImageList.GetImageBinder(ImageName.CheckBoxUnChecked);
                }

                imageBox.MouseDown += (s, e) =>
                {
                    //toggle checked/unchecked
                    this.Checked = !this.Checked;
                };
                this.AddChild(imageBox);
                return baseRenderElement;
            }
            else
            {
                return base.GetPrimaryRenderElement(rootgfx);
            }
        }
Пример #6
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (!this.HasReadyRenderElement)
     {
         //first time
         RenderElement baseRenderElement = base.GetPrimaryRenderElement(rootgfx);
         //1. add place holder first
         placeHolder = new CustomTextRun(rootgfx, this.Width - 4, this.Height - 4);
         placeHolder.Text = placeHolderText;
         placeHolder.SetLocation(1, 1);
         placeHolder.TextColor = Color.FromArgb(180, Color.LightGray);
         baseRenderElement.AddChild(placeHolder);
         //2. textbox 
         myTextBox = new TextBox(this.Width - 4, this.Height - 4, multiline);
         myTextBox.BackgroundColor = Color.Transparent;
         myTextBox.SetLocation(2, 2);
         textEvListener = new Text.TextSurfaceEventListener();
         myTextBox.TextEventListener = textEvListener;
         textEvListener.KeyDown += new EventHandler<Text.TextDomEventArgs>(textEvListener_KeyDown);
         baseRenderElement.AddChild(myTextBox);
         return baseRenderElement;
     }
     else
     {
         return base.GetPrimaryRenderElement(rootgfx);
     }
 }
Пример #7
0
        public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (primElement == null)
            {
                var renderE = new CustomRenderBox(rootgfx, this.Width, this.Height);
                this.SetLocation(this.Left, this.Top);
                renderE.BackColor = backColor;
                renderE.SetController(this);
                renderE.HasSpecificSize = true;
                //------------------------------------------------
                //create visual layer                 

                if (this.landPart != null)
                {
                    renderE.AddChild(this.landPart);
                }
                if (this.floatPart != null)
                {
                }

                //---------------------------------
                primElement = renderE;
            }
            return primElement;
        }
 public TextEditRenderBox(RootGraphic rootgfx,
     int width, int height,
     bool isMultiLine)
     : base(rootgfx, width, height)
 {
     GlobalCaretController.RegisterCaretBlink(rootgfx);            
     myCaret = new CaretRenderElement(rootgfx, 2, 17);
     myCaret.TransparentForAllEvents = true;
     this.MayHasViewport = true;
     this.BackgroundColor = Color.White;// Color.Transparent;
     this.currentSpanStyle = new TextSpanStyle();
     this.currentSpanStyle.FontInfo = rootgfx.DefaultTextEditFontInfo;
     textLayer = new EditableTextFlowLayer(this);
     internalTextLayerController = new InternalTextLayerController(this, textLayer);
     this.isMultiLine = isMultiLine;
     if (isMultiLine)
     {
         textLayer.SetUseDoubleCanvas(false, true);
     }
     else
     {
         textLayer.SetUseDoubleCanvas(true, false);
     }
     this.IsBlockElement = false;
 }
 public GdiPlusCanvasViewport(RootGraphic rootgfx,
     Size viewportSize, int cachedPageNum)
     : base(rootgfx, viewportSize, cachedPageNum)
 {
     quadPages = new QuadPages( cachedPageNum, viewportSize.Width, viewportSize.Height * 2);
     this.CalculateCanvasPages();
 }
 public WrapperCssBoxBase(object controller,
      BoxSpec spec,
      RootGraphic root, CssDisplay display)
     : base(spec, root, display)
 {
     this.SetController(controller);
 }
Пример #11
0
 public CssBoxSvgRoot(Css.BoxSpec spec, RootGraphic rootgfx, SvgElement svgElem)
     : base(spec, rootgfx, Css.CssDisplay.Block)
 {
     SetAsCustomCssBox(this);
     //create svg node 
     this.SvgSpec = svgElem;
     ChangeDisplayType(this, Css.CssDisplay.Block);
 }
 public GraphicsTimerTaskManager(RootGraphic rootgfx, UIPlatform platform)
 {
     this.rootgfx = rootgfx;
     this.uiTimer1 = platform.CreateUITimer();
     //--------------------------------------
     uiTimer1.Interval = fastPlanInterval; //fast task plan
     uiTimer1.Tick += new EventHandler(graphicTimer1_Tick);
     uiTimer1.Enabled = true;
     //--------------------------------------
 }
        public MiniAggCanvasRenderElement(RootGraphic rootgfx, int width, int height)
            : base(rootgfx, width, height)
        {

            this.actualImage = new ActualImage(width, height, PixelFarm.Agg.PixelFormat.ARGB32);
            this.gfx2d = Graphics2D.CreateFromImage(actualImage);
            this.painter = new AggCanvasPainter((ImageGraphics2D)gfx2d);
            needUpdate = true;
            this.BackColor = Color.White;
        }
        public void InitRootGraphics(
            RootGraphic rootgfx,
            ITopWindowEventRoot topWinEventRoot,
            InnerViewportKind innerViewportKind)
        {
            //1.
            this.rootgfx = rootgfx;
            this.topWinEventRoot = topWinEventRoot;
            this.innerViewportKind = innerViewportKind;
            switch (innerViewportKind)
            {
                case InnerViewportKind.GL:
                    {
                        //temp not suppport 

                        throw new NotSupportedException();
                        //PixelFarm.Drawing.DrawingGL.CanvasGLPortal.Start();

                        //var bridge = new OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWinEventRoot);
                        //var view = new OpenGL.GpuOpenGLSurfaceView();
                        //view.Width = 800;
                        //view.Height = 600;
                        ////view.Dock = DockStyle.Fill;
                        //this.Controls.Add(view);
                        ////--------------------------------------- 
                        //view.Bind(bridge); 
                        //this.winBridge = bridge; 
                    }
                    break;
                case InnerViewportKind.Skia:
                    {
                        //skiasharp ***
                        var bridge = new Skia.MyTopWindowBridgeSkia(rootgfx, topWinEventRoot);
                        var view = new CpuSurfaceView();
                        view.Dock = DockStyle.Fill;
                        this.Controls.Add(view);
                        //--------------------------------------- 
                        view.Bind(bridge);
                        this.winBridge = bridge;
                    }
                    break;
                case InnerViewportKind.GdiPlus:
                default:
                    {
                        var bridge = new GdiPlus.MyTopWindowBridgeGdiPlus(rootgfx, topWinEventRoot);
                        var view = new CpuSurfaceView();
                        view.Dock = DockStyle.Fill;
                        this.Controls.Add(view);
                        //--------------------------------------- 
                        view.Bind(bridge);
                        this.winBridge = bridge;
                    }
                    break;
            }
        }
Пример #15
0
 /// <summary>
 /// Init.
 /// </summary>
 /// <param name="parent">the parent box of this box</param>
 /// <param name="controller">the html tag data of this box</param>
 public CssBoxImage(Css.BoxSpec boxSpec,
     RootGraphic rootgfx, ImageBinder binder)
     : base(boxSpec, rootgfx)
 {
     this._imgRun = new CssImageRun();
     this._imgRun.ImageBinder = binder;
     this._imgRun.SetOwner(this);
     var runlist = new List<CssRun>(1);
     runlist.Add(_imgRun);
     CssBox.UnsafeSetContentRuns(this, runlist, false);
 }
Пример #16
0
 bool isClosed;//is this viewport closed
 public CanvasViewport(RootGraphic rootgfx,
     Size viewportSize, int cachedPageNum)
 {
     this.rootGraphics = rootgfx;
     this.topWindowBox = rootgfx.TopWindowRenderBox;
     this.viewportWidth = viewportSize.Width;
     this.viewportHeight = viewportSize.Height;
     canvasSizeChangedHandler = Canvas_SizeChanged;
     viewportX = 0;
     viewportY = 0;
 }
Пример #17
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (renderShape == null)
     {
         renderShape = new GraphicShapeRenderElement(rootgfx, this.Width, this.Height);
         renderShape.SetLocation(this.Left, this.Top);
         renderShape.SetController(this);
         this.SetPrimaryRenderElement(renderShape);
     }
     return this.renderShape;
 }
Пример #18
0
 public SolidTextRun(RootGraphic gfx, char c, TextSpanStyle style)
     : base(gfx)
 {
     mybuffer = new char[] { c };
     if (c == '\n')
     {
         this.IsLineBreak = true;
     }
     //check line break?
     UpdateRunWidth();
 }
Пример #19
0
 internal static void RegisterCaretBlink(RootGraphic root)
 {
     if (!root.CaretHandleRegistered)
     {
         root.CaretHandleRegistered = true;
         task = root.SubscribeGraphicsIntervalTask(
             caretBlinkTask,
             TaskIntervalPlan.CaretBlink,
             20,
             tickHandler);
     }
 }
Пример #20
0
 public GraphicsTimerTask(RootGraphic rootgfx,
     TaskIntervalPlan planName,
     object uniqueName,
     int internvalMs,
     EventHandler<GraphicsTimerTaskEventArgs> tickHandler)
 {
     this.PlanName = planName;
     this.uniqueName = uniqueName;
     this.enable = false;
     this.rootgfx = rootgfx;
     this.tickHandler = tickHandler;
 }
Пример #21
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (this.myTextRun == null)
     {
         var trun = new CustomTextRun(rootgfx, this.Width, this.Height);
         trun.SetLocation(this.Left, this.Top);
         trun.TextColor = this.textColor;
         trun.Text = this.Text;
         this.myTextRun = trun;
     }
     //-----------
     return myTextRun;
 }
Пример #22
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (imgRenderBox == null)
     {
         var renderBox = new CustomImageRenderBox(rootgfx, this.Width, this.Height);
         renderBox.SetLocation(this.Left, this.Top);
         renderBox.ImageBinder = imageBinder;
         renderBox.SetController(this);
         renderBox.BackColor = this.BackColor;
         SetPrimaryRenderElement(renderBox);
         this.imgRenderBox = renderBox;
     }
     return this.imgRenderBox;
 }
Пример #23
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (canvasRenderElement == null)
     {
         var canvas = new MiniAggCanvasRenderElement(rootgfx, this.Width, this.Height);
         canvas.HasSpecificHeight = this.HasSpecificHeight;
         canvas.HasSpecificWidth = this.HasSpecificWidth;
         canvas.SetLocation(this.Left, this.Top);
         canvas.Painter.StrokeWidth = 1;
         canvas.Painter.StrokeColor = PixelFarm.Drawing.Color.Black;
         this.canvasRenderElement = canvas;
         canvas.SetController(this);
     }
     return canvasRenderElement;
 }
Пример #24
0
        public SkiaCanvasViewport(RootGraphic rootgfx,
            Size viewportSize, int cachedPageNum)
            : base(rootgfx, viewportSize, cachedPageNum)
        {

            this.CalculateCanvasPages();
            mySkCanvas = new PixelFarm.Drawing.Skia.MySkiaCanvas(0, 0, 0, 0, internalSizeW, internalSizwH);
            //TODO: review performance here
            //review how to move data from unmanged(skia) to unmanaged(hdc's bitmap)
            tmpBmp = new System.Drawing.Bitmap(internalSizeW, internalSizwH);
            var bmpdata = tmpBmp.LockBits(
                new System.Drawing.Rectangle(0, 0, internalSizeW, internalSizwH),
                 System.Drawing.Imaging.ImageLockMode.ReadOnly, tmpBmp.PixelFormat);
            tmpBuffer = new byte[bmpdata.Stride * bmpdata.Height];
            tmpBmp.UnlockBits(bmpdata);
        }
Пример #25
0
 public SolidTextRun(RootGraphic gfx, string str, TextSpanStyle style)
     : base(gfx)
 {
     if (str != null && str.Length > 0)
     {
         mybuffer = str.ToCharArray();
         if (mybuffer.Length == 1 && mybuffer[0] == '\n')
         {
             this.IsLineBreak = true;
         }
         UpdateRunWidth();
     }
     else
     {
         throw new Exception("string must be null or zero length");
     }
 }
Пример #26
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     if (mainBox == null)
     {
         switch (this.ScrollBarType)
         {
             case ScrollBarType.Horizontal:
                 {
                     CreateHScrollbarContent(rootgfx);
                 }
                 break;
             default:
                 {
                     CreateVScrollbarContent(rootgfx);
                 }
                 break;
         }
     }
     return mainBox;
 }
Пример #27
0
        public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (!this.HasReadyRenderElement)
            {
                var renderE = base.GetPrimaryRenderElement(rootgfx);
                if (contentBox != null)
                {
                    renderE.AddChild(contentBox);
                }

                //------------------------------------------------------

                renderE.AddChild(boxLeftTop);
                renderE.AddChild(boxRightTop);
                renderE.AddChild(boxLeftBottom);
                renderE.AddChild(boxRightBottom);
                //------------------------------------------------------
            }
            return base.GetPrimaryRenderElement(rootgfx);
        }
Пример #28
0
        public CssBox(BoxSpec spec, RootGraphic rootgfx)
        {
            this.rootgfx = rootgfx;
            this._aa_boxes = new CssBoxCollection();
#if DEBUG
            //if (this.__aa_dbugId == 6)
            //{
            //}
            if (!spec.IsFreezed)
            {
                //must be freezed
                throw new NotSupportedException();
            }
#endif

            //assign spec 
            this._myspec = spec;
            EvaluateSpec(spec);
            ChangeDisplayType(this, _myspec.CssDisplay);
        }
Пример #29
0
        public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (primElement == null)
            {
                var renderE = new CustomRenderBox(rootgfx, this.Width, this.Height);
                renderE.SetLocation(this.Left, this.Top);
                renderE.BackColor = backColor;
                renderE.SetController(this);
                renderE.HasSpecificSize = true;
                //------------------------------------------------
                //create visual layer 
                int n = this.uiList.Count;
                for (int m = 0; m < n; ++m)
                {
                    renderE.AddChild(uiList.GetElement(m));
                }

                //---------------------------------
                primElement = renderE;
            }
            return primElement;
        }
Пример #30
0
        public CssBox(BoxSpec spec, RootGraphic rootgfx, CssDisplay displayType)
        {
            this.rootgfx = rootgfx;
            this._aa_boxes = new CssBoxCollection();
#if DEBUG
            //if (this.__aa_dbugId == 6)
            //{
            //}
            if (!spec.IsFreezed)
            {
                //must be freezed 
                throw new NotSupportedException();
            }
#endif

            //assign spec             
            this._boxCompactFlags |= BoxFlags.DONT_CHANGE_DISPLAY_TYPE;
            this._cssDisplay = displayType;
            this._myspec = spec;
            //---------------------------- 
            EvaluateSpec(spec);
            ChangeDisplayType(this, _myspec.CssDisplay);
        }
        public void InitRootGraphics(
            RootGraphic rootgfx,
            ITopWindowEventRoot topWinEventRoot,
            InnerViewportKind innerViewportKind)
        {
            //create a proper bridge****

            this.rootgfx           = rootgfx;
            this.topWinEventRoot   = topWinEventRoot;
            this.innerViewportKind = innerViewportKind;
            switch (innerViewportKind)
            {
            case InnerViewportKind.GL:
            {
#if GL_ENABLE
                //temp not suppport
                //TODO: review here
                //PixelFarm.Drawing.DrawingGL.CanvasGLPortal.Start();

                var bridge = new OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWinEventRoot);
                var view   = new OpenGL.GpuOpenGLSurfaceView();

                view.Width        = 1200;
                view.Height       = 1200;
                openGLSurfaceView = view;
                //view.Dock = DockStyle.Fill;
                //this.Controls.Add(view);
                this.panel1.Visible = true;
                this.panel1.Controls.Add(view);

                //---------------------------------------
                view.Bind(bridge);
                this.winBridge = bridge;
                //---------------------------------------
                view.SetGLPaintHandler(null);
                hh1 = view.Handle;         //force real window handle creation
                view.MakeCurrent();


                int max = Math.Max(view.Width, view.Height);
                _glsx = PixelFarm.Drawing.GLES2.GLES2Platform.CreateGLRenderSurface(max, max, view.Width, view.Height);
                //---------------
                //canvas2d.FlipY = true;//
                //---------------
                canvasPainter = new GLPainter(_glsx);

                //canvasPainter.SmoothingMode = PixelFarm.Drawing.SmoothingMode.HighQuality;
                //----------------------
                //1. win gdi based
                //var printer = new WinGdiFontPrinter(canvas2d, view.Width, view.Height);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //2. raw vxs
                //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //3. agg texture based font texture
                //var printer = new AggTextSpanPrinter(canvasPainter, 400, 50);
                //printer.HintTechnique = Typography.Rendering.HintTechnique.TrueTypeInstruction_VerticalOnly;
                //printer.UseSubPixelRendering = true;
                //canvasPainter.TextPrinter = printer;
                //3
                var printer = new GLBitmapGlyphTextPrinter(canvasPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);
                canvasPainter.TextPrinter = printer;

                //
                var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(canvasPainter, _glsx.CanvasWidth, _glsx.CanvasHeight);
                bridge.SetCanvas(myGLCanvas1);
#endif
            }
            break;

#if __SKIA__
            case InnerViewportKind.Skia:
            {
                //skiasharp ***

                var bridge = new Skia.MyTopWindowBridgeSkia(rootgfx, topWinEventRoot);
                var view   = new CpuSurfaceView();
                view.Dock = DockStyle.Fill;
                this.Controls.Add(view);
                //---------------------------------------
                view.Bind(bridge);
                this.winBridge = bridge;
            }
            break;
#endif
            case InnerViewportKind.GdiPlus:
            default:
            {
                var bridge = new GdiPlus.MyTopWindowBridgeGdiPlus(rootgfx, topWinEventRoot);
                var view   = new CpuSurfaceView();
                view.Dock = DockStyle.Fill;
                this.Controls.Add(view);
                //---------------------------------------
                view.Bind(bridge);
                this.winBridge = bridge;
            }
            break;
            }
        }
Пример #32
0
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     throw new NotImplementedException();
 }
Пример #33
0
        //----------
        //for test
#if DEBUG
        //void dbugTest01()
        //{
        //    //canvas.Orientation = CanvasOrientation.LeftTop;
        //    canvas.ClearSurface(Color.White);

        //    canvas.FillRectangle(Color.Red, 50, 50, 100, 100);

        //    dbugGLOffsetCanvasOrigin(50, 50);
        //    //simulate draw content
        //    canvas.FillRectangle(Color.Gray, 10, 10, 80, 80);
        //    dbugGLOffsetCanvasOrigin(-50, -50);
        //}
        //void dbugGLSetCanvasOrigin(int x, int y)
        //{
        //    canvas.SetCanvasOrigin(x, y);
        //    //int properW = Math.Min(canvas.Width, canvas.Height);
        //    ////int max = 600;
        //    ////init
        //    ////---------------------------------
        //    ////-1 temp fix split scanline in some screen
        //    ////OpenTK.Graphics.OpenGL.GL.Viewport(x, y, properW, properW - 1);
        //    //////---------------------------------
        //    //OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
        //    //OpenTK.Graphics.OpenGL.GL.LoadIdentity();
        //    //OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, properW, 0, 0.0, 100);

        //    ////switch (this.orientation)
        //    ////{
        //    ////    case Drawing.CanvasOrientation.LeftTop:
        //    ////        {
        //    ////            OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, properW, 0, 0.0, 100);
        //    ////        } break;
        //    ////    default:
        //    ////        {
        //    ////            OpenTK.Graphics.OpenGL.GL.Ortho(0, properW, 0, properW, 0.0, 100);
        //    ////        } break;
        //    ////}
        //    //OpenTK.Graphics.OpenGL.GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
        //    //OpenTK.Graphics.OpenGL.GL.LoadIdentity();
        //    //OpenTK.Graphics.OpenGL.GL.Translate(x, y, 0);
        //}
        //void dbugGLOffsetCanvasOrigin(int dx, int dy)
        //{
        //    dbugGLSetCanvasOrigin(canvas.CanvasOriginX + dx, canvas.CanvasOriginY + dy);
        //}
#endif
        //-------

        public void PaintMe()
        {
            if (isClosed)
            {
                return;
            }
            //---------------------------------------------

            //canvas.Orientation = CanvasOrientation.LeftTop;
            //Test01();
            //return;
            //Test01();
            //return;
            //canvas.ClearSurface(Color.White);
            //canvas.FillRectangle(Color.Red, 20, 20, 200, 400);
            // return;
            //----------------------------------
            //gl paint here
            if (canvas == null)
            {
                return;
            }
            canvas.Clear(Color.White);
            ////test draw rect
            //canvas.StrokeColor = PixelFarm.Drawing.Color.Blue;
            //canvas.DrawRectangle(Color.Blue, 20, 20, 200, 200);
            ////------------------------



            if (this.IsClosed)
            {
                return;
            }
            //------------------------------------

            this.rootGraphics.PrepareRender();
            //---------------
            this.rootGraphics.IsInRenderPhase = true;
#if DEBUG
            this.rootGraphics.dbug_rootDrawingMsg.Clear();
            this.rootGraphics.dbug_drawLevel = 0;
#endif
            UpdateAllArea(this.canvas, this.topWindowBox);

            this.rootGraphics.IsInRenderPhase = false;
#if DEBUG
            RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot;
            if (visualroot.dbug_RecordDrawingChain)
            {
                List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs;
                outputMsgs.Clear();
                outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]"));
                visualroot.dbug_DumpRootDrawingMsg(outputMsgs);
                dbugOutputWindow.dbug_InvokeVisualRootDrawMsg();
                debug_render_to_output_count++;
            }


            if (dbugHelper01.dbugVE_HighlightMe != null)
            {
                dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect());
            }
#endif
        }
Пример #34
0
 public VgBridgeRenderElement(RootGraphic rootGfx, int width, int height)
     : base(rootGfx, width, height)
 {
     this.MayHasChild = true;
 }
Пример #35
0
 public void SetRootGraphics(RootGraphic rootgfx)
 {
     this.rootgfx = rootgfx;
 }
Пример #36
0
 public MyTopWindowBridgeGdiPlus(RootGraphic root, ITopWindowEventRoot topWinEventRoot)
     : base(root, topWinEventRoot)
 {
 }
Пример #37
0
        Stack <UIFocusEventArgs> _focusEventStack = new Stack <UIFocusEventArgs>(); //resuable

        public TopWindowBridgeWinNeutral(RootGraphic rootGraphic, ITopWindowEventRoot topWinEventRoot)
        {
            _topWinEventRoot = topWinEventRoot;
            _rootGraphic     = rootGraphic;
        }
Пример #38
0
 public CssIsolateBox(BoxSpec spec, RootGraphic rootgfx)
     : base(spec, new CssBoxRootGfxBridge(rootgfx))
 {
 }
Пример #39
0
 public GraphicShapeRenderElement(RootGraphic root, int w, int h)
     : base(root, w, h)
 {
 }
Пример #40
0
 public MyTopWindowBridgeOpenGL(RootGraphic root, ITopWindowEventRoot topWinEventRoot)
     : base(root, topWinEventRoot)
 {
 }
 public OpenGLCanvasViewport(RootGraphic root,
                             Size viewportSize, int cachedPageNum)
     : base(root, viewportSize, cachedPageNum)
 {
 }
Пример #42
0
        void IEventPortal.PortalMouseDown(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
            dbugMsgChainVersion = 1;
            int local_msgVersion = 1;
#endif
            HitChain hitPointChain = GetFreeHitChain();
#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseDown;
#endif
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);
            if (hitPointChain.Count > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------
                var prevMouseDownElement          = e.PreviousMouseDown;
                IUIEventListener currentMouseDown = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseDown(e);
                    //*****
                    currentMouseDown = e.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseDown = null; //clear
                    ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                    {
                        if (listener.BypassAllMouseEvents)
                        {
                            return(false);
                        }


                        currentMouseDown = listener;
                        listener.ListenMouseDown(e);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e.CancelBubbling;
                        if (prevMouseDownElement != null &&
                            prevMouseDownElement != listener)
                        {
                            prevMouseDownElement.ListenLostMouseFocus(e);
                            prevMouseDownElement = null;//clear
                        }
                        //-------------------------------------------------------
                        //retrun true to stop this loop (no further bubble up)
                        //return false to bubble this to upper control
                        return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }

                if (prevMouseDownElement != currentMouseDown &&
                    prevMouseDownElement != null)
                {
                    prevMouseDownElement.ListenLostMouseFocus(e);
                    prevMouseDownElement = null;
                }
            }
            //---------------------------------------------------------------

#if DEBUG
            RootGraphic visualroot = this.dbugRootGraphics;
            if (visualroot.dbug_RecordHitChain)
            {
                visualroot.dbug_rootHitChainMsg.Clear();
                HitInfo hitInfo;
                for (int tt = hitPointChain.Count - 1; tt >= 0; --tt)
                {
                    hitInfo = hitPointChain.GetHitInfo(tt);
                    RenderElement ve = hitInfo.HitElemAsRenderElement;
                    if (ve != null)
                    {
                        ve.dbug_WriteOwnerLayerInfo(visualroot, tt);
                        ve.dbug_WriteOwnerLineInfo(visualroot, tt);
                        string hit_info = new string('.', tt) + " [" + tt + "] "
                                          + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") "
                                          + ve.dbug_FullElementDescription();
                        visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info));
                    }
                }
            }
#endif

            SwapHitChain(hitPointChain);

            e.StopPropagation();
#if DEBUG
            if (local_msgVersion != dbugMsgChainVersion)
            {
                return;
            }
            visualroot.dbugHitTracker.Write("stop-mousedown");
            visualroot.dbugHitTracker.Play = false;
#endif
        }
Пример #43
0
 public override void ResetRootGraphics(RootGraphic rootgfx)
 {
     DirectSetRootGraphics(this, rootgfx);
 }
Пример #44
0
 public override void ResetRootGraphics(RootGraphic rootgfx)
 {
 }
Пример #45
0
 public LineRenderElement(RootGraphic rootGfx, int width, int height)
     : base(rootGfx, width, height)
 {
 }
Пример #46
0
 public HtmlRenderBox(RootGraphic rootgfx,
                      int width, int height)
     : base(rootgfx, width, height)
 {
 }
Пример #47
0
 public EditableRun(RootGraphic gfx)
     : base(gfx, 10, 10)
 {
 }
Пример #48
0
 public TopWindowBridge(RootGraphic rootGraphic, ITopWindowEventRoot topWinEventRoot)
 {
     this.topWinEventRoot = topWinEventRoot;
     this.rootGraphic     = rootGraphic;
 }
Пример #49
0
 //
 public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
 {
     _hasPrimRenderE = true;
     return(_groundBox.GetPrimaryRenderElement(rootgfx));
 }
Пример #50
0
        internal static CssBox CreateBridgeBox(IFonts iFonts, LayoutFarm.RenderElement containerElement, RootGraphic rootgfx)
        {
            var spec = new BoxSpec();

            spec.CssDisplay = CssDisplay.Block;
            spec.Freeze();
            var box = new RenderElementBridgeCssBox(spec, containerElement, rootgfx);

            //------------------------------------
            box.ReEvaluateFont(iFonts, 10);
            //------------------------------------
            return(box);
        }
Пример #51
0
 public override void ResetRootGraphics(RootGraphic rootgfx)
 {
     //change root graphics after create
     DirectSetRootGraphics(this, rootgfx);
 }
Пример #52
0
        protected override void OnRequestScrollView(CssBox box)
        {
            RootGraphic rootgfx = (RootGraphic)box.RootGfx;

            rootgfx.AddToElementUpdateQueue(box);
        }
        public void InitRootGraphics(
            RootGraphic rootgfx,
            ITopWindowEventRoot topWinEventRoot,
            InnerViewportKind innerViewportKind)
        {
            //create a proper bridge****

            _rootgfx           = rootgfx;
            _topWinEventRoot   = topWinEventRoot;
            _innerViewportKind = innerViewportKind;
            switch (innerViewportKind)
            {
            case InnerViewportKind.GdiPlusOnGLES:
            case InnerViewportKind.AggOnGLES:
            case InnerViewportKind.GLES:
            {
                //temp not suppport

                var bridge = new OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWinEventRoot);
                var view   = new OpenGL.GpuOpenGLSurfaceView();
                view.Width  = rootgfx.Width;
                view.Height = rootgfx.Height;
                _gpuSurfaceViewUserControl = view;
                this.Controls.Add(view);
                //---------------------------------------
                view.Bind(bridge);
                _winBridge = bridge;
                //---------------------------------------
                IntPtr hh1 = view.Handle;         //force real window handle creation
                try
                {
                    view.MakeCurrent();
                }
                catch (Exception ex)
                {
                }
                int max = Math.Max(view.Width, view.Height);

                _pcx = GLPainterContext.Create(max, max, view.Width, view.Height, true);

                _glPainter = new GLPainter();
                _glPainter.BindToPainterContext(_pcx);
                _glPainter.TextPrinter = new GLBitmapGlyphTextPrinter(_glPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);

                //canvasPainter.SmoothingMode = PixelFarm.Drawing.SmoothingMode.HighQuality;
                //----------------------
                //1. win gdi based
                //var printer = new WinGdiFontPrinter(canvas2d, view.Width, view.Height);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //2. raw vxs
                //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //3. agg texture based font texture
                //_glPainter.TextPrinter = new CpuBlitTextSpanPrinter2(_glPainter, 400, 50, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);

                //3
                var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(_glPainter);
                //{
                //in mixed mode
                //GDI+ on GLES, Agg on GLES we provide a software rendering layer too
                PixelFarm.Drawing.DrawBoard cpuDrawBoard = null;        // CreateSoftwareDrawBoard(view.Width, view.Height, innerViewportKind);
                myGLCanvas1.SetCpuBlitDrawBoardCreator(() => cpuDrawBoard ?? (cpuDrawBoard = CreateSoftwareDrawBoard(view.Width, view.Height, innerViewportKind)));
                //}

                bridge.SetCanvas(myGLCanvas1);
            }
            break;


            case InnerViewportKind.PureAgg:
            {
                var bridge = new GdiPlus.MyTopWindowBridgeAgg(rootgfx, topWinEventRoot);         //bridge to agg
                var view   = new CpuSurfaceView();
                view.Dock = DockStyle.Fill;
                this.Controls.Add(view);
                //---------------------------------------
                view.Bind(bridge);
                _winBridge = bridge;
            }
            break;

            case InnerViewportKind.GdiPlus:
            default:
            {
                var bridge = new GdiPlus.MyTopWindowBridgeGdiPlus(rootgfx, topWinEventRoot);         //bridge with GDI+
                var view   = new CpuSurfaceView();
                view.Size = new System.Drawing.Size(rootgfx.Width, rootgfx.Height);
                this.Controls.Add(view);
                //---------------------------------------
                view.Bind(bridge);
                _winBridge = bridge;
            }
            break;
#if __SKIA__
                //case InnerViewportKind.Skia:
                //    {
                //        //skiasharp ***

                //        var bridge = new Skia.MyTopWindowBridgeSkia(rootgfx, topWinEventRoot);
                //        var view = new CpuSurfaceView();
                //        view.Dock = DockStyle.Fill;
                //        this.Controls.Add(view);
                //        //---------------------------------------
                //        view.Bind(bridge);
                //        _winBridge = bridge;

                //    }
                //    break;
#endif
            }
        }
Пример #54
0
        //-------

        public void PaintMe()
        {
            if (_isClosed || _drawboard == null)
            {
                return;
            }

            RootGraphic backup = GlobalRootGraphic.CurrentRootGfx;

            GlobalRootGraphic.CurrentRootGfx = _rootgfx;
            _rootgfx.PrepareRender();
            //---------------
            _rootgfx.BeginRenderPhase();
#if DEBUG
            _rootgfx.dbug_rootDrawingMsg.Clear();
            _rootgfx.dbug_drawLevel = 0;
#endif

            if (_rootgfx.HasAccumInvalidateRect)
            {
                //evaluate
                _gfxUpdatePlan.SetUpdatePlanForFlushAccum();
                int j = _gfxUpdatePlan.UpdateListCount;

                if (j > 0)
                {
                    //special mode
                    UpdateArea u = GetFreeUpdateArea();
                    for (int i = 0; i < j; ++i)
                    {
                        _gfxUpdatePlan.SetCurrentUpdate(i);

                        u.CurrentRect = _gfxUpdatePlan.AccumUpdateArea;

                        _drawboard.SetClipRect(u.CurrentRect); //**

                        UpdateInvalidateArea(_drawboard, _topWindowBox, u);

                        _gfxUpdatePlan.ClearCurrentUpdate();


#if DEBUG
                        if (RenderElement.WaitForStartRenderElement)
                        {
                            //should not occur
                            throw new System.NotSupportedException();
                        }
#endif
                    }

                    _gfxUpdatePlan.ResetUpdatePlan();
                    ReleaseUpdateArea(u);
                }
                else
                {
                    //default mode
                    _drawboard.SetClipRect(_rootgfx.AccumInvalidateRect);
                    UpdateArea u = GetFreeUpdateArea();

                    //TODO: review clear bg again
                    _drawboard.Clear(Color.White);
                    u.CurrentRect = _rootgfx.AccumInvalidateRect;

                    UpdateInvalidateArea(_drawboard, _topWindowBox, u);

                    _gfxUpdatePlan.ResetUpdatePlan();
                    ReleaseUpdateArea(u);
                }
                //-----------
            }
            _rootgfx.EndRenderPhase();
            GlobalRootGraphic.CurrentRootGfx = backup;
#if DEBUG
            RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot;
            if (visualroot.dbug_RecordDrawingChain)
            {
                List <dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs;
                outputMsgs.Clear();
                outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]"));
                visualroot.dbug_DumpRootDrawingMsg(outputMsgs);
                dbugOutputWindow.dbug_InvokeVisualRootDrawMsg();
                debug_render_to_output_count++;
            }
            if (dbugHelper01.dbugVE_HighlightMe != null)
            {
                dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect());
            }
#endif
        }
Пример #55
0
 public CssIsolateBox(BoxSpec spec, RootGraphic rootgfx)
     : base(spec, rootgfx)
 {
 }
Пример #56
0
 public CustomRenderBox(RootGraphic rootgfx, int width, int height)
     : base(rootgfx, width, height)
 {
     this.BackColor = Color.LightGray;
 }
Пример #57
0
 public BackBoardRenderElement(RootGraphic rootgfx, int width, int height)
     : base(rootgfx, width, height)
 {
 }
Пример #58
0
 public OpenGLCanvasViewport(RootGraphic root, Size viewportSize)
     : base(root, viewportSize)
 {
     _gfxUpdatePlan = new GfxUpdatePlan(root);
 }
Пример #59
0
 public CustomTextRun(RootGraphic rootgfx, int width, int height)
     : base(rootgfx, width, height)
 {
     _font = rootgfx.DefaultTextEditFontInfo;
 }
Пример #60
0
 public abstract RenderElement GetPrimaryRenderElement(RootGraphic rootgfx);