예제 #1
0
    public static int GetHeight(this Gdk.Window gdkWindow)
    {
        int w, h;

        gdkWindow.GetSize(out w, out h);
        return(h);
    }
예제 #2
0
    public static int GetWidth(this Gdk.Window gdkWindow)
    {
        int w, h;

        gdkWindow.GetSize(out w, out h);
        return(w);
    }
예제 #3
0
        private static CSWindow CreateWin32(Gdk.Window gdkWindow)
        {
            NativeGdkWin.Gdk_window_ensure_native(gdkWindow.Handle);
            IntPtr windowHandle = NativeGdkWin.GetWindowHandle(gdkWindow.Handle);
            int    width;
            int    heigth;

            gdkWindow.GetSize(out width, out heigth);
            return(new CSWindow(windowHandle.ToInt32(), width, heigth, WindowHelp.GetStartupPath()));
        }
예제 #4
0
        public override void Clear(Color c)
        {
            Gdk.GC g = new Gdk.GC(window);
            g.RgbFgColor = GdkColor(c);
            g.RgbBgColor = GdkColor(c);
            int Width;
            int Height;

            window.GetSize(out Width, out Height);
            window.DrawRectangle(g, true, 0, 0, Width, Height);
        }
예제 #5
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            int height;
            int width;

            Gdk.Window win = evnt.Window;

            win.GetSize(out width, out height);
            win.Resize((int)(frames / pixelRatio), height);
            win.GetSize(out width, out height);

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                this.CairoDraw(evnt, height, width);
            }
            else
            {
                this.GdkDraw(evnt, height, width);
            }
            return(base.OnExposeEvent(evnt));
        }
예제 #6
0
파일: MainWindow.cs 프로젝트: cr3a70r/DGLE2
    private static Gdk.Rectangle GetRect(Gdk.Window window)
    {
        Gdk.Rectangle rect = Gdk.Rectangle.Zero;
        int           vx, vy;

        window.GetPosition(out vx, out vy);
        rect.X = vx;
        rect.Y = vy;
        window.GetSize(out vx, out vy);
        rect.Width  = vx;
        rect.Height = vy;
        return(rect);
    }
예제 #7
0
        void DrawTimeNodes(Gdk.Window win)
        {
            bool hasSelectedTimeNode = false;

            using (Cairo.Context g = Gdk.CairoHelper.Create(win)) {
                int height;
                int width;

                win.Resize((int)(frames / pixelRatio), Allocation.Height);
                win.GetSize(out width, out height);

                g.Operator = Operator.Over;

                foreach (T tn in list)
                {
                    if (filter != null && !filter.IsVisible(tn))
                    {
                        continue;
                    }

                    if (!tn.Equals(selected))
                    {
                        Cairo.Color borderColor = new Cairo.Color(color.R + 0.1, color.G + 0.1, color.B + 0.1, 1);
                        CairoUtils.DrawRoundedRectangle(g, tn.StartFrame / pixelRatio, 3,
                                                        tn.TotalFrames / pixelRatio, height - 6,
                                                        SECTION_HEIGHT / 7, color, borderColor);
                    }
                    else
                    {
                        hasSelectedTimeNode = true;
                    }
                }
                //Then we draw the selected TimeNode over the others
                if (hasSelectedTimeNode)
                {
                    Cairo.Color borderColor = new Cairo.Color(0, 0, 0, 1);
                    CairoUtils.DrawRoundedRectangle(g, selected.StartFrame / pixelRatio, 3,
                                                    selected.TotalFrames / pixelRatio, height - 6,
                                                    SECTION_HEIGHT / 7, color, borderColor);
                    if (selected.HasDrawings)
                    {
                        g.MoveTo(selected.KeyFrame / pixelRatio, 3);
                        g.LineTo(selected.KeyFrame / pixelRatio, SECTION_HEIGHT - 3);
                        g.StrokePreserve();
                    }
                }
                DrawLines(win, g, height, width);
            }
        }
예제 #8
0
        //Take screen shot of desktop
        public Gtk.Image GetScreenshot()
        {
            int width  = 0;
            int height = 0;

            Gdk.Window root = Gdk.Global.DefaultRootWindow;
            root.GetSize(out width, out height);
            Pixbuf screenshot = new Pixbuf(Gdk.Colorspace.Rgb, false, 8, width, height).GetFromDrawable(root, Gdk.Colormap.System, 0, 0, 0, 0, width, height);

            Gtk.Image image = new Gtk.Image(screenshot);
            screenshot.Save(originalImageName, "jpeg");
            mainImage   = image;
            imageWidth  = screenshot.Width;
            imageHeight = screenshot.Height;
            return(image);
        }
예제 #9
0
파일: GtkEngine.cs 프로젝트: lanicon/xwt-1
        public override object RenderWidget(Widget widget)
        {
            var w = ((WidgetBackend)widget.GetBackend()).Widget;

            Gdk.Window win = w.GdkWindow;
            if (win != null && win.IsViewable)
            {
                int ww, wh;
                win.GetSize(out ww, out wh);
                if (ww == w.Allocation.Width && wh == w.Allocation.Height)
                {
                    return(new GtkImage(win.ToPixbuf(0, 0, w.Allocation.Width, w.Allocation.Height)));
                }
                return(new GtkImage(win.ToPixbuf(w.Allocation.X, w.Allocation.Y, w.Allocation.Width, w.Allocation.Height)));
            }
            throw new InvalidOperationException();
        }
        public void Position(Gdk.Window eventWindow)
        {
            int x, y;
            int widget_x, widget_y;
            int widget_height, widget_width;

            Realize();

            Gdk.Window widget_window = eventWindow;
            Gdk.Screen widget_screen = widget_window.Screen;

            Gtk.Requisition popup_req;

            widget_window.GetOrigin(out widget_x, out widget_y);
            widget_window.GetSize(out widget_width, out widget_height);

            popup_req = Requisition;

            if (widget_x + widget_width > widget_screen.Width)
            {
                x = widget_screen.Width - popup_req.Width;
            }
            else if (widget_x + widget_width - popup_req.Width < 0)
            {
                x = 0;
            }
            else
            {
                x = widget_x + widget_width - popup_req.Width;
            }

            if (widget_y + widget_height + popup_req.Height > widget_screen.Height)
            {
                y = widget_screen.Height - popup_req.Height;
            }
            else if (widget_y + widget_height < 0)
            {
                y = 0;
            }
            else
            {
                y = widget_y + widget_height;
            }

            Move(x, y);
        }
예제 #11
0
        void DrawTicks(Gdk.Window win, Gdk.GC gc, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
        {
            int rwidth, rheight;

            win.GetSize(out rwidth, out rheight);

            Pango.Layout layout = null;

            if (showLabels)
            {
                layout = new Pango.Layout(this.PangoContext);
                layout.FontDescription = Pango.FontDescription.FromString("Tahoma 8");
            }

            bool isX   = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
            bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;

            double start = GetStart(ad);
            double end   = GetEnd(ad);

            e.Init(GetOrigin(ad));

            while (e.CurrentValue > start)
            {
                e.MovePrevious();
            }

            int lastPosLabel;
            int lastPos;
            int lastTw = 0;

            if (isX)
            {
                lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
                lastPos      = left - minTickStep * 2;
            }
            else
            {
                lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
                lastPos      = top + height + minTickStep * 2;
            }

            for ( ; e.CurrentValue <= end; e.MoveNext())
            {
                int px, py;
                int tw = 0, th = 0;
                int tick = tickSize;

                GetPoint(e.CurrentValue, e.CurrentValue, out px, out py);

                if (showLabels)
                {
                    layout.SetMarkup(e.CurrentLabel);
                    layout.GetPixelSize(out tw, out th);
                }

                if (isX)
                {
                    if (Math.Abs((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
                    {
                        continue;
                    }
                    lastPos = px;

                    bool labelFits = false;
                    if ((Math.Abs(px - lastPosLabel) - (tw / 2) - (lastTw / 2)) >= MinLabelGapX)
                    {
                        lastPosLabel = px;
                        lastTw       = tw;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, px - (tw / 2), top - AreaBorderWidth - th, layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, px, top, px, top + tick);
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, px - (tw / 2), top + height + AreaBorderWidth, layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, px, top + height, px, top + height - tick);
                    }
                }
                else
                {
                    if (Math.Abs((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
                    {
                        continue;
                    }
                    lastPos = py;

                    bool labelFits = false;
                    if ((Math.Abs(py - lastPosLabel) - (th / 2) - (lastTw / 2)) >= MinLabelGapY)
                    {
                        lastPosLabel = py;
                        lastTw       = th;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, left + width + AreaBorderWidth + 1, py - (th / 2), layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, left + width, py, left + width - tick, py);
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, left - AreaBorderWidth - tw - 1, py - (th / 2), layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, left, py, left + tick, py);
                    }
                }
            }
        }
예제 #12
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            Gdk.Window win = GdkWindow;
            int        rwidth, rheight;

            Cairo.Context ctx = CairoHelper.Create(win);

            win.GetSize(out rwidth, out rheight);

            if (autoStartY || autoEndY)
            {
                double nstartY = double.MaxValue;
                double nendY   = double.MinValue;
                GetValueRange(AxisDimension.Y, out nstartY, out nendY);

                if (!autoStartY)
                {
                    nstartY = startY;
                }
                if (!autoEndY)
                {
                    nendY = endY;
                }
                if (nendY < nstartY)
                {
                    nendY = nstartY;
                }

                if (nstartY != startY || nendY != endY)
                {
                    yrangeChanged = true;
                    startY        = nstartY;
                    endY          = nendY;
                }
            }

            if (autoStartX || autoEndX)
            {
                double nstartX = double.MaxValue;
                double nendX   = double.MinValue;
                GetValueRange(AxisDimension.X, out nstartX, out nendX);

                if (!autoStartX)
                {
                    nstartX = startX;
                }
                if (!autoEndX)
                {
                    nendX = endX;
                }
                if (nendX < nstartX)
                {
                    nendX = nstartX;
                }

                if (nstartX != startX || nendX != endX)
                {
                    xrangeChanged = true;
                    startX        = nstartX;
                    endX          = nendX;
                }
            }

            if (yrangeChanged)
            {
                FixOrigins();
                int right = rwidth - 2 - AreaBorderWidth;
                left          = AreaBorderWidth;
                left         += MeasureAxisSize(AxisPosition.Left) + 1;
                right        -= MeasureAxisSize(AxisPosition.Right) + 1;
                yrangeChanged = false;
                width         = right - left + 1;
                if (width <= 0)
                {
                    width = 1;
                }
            }

            if (xrangeChanged)
            {
                FixOrigins();
                int bottom = rheight - 2 - AreaBorderWidth;
                top     = AreaBorderWidth;
                bottom -= MeasureAxisSize(AxisPosition.Bottom);
                top    += MeasureAxisSize(AxisPosition.Top);

                // Make room for cursor handles
                foreach (ChartCursor cursor in cursors)
                {
                    if (cursor.Dimension == AxisDimension.X && top - AreaBorderWidth < cursor.HandleSize)
                    {
                        top = cursor.HandleSize + AreaBorderWidth;
                    }
                }

                xrangeChanged = false;
                height        = bottom - top + 1;
                if (height <= 0)
                {
                    height = 1;
                }
            }

            if (AutoScaleMargin != 0 && height > 0)
            {
                double margin = (double)AutoScaleMargin * (endY - startY) / (double)height;
                if (autoStartY)
                {
                    startY -= margin;
                }
                if (autoEndY)
                {
                    endY += margin;
                }
            }

//			Console.WriteLine ("L:" + left + " T:" + top + " W:" + width + " H:" + height);

            // Draw the background

            if (backgroundDisplay == BackgroundDisplay.Gradient)
            {
                ctx.Rectangle(left - 1, top - 1, width + 2, height + 2);
                using (var pat = new Cairo.LinearGradient(left - 1, top - 1, left - 1, height + 2)) {
                    pat.AddColorStop(0, backroundColor);
                    Cairo.Color endc = new Cairo.Color(1, 1, 1);
                    pat.AddColorStop(1, endc);
                    ctx.SetSource(pat);
                    ctx.Fill();
                }
            }
            else
            {
                ctx.Rectangle(left - 1, top - 1, width + 2, height + 2);
                ctx.SetSourceColor(backroundColor);
                ctx.Fill();
            }
//			win.DrawRectangle (Style.WhiteGC, true, left - 1, top - 1, width + 2, height + 2);
            win.DrawRectangle(Style.BlackGC, false, left - AreaBorderWidth, top - AreaBorderWidth, width + AreaBorderWidth * 2, height + AreaBorderWidth * 2);

            // Draw selected area

            if (enableSelection)
            {
                int sx, sy, ex, ey;
                GetPoint(selectionStart.Value, selectionStart.Value, out sx, out sy);
                GetPoint(selectionEnd.Value, selectionEnd.Value, out ex, out ey);
                if (sx > ex)
                {
                    int tmp = sx; sx = ex; ex = tmp;
                }
                Gdk.GC sgc = new Gdk.GC(GdkWindow);
                sgc.RgbFgColor = new Color(225, 225, 225);
                win.DrawRectangle(sgc, true, sx, top, ex - sx, height + 1);
            }

            // Draw axes

            Gdk.GC gc = Style.BlackGC;

            foreach (Axis ax in axis)
            {
                DrawAxis(win, gc, ax);
            }

            // Draw values
            foreach (Serie serie in series)
            {
                if (serie.Visible)
                {
                    DrawSerie(ctx, serie);
                }
            }

            // Draw cursors
            foreach (ChartCursor cursor in cursors)
            {
                DrawCursor(cursor);
            }

            // Draw cursor labels
            foreach (ChartCursor cursor in cursors)
            {
                if (cursor.ShowValueLabel)
                {
                    DrawCursorLabel(cursor);
                }
            }

            ((IDisposable)ctx).Dispose();
            return(true);
        }
예제 #13
0
        private bool DrawPreview()
        {
            Console.WriteLine(OldRefreshRate + "--------" + RefreshRate);

            if (OldRefreshRate == RefreshRate)
            {
                if (!moving_mouse)
                {
                    Console.WriteLine("Drawing with ref rate..." + RefreshRate);

                    int width  = 0;
                    int height = 0;

                    if (!BtnPressed)
                    {
                        try{
                            root = Gdk.Global.DefaultRootWindow;

                            // get its width and height
                            root.GetSize(out width, out height);
                            // create a new pixbuf from the root window
                            //try{
                            //LliureXMiniScreen.Core.getCore().win.Hide();
                            screenshot = Gdk.Pixbuf.FromDrawable(root, root.Colormap, 0, 0, 0, 0, width, height);

                            int miniscreen_size_x, miniscreen_size_y;                                   // dimensions de la minipantalla
                            int px, py, win_px, win_py;
                            if (LliureXMiniScreen.Core.getCore().win != null)
                            {
                                LliureXMiniScreen.Core.getCore().win.GetPosition(out win_px, out win_py);
                                MiniScreen.GetSizeRequest(out miniscreen_size_x, out miniscreen_size_y);
                                px = MiniScreenPosition * (width - miniscreen_size_x);
                                py = height - miniscreen_size_y;

                                Console.WriteLine("Dibuixe en: (" + px + "," + py + ") una finestra de " + miniscreen_size_x + "x" + miniscreen_size_y);
                                if (px != win_px || py != win_py)
                                {
                                    LliureXMiniScreen.Core.getCore().win.Move(px, py);
                                }

                                // Amaguem la minipantallla

                                // PATCH
                                //Gdk.Pixbuf HiddenMiniScreen=new Pixbuf("/usr/share/icons/LliureX-Accessibility/llx-miniscreen-hide.png", miniscreen_size_x, miniscreen_size_y);
                                HiddenMiniScreen = new Pixbuf(InitScreenshot, px, py, MiniScreenWidth, MiniScreenHeight);

                                // END PATCH

                                Console.WriteLine("->" + HiddenMiniScreen.Width + " " + HiddenMiniScreen.Height);
                                HiddenMiniScreen = HiddenMiniScreen.ScaleSimple(miniscreen_size_x, miniscreen_size_y, InterpType.Bilinear);
                                HiddenMiniScreen.CopyArea(0, 0, miniscreen_size_x, miniscreen_size_y,
                                                          screenshot, px, py);
                            }

                            //LliureXMiniScreen.Core.getCore().win.Activate();
                            //	LliureXMiniScreen.Core.getCore().win.Show();

                            /*} catch (Exception exc){
                             *      Console.WriteLine("Excepció...: "+exc);
                             * }*/

                            //Gdk.Pixbuf screenshot = Gdk.Pixbuf.FromDrawable(root, root.Colormap, 0,0, 0,0, width, height);
                            //
                            // Cal inserir una imatge al screenshot per poder ocultar la minifinestra a la captura!!!
                            //
                            screenshot = screenshot.ScaleSimple(this.MiniScreenWidth, this.MiniScreenHeight, InterpType.Bilinear);
                        }catch (Exception exc) {
                            Console.WriteLine("Excepció...: " + exc);
                        }
                    }

                    // Creem la imatge per emmagatzemar el pixbuf

                    Gtk.Image MyImage = new Gtk.Image();
                    MyImage.Pixbuf = screenshot;

                    // Agafem les dimensions de la finestra
                    Gdk.GC gc = ((Gtk.DrawingArea)MiniScreen).Style.TextGC(Gtk.StateType.Normal);

                    MiniScreen.GdkWindow.DrawPixbuf(gc, MyImage.Pixbuf, 0, 0, 0, 0, this.MiniScreenWidth, this.MiniScreenHeight, Gdk.RgbDither.Max, 0, 0);

                    Cairo.Context context = Gdk.CairoHelper.Create(MiniScreen.GdkWindow);

                    if (BtnPressed)
                    {
                        double r = double.Parse((PathColor.Red).ToString()) / 65535;
                        double g = double.Parse((PathColor.Green).ToString()) / 65535;
                        double b = double.Parse((PathColor.Blue).ToString()) / 65535;

                        context.Color = new Cairo.Color(r, g, b);

                        try{
                            if (Llista_Punts.Count > 1)
                            {
                                context.LineWidth = 3;
                                context.MoveTo(Llista_Punts[0].X, Llista_Punts[0].Y);
                                foreach (Gdk.Point p in Llista_Punts)
                                {
                                    context.LineTo(p.X, p.Y);
                                    context.MoveTo(p.X, p.Y);
                                }
                            }
                            context.Stroke();
                            context.FillPreserve();
                        }

                        catch (Exception ex) {
                            Console.WriteLine("Exception: " + ex.Message);
                        }
                    }

                    ((IDisposable)context.Target).Dispose();
                    ((IDisposable)context).Dispose();


                    return(true);
                }
            }
            else
            {
                //if(RefreshRate!=OldRefreshRate){
                Console.WriteLine("Change refresg rate!!!");
                OldRefreshRate = RefreshRate;
                return(false);
                //}
            }
            return(false);
        }
예제 #14
0
        AccelGroup grup = new AccelGroup(); // Necessari per als items de menú amb imatges


        public void Init()
        {
            /* Creem el fitxer amb la llista dels diospositius d'entrada */
            ExecuteCommandSync("/bin/bash", "getInputMouse");

            /* Inicialitza variables i objectes */
            RefreshRate    = 500;
            OldRefreshRate = 500;
            // Timer que es dispara cada X ms per refrescar la finestra
            GLib.Timeout.Add(RefreshRate, DrawPreview);             // Amb més sembla que se satura si punxem dins la finestra...
            // Propietats de la pantalla
            MiniScreenWidth    = 400;
            MiniScreenHeight   = 320;
            MiniScreenPosition = 0;
            MiniScreen.SetSizeRequest(MiniScreenWidth, MiniScreenHeight);

            BtnPressed = false;                 // Botó premut

            // get the root window
            root = Gdk.Global.DefaultRootWindow;

            // Dimensions de la pantalla
            root.GetSize(out ScreenWidth, out ScreenHeight);
            Console.WriteLine("Pantalla: " + ScreenWidth + " " + ScreenHeight);

            PathColor = new Color(255, 0, 0);

            Llista_Punts = new List <Point>();
            moving_mouse = false;

            // Llegim les propietats del ratoli
            System.IO.StreamReader sr = new System.IO.StreamReader("/tmp/miniscreen_deviceslist");

            Input_Devices_List = new List <string[]>();
            string texto;

            string [] split_texto;
            string    dev;
            string    property;

            while (!sr.EndOfStream)
            {
                texto       = sr.ReadLine();
                split_texto = texto.Split(new char[] { ' ' });
                //String[] device=new String();
                //dev=split_texto[0];
                //property=split_texto[1];
                Input_Devices_List.Add(split_texto);
            }

            foreach (String [] device in Input_Devices_List)
            {
                Console.WriteLine("DEV: " + device[0]);
                Console.WriteLine("PROP: " + device[1]);
            }

            sr.Close();
            // cap posar dev i property com a parametres al xinit, i xinit com a dependencia d'este paquet
            // i invocar el script que crea aço abans de llegir-lo
            // Per si hi ha mes dispositius, ha de ser una llista!!

            // PATCH
            // Fem una captura de la pantalla general, per agafar les imatges a substiutir per la minipantalla
            InitScreenshot = Gdk.Pixbuf.FromDrawable(root, root.Colormap, 0, 0, 0, 0, ScreenWidth, ScreenHeight);

            int width, height, px, py;
        }