Inheritance: Xwt.Widget
Esempio n. 1
0
		public ScrollbarSample ()
		{
			WidthRequest = 300;
			HeightRequest = 300;

			canvas = new Canvas ();
			label = new Label ("Use the scrollbars\nto move this label");
			canvas.AddChild (label);

			Add (canvas, 0, 0, hexpand:true, vexpand:true);

			vscroll = new VScrollbar () {
				LowerValue = 0,
				UpperValue = 300,
				PageIncrement = 10,
				PageSize = 50,
				StepIncrement = 1
			};
			Add (vscroll, 1, 0, vexpand:true);
			
			hscroll = new HScrollbar () {
				LowerValue = 0,
				UpperValue = 300,
				PageIncrement = 10,
				PageSize = 50,
				StepIncrement = 1
			};
			Add (hscroll, 0, 1, hexpand:true);

			vscroll.ValueChanged += HandleValueChanged;
			hscroll.ValueChanged += HandleValueChanged;
		}
Esempio n. 2
0
            void IXwtRender.CreateForWidgetContext(IRenderer renderer, IRenderOwner rendererimpl, Canvas widget)
            {
                Xwt.Canvas   view = null;
                IntPtr       hwnd;
                EventHandler sizefunc = null;

                if (Xwt.Toolkit.CurrentEngine.Type == ToolkitType.Wpf)
                {
                    hwnd = GetHwnd(widget.ParentWindow);
                }
                else
                {
                    hwnd = GetHwndFromGtk(Xwt.Toolkit.CurrentEngine.GetSafeBackend(widget));

                    if (hwnd == GetHwndFromGtk(widget.ParentWindow))
                    {
                        view = new global::Xwt.Canvas()
                        {
                            ExpandHorizontal = true, ExpandVertical = true, HorizontalPlacement = WidgetPlacement.Fill, VerticalPlacement = WidgetPlacement.Fill, MinWidth = 1, MinHeight = 1, BackgroundColor = Xwt.Drawing.Colors.Black
                        };
                        (widget as global::Xwt.Canvas).AddChild(view);
                        var viewbackend = Xwt.Toolkit.CurrentEngine.GetSafeBackend(view) as Xwt.Backends.ICanvasBackend;
                        var gtkview     = viewbackend.GetType().GetPropertyValue(viewbackend, "Widget");
                        gtkview.GetType().SetPropertyValue(gtkview, "DoubleBuffered", false);

                        hwnd = GetHwndFromGtk(viewbackend);
                        Debug.Assert(hwnd != GetHwndFromGtk(widget.ParentWindow));
                        sizefunc = new EventHandler((s, a) => (widget as global::Xwt.Canvas).SetChildBounds(view, new Rectangle(Point.Zero, widget.Size)));
                        (widget as global::Xwt.Canvas).BoundsChanged += sizefunc;
                        sizefunc(null, EventArgs.Empty);
                    }
                }
                IWindowInfo      WindowInfo = null;
                IGraphicsContext gfxcontext = null;

                WindowInfo = Utilities.CreateWindowsWindowInfo(hwnd);
                gfxcontext = new global::OpenTK.Graphics.GraphicsContext(new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8), WindowInfo, null, 3, 2, GraphicsContextFlags.Default);

                views[widget] = new viewinfo(WindowInfo, gfxcontext)
                {
                    viewcanvas = view, sizefunc = sizefunc
                };

                gfxcontext.MakeCurrent(WindowInfo);
                gfxcontext.LoadAll();

                int major, minor;

                GL.GetInteger(GetPName.MajorVersion, out major);
                GL.GetInteger(GetPName.MinorVersion, out minor);

                Console.WriteLine($"OpenGL {major}.{minor}");

                gfxcontext.MakeCurrent(null);
            }
Esempio n. 3
0
        public GridView()
        {
            this.minWidthPerChild = 0;
            this.minHeightPerChild = 0;

            this.canvas = new Canvas();
            this.Content = canvas;

            canvas.HorizontalPlacement = WidgetPlacement.Center;
            canvas.VerticalPlacement = WidgetPlacement.Center;

            canvas.BoundsChanged += (object sender, EventArgs e) => RecalculatePosition();
        }
Esempio n. 4
0
        internal OpenTKRenderer(FrameFactory owner, IXwtRender xwtrender, Xwt.Canvas window, IRenderOwner renderer, size videosize)
        {
            //    OpenTKRenderer.usecnt = 1;
            this.owner     = owner;
            this.Xwt       = xwtrender;
            this.videosize = videosize;
            this.window    = window;
            this.renderer  = renderer;

            this.viewsize         = window.Size;
            window.BoundsChanged += viewsizechanged;

            this.actionthread = new Thread(run)
            {
                Name = "opentk"
            };
            this.actionthread.Start();

            var _this = this;

            this.Xwt.CreateForWidgetContext(this, this.renderer, window);

            // Invoke(() =>
            //  {
            this.Lock(false);
            try
            {
                try
                {
                    //        GL.GetInternalformat(TextureTarget.Texture2D, SizedInternalFormat.Rgba8, InternalFormatParameter..TEXTUREIMAGEFORMAT, 1, &preferred_format).

                    this.vertices1 = new vertices(_vertices);
                    this.vertices2 = new vertices(_vertices2);

                    /*   GL.GenBuffers(1, out buf_vertices2); // Generate 1 buffer
                     * GL.BindBuffer(BufferTarget.ArrayBuffer, buf_vertices2);
                     * GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
                     * GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float));
                     * GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * vertices2.Length, vertices2, BufferUsageHint.StaticDraw);
                     * GL.EnableVertexAttribArray(0);
                     * GL.EnableVertexAttribArray(1);
                     *
                     * GL.GenBuffers(1, out buf_vertices3); // Generate 1 buffer
                     * GL.BindBuffer(BufferTarget.ArrayBuffer, buf_vertices3);
                     * GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
                     * GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float));
                     * GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * vertices3.Length, vertices3, BufferUsageHint.StaticDraw);
                     * GL.EnableVertexAttribArray(0);
                     * GL.EnableVertexAttribArray(1);*/

                    //     GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

                    /*    this.presentshader = new shader(shadervertex, shaderfragment, vertices1);
                     *  GL.UseProgram(this.presentshader);
                     *  var pos = GL.GetUniformLocation(this.presentshader, "tex");
                     *  GL.Uniform1(pos, 0);
                     */
                    /*             this.combineshader = new shader(combineshadervertex, combineshaderfragment, vertices1);
                     *
                     *           GL.UseProgram(combineshader);
                     *           var pos = GL.GetUniformLocation(this.combineshader, "tex");
                     *           GL.Uniform1(pos, 0);
                     *           pos = GL.GetUniformLocation(this.combineshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);
                     *
                     *           this.deinterlaceblendshader = new shader(combineshadervertex, blendshaderfragment, vertices1);
                     *           GL.UseProgram(deinterlaceblendshader);
                     *           pos = GL.GetUniformLocation(this.deinterlaceblendshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);
                     *
                     *           this.deinterlacesplitshader = new shader(combineshadervertex, splitshaderfragment, vertices1);
                     *
                     *           GL.UseProgram(deinterlacesplitshader);
                     *           pos = GL.GetUniformLocation(this.deinterlacesplitshader, "vpHeight");
                     *           GL.Uniform1(pos, (float)videosize.height);*/
                }
                catch (Exception e)
                {
                    //         Log.LogException(e);
                    Dispose(true);
                    GC.SuppressFinalize(this);
                    throw;
                }
            }
            finally
            {
                Unlock(false);
            }
            //   });
        }