Example #1
0
        protected void DrawHorizontalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, double w, out double h)
        {
            cr.MoveTo(x,y);
            cr.LineTo(x,y+SectionSerifeWidth*2);
            cr.MoveTo(x,y+SectionSerifeWidth);
            cr.LineTo(x+w,y+SectionSerifeWidth);
            cr.MoveTo(x+w,y);
            cr.LineTo(x+w,y+SectionSerifeWidth*2);
            cr.Color = new Cairo.Color(0, 0, 0);
            cr.LineWidth = 1;
            cr.Stroke();

            layout.Width = (int)(w*Pango.Scale.PangoScale);
            layout.Alignment = Pango.Alignment.Center;
            layout.SetText (text);
            layout.Ellipsize = EllipsizeMode.Middle;
            layout.Justify = true;
            cr.Color = new Cairo.Color(0, 0, 0);
            cr.MoveTo(x,y+SectionSerifeWidth*2);
            Pango.CairoHelper.ShowLayout (cr, layout);

            int lw,lh;
            layout.GetPixelSize(out lw, out lh);
            h=(double)lh+SectionSerifeWidth*2;
        }
Example #2
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.MoveTo ( new PointD (0.5, 0.1) );
		gr.LineTo ( new PointD (0.9, 0.9) );
		gr.RelLineTo ( new Distance (-0.4, 0.0) );
		gr.CurveTo ( new PointD (0.2, 0.9),
			     new PointD ( 0.2, 0.5),
			     new PointD (0.5, 0.5)
			     );
		gr.ClosePath ();
		
		gr.MoveTo ( new PointD (0.25, 0.1) );
		gr.RelLineTo ( new Distance (0.2, 0.2) );
		gr.RelLineTo ( new Distance ( -0.2, 0.2) );
		gr.RelLineTo ( new Distance (-0.2, -0.2) );
		gr.ClosePath ();	       
		
		gr.Color = new Color (0, 0, 1, 1);
		gr.FillPreserve ();
		gr.Color = new Color ( 0, 0, 0, 1);
		gr.Stroke ();
	}
Example #3
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		int w, h;
		ImageSurface image;
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
		gr.Clip ();
		gr.NewPath ();
		
		image = new ImageSurface("data/e.png");
		w = image.Width;
		h = image.Height;
		
		gr.Scale (1.0/w, 1.0/h);
		
		image.Show (gr, 0, 0);
		
		image.Destroy();
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();
		
		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
		gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
Example #4
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		double x=0.1,  y=0.5;
		double x1=0.4, y1=0.9, x2=0.6, y2=0.1, x3=0.9, y3=0.5;
		
				
		gr.Scale (width, height);
		gr.LineWidth = 0.04;		
		
		gr.MoveTo ( new PointD (x, y) );
		
		gr.CurveTo ( new PointD (x1, y1),
			     new PointD (x2, y2), 
			     new PointD (x3, y3)
			     );
		
		gr.Stroke ();
		
		gr.Color = new Color (1, 0.2, 0.2, 0.6);
		gr.LineWidth = 0.03;
		gr.MoveTo ( new PointD (x, y) );
		gr.LineTo ( new PointD (x1, y1) );
		gr.MoveTo ( new PointD (x2, y2) );
		gr.LineTo ( new PointD (x3, y3) );
		gr.Stroke ();						
	}
Example #5
0
        public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y)
        {
            g.Save();

            g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING);
            g.Color = Colors.BLACK;
            g.ShowText(text);

            g.MoveTo(x, y);
            g.Color = c;
            g.ShowText(text);

            g.Restore();
        }
Example #6
0
 public void draw(Cairo.Context cr)
 {
     cr.MoveTo (position);
     cr.SetSourceRGB (0, 1.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
        public static void RoundedRectangle(Cairo.Context c, RectangleD rect, double radius)
        {
            if (radius > (rect.Width /2) || radius > (rect.Height / 2)) {
                radius = Math.Min ((rect.Width /2), (rect.Height / 2));
            }

            c.Save ();

            /* Bottom Left */
            c.MoveTo(rect.X, rect.Y + radius);
            c.Arc (rect.X + radius, rect.Y + radius, radius, Math.PI, -Math.PI/2);
            c.LineTo (rect.X2 - radius, rect.Y);

            /* Bottom Right */
            c.Arc (rect.X2 - radius, rect.Y + radius, radius, -Math.PI/2, 0);
            c.LineTo (rect.X2, rect.Y2 - radius);

            /* Top Right */
            c.Arc (rect.X2 - radius, rect.Y2 - radius, radius, 0, Math.PI/2);
            c.LineTo (rect.X + radius, rect.Y2);

            /* Top Left */
            c.Arc(rect.X + radius, rect.Y2 - radius, radius, Math.PI/2, Math.PI);
            c.ClosePath ();

            c.Restore ();
        }
Example #8
0
        public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
		                                        double width, double height, double radius,
		                                        Cairo.Color color, Cairo.Color borderColor)
        {
            gr.Save();

            if((radius > height / 2) || (radius > width / 2))
                radius = Math.Min(height / 2, width / 2);

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();

            gr.LineJoin = LineJoin.Round;
            gr.Color = borderColor;
            gr.StrokePreserve();
            gr.Color = color;
            gr.Fill();
        }
Example #9
0
        public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            if (IsPanelWidget) {
                return;
            } else if (!IsSourceViewWidget) {
                base.DrawFrameBorder (cr, alloc);
                return;
            }

            cr.SetSourceColor (TextMidColor);
            cr.LineWidth = 1.0;
            cr.Antialias = Cairo.Antialias.None;

            cr.MoveTo (alloc.Right - 1, alloc.Top);
            cr.LineTo (alloc.Right - 1, alloc.Bottom);
            cr.Stroke ();

            if (Widget.Allocation.Bottom < Widget.Toplevel.Allocation.Height) {
                cr.MoveTo (alloc.Left, alloc.Bottom - 1);
                cr.LineTo (alloc.Right, alloc.Bottom - 1);
                cr.Stroke ();
            }

            cr.Antialias = Cairo.Antialias.Default;
        }
Example #10
0
        /// <summary>
        /// Draw the robot taking into account the center x and y position of the map which
        /// will be different from the true center x and y positions on the drawing context.
        /// This method will result in a red wheeled robot with black tyres being drawn at
        /// the robots location on the map.
        /// 
        /// The scale value is currently unused but it could be useful if the map was scaled
        /// in some way for example a mini-map may be 10 times smaller than the original 
        /// results in 1:10 scale robot.
        /// </summary>
        /// <param name="cairoContext">Cairo context to draw to (assuming a map).</param>
        /// <param name="centerX">Center x position of map to draw onto.</param>
        /// <param name="centerY">Center y position of map to draw onto.</param>
        /// <param name="scale">Scale currently unused.</param>
        public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
        {
            // Scale up to centimeters.
            int width = (int)(robot.Width * 100);
            int height = (int)(robot.Height * 100);
            int x = (int)(robot.X * 100);
            int y = (int)(robot.Y * 100);

            // Set a red colour.
            cairoContext.SetSourceRGB(255, 0, 0);

            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap = LineCap.Butt;

            cairoContext.Translate (centerX + x, centerY - y);
            cairoContext.Rotate (relativeRotation); // Rotate the robot based on its orientation in radians.

            // Draw the robot as a triangle.
            cairoContext.MoveTo (0, -height / 2);
            cairoContext.LineTo (-width / 2, height / 2);
            cairoContext.LineTo (width / 2, height / 2);
            cairoContext.LineTo (0, -height / 2);
            cairoContext.Stroke ();

            // Reset the drawing context.
            cairoContext.Rotate (-relativeRotation);
            cairoContext.Translate (-(centerX + x), -(centerY - y));
        }
Example #11
0
		public static void DrawRoundRectangle (Cairo.Context cr, double x, double y, double r, double w, double h)
		{
			const double ARC_TO_BEZIER = 0.55228475;
			double radius_x = r;
			double radius_y = r / 4;
			
			if (radius_x > w - radius_x)
				radius_x = w / 2;
					
			if (radius_y > h - radius_y)
				radius_y = h / 2;
			
			double c1 = ARC_TO_BEZIER * radius_x;
			double c2 = ARC_TO_BEZIER * radius_y;
			
			cr.NewPath ();
			cr.MoveTo (x + radius_x, y);
			cr.RelLineTo (w - 2 * radius_x, 0.0);
			cr.RelCurveTo (c1, 0.0, 
			               radius_x, c2, 
			               radius_x, radius_y);
			cr.RelLineTo (0, h - 2 * radius_y);
			cr.RelCurveTo (0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y);
			cr.RelLineTo (-w + 2 * radius_x, 0);
			cr.RelCurveTo (-c1, 0, -radius_x, -c2, -radius_x, -radius_y);
			cr.RelLineTo (0, -h + 2 * radius_y);
			cr.RelCurveTo (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y);
			cr.ClosePath ();
		}
Example #12
0
        private void Draw(Cairo.Context cr, int width, int heigth)
        {
            foreach (var path in pathPosition.Keys)
            {
                var pPosition = pathPosition[path];
                var begin = pPosition.Item1;
                var end = pPosition.Item2;

                cr.SetSourceRGB(1, 1, 1);
                cr.MoveTo(begin.X, begin.Y);
                cr.LineTo(end.X, end.Y);
                cr.Stroke();
                cr.SetSourceRGB(0, 0, 0);
            }

            foreach (var path in pathPosition.Keys)
            {
                var pPosition = pathPosition[path];
                var begin = pPosition.Item1;
                var end = pPosition.Item2;

                if (path is BlockingPath)
                {
                    var blockingPath = path as BlockingPath;

                    if (blockingPath.IsBlocked)
                    {
                        cr.SetSourceRGB(1, 0, 0);
                    }
                    else
                    {
                        cr.SetSourceRGB(0, 1, 0);
                    }

                    cr.Rectangle(new Cairo.Rectangle(end.X - 6, end.Y - 6, 12, 12));
                    cr.Fill();
                    cr.SetSourceRGB(0, 0, 0);
                }
                else if (path is SourcePath)
                {
                    var sourcePath = path as SourcePath;
                    cr.MoveTo(begin.X, begin.Y);
                    cr.TextPath(sourcePath.Queue.ToString());
                    cr.Fill();
                }

                foreach (var vehicle in path.VehiclePosition.Keys)
                {
                    var position = path.VehiclePosition[vehicle];
                    var r = position / path.Length;
                    var x = begin.X + (end.X - begin.X) * r;
                    var y = begin.Y + (end.Y - begin.Y) * r;

                    cr.Arc(x, y, 5, 0, 2 * Math.PI);
                    cr.Fill();
                }
            }

            cr.Stroke();
        }
Example #13
0
        /// <summary>
        /// Draw the specified cairoContext, centerX, centerY and scale.
        /// </summary>
        /// <param name="cairoContext">Cairo context.</param>
        /// <param name="centerX">Center x.</param>
        /// <param name="centerY">Center y.</param>
        /// <param name="scale">Scale.</param>
        public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
        {
            cairoContext.SetSourceRGB (0, 0, 200);
            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap = LineCap.Butt;

            //cairoContext.MoveTo (OriginalX, -OriginalY);
            //int x = centerX;

            //Console.WriteLine ("point: " + (robot.PathPointList [robot.PathPointList.Count-1] [1]*100));

            //if (30 <= (robot.PathPointList [robot.PathPointList.Count - 1] [1] * 100))
            //{
            //robot.Halt ();
            //Console.WriteLine ("\n\n Has Gone 30cm \n\n");
            //}

            for (int i = 1; i < robot.PathPointList.Count; i++)
            {
                cairoContext.MoveTo (centerX + (robot.PathPointList [i - 1] [0] * 100), centerY - (robot.PathPointList [i - 1] [1] * 100));
                cairoContext.LineTo (centerX + (robot.PathPointList [i] [0] * 100), centerY - (robot.PathPointList [i] [1] * 100));
                //	Console.WriteLine (path[0]*100+" , "+ path[1]*100);
                cairoContext.Stroke ();
            }

            foreach (double[] path in robot.PathPointList)
            {
                //cairoContext.MoveTo (centerX - (path[0] * 100), centerY - (path[1] * 100));
            }
        }
Example #14
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            double step_width = Allocation.Width / (double)steps;
            double step_height = Allocation.Height / (double)steps;
            double h = 1.0;
            double s = 0.0;

            for (int xi = 0, i = 0; xi < steps; xi++) {
                for (int yi = 0; yi < steps; yi++, i++) {
                    double bg_b = (double)(i / 255.0);
                    double fg_b = 1.0 - bg_b;

                    double x = xi * step_width;
                    double y = yi * step_height;

                    cr.Rectangle (x, y, step_width, step_height);
                    cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b);
                    cr.Fill ();

                    int tw, th;
                    Pango.Layout layout = new Pango.Layout (PangoContext);
                    layout.SetText (((int)(bg_b * 255.0)).ToString ());
                    layout.GetPixelSize (out tw, out th);

                    cr.Translate (0.5, 0.5);
                    cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0);
                    cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b);
                    PangoCairoHelper.ShowLayout (cr, layout);
                    cr.Translate (-0.5, -0.5);
                }
            }

            return true;
        }
Example #15
0
		public override void DrawContent (Cairo.Context Context, Cairo.Rectangle Area)
		{
			Context.Color = new Color (0, 0, 0);
			Pango.CairoHelper.UpdateLayout (Context, textLayout);
			Context.MoveTo (Area.X, Area.Y);
			Pango.CairoHelper.ShowLayout (Context, textLayout);
		}
Example #16
0
		internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, LineSegment lineSegment, int line, double x, double y, double lineHeight)
		{
			cr.MoveTo (x + 0.5, y);
			cr.LineTo (x + 0.5, y + lineHeight);
			cr.Color = color;
			cr.Stroke ();
		}
Example #17
0
        public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y, string font, int point)
        {
            g.Save();

            g.SelectFontFace(font, FontSlant.Normal, FontWeight.Normal);
            g.SetFontSize(point);

            g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING);
            g.Color = Colors.BLACK;
            g.ShowText(text);

            g.MoveTo(x, y);
            g.Color = c;
            g.ShowText(text);

            g.Restore();
        }
Example #18
0
	static void oval_path (Cairo.Context gr, double xc, double yc, double xr, double yr)
	{
		gr.Translate (xc, yc);
		gr.Scale (1.0, yr / xr);
		gr.MoveTo (new PointD (xr, 0.0) );
		gr.Arc (0, 0, xr, 0, 2 * M_PI);
		gr.ClosePath ();
	}
Example #19
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();

		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
	        gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
Example #20
0
 /// <summary>
 /// The draw curved rectangle.
 /// </summary>
 protected void DrawCurvedRectangle(Cairo.Context gr, double x, double y, double width, double height)
 {
     gr.Save();
     gr.MoveTo(x, y + height / 2);
     gr.CurveTo(x, y, x, y, x + width / 2, y);
     gr.CurveTo(x + width, y, x + width, y, x + width, y + height / 2);
     gr.CurveTo(x + width, y + height, x + width, y + height, x + width / 2, y + height);
     gr.CurveTo(x, y + height, x, y + height, x, y + height / 2);
     gr.Restore();
 }
Example #21
0
 public static void RenderLine(Cairo.Context g, Cairo.Color c, double lw, double x0, double y0, double x1, double y1)
 {
     g.Save();
     g.Color = c;
     g.LineWidth = 3;
     g.MoveTo(x0, y0);
     g.LineTo(x1, y1);
     g.Stroke();
     g.Restore();
 }
		protected override void OnLayoutOutline (Cairo.Context context)
		{
			// polygons have 3 sides
			if (verticies.Count <= 2)
				return;

			var renderVerts = verticies.Select (v => new Cairo.PointD (v.X * Width, v.Y * Height)).ToList ();
			context.MoveTo (renderVerts.First ());
			renderVerts.ForEach (v => context.LineTo (v));
		}
Example #23
0
 public void draw(Cairo.Context cr)
 {
     if (!canSeePlayer) {
         return;
     }
     cr.MoveTo (position);
     cr.SetSourceRGB (1.0, 0.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
Example #24
0
 static void DrawCurvedRectangle(Cairo.Context gr, int x, int y, int width, int height)
 {
     gr.Save ();
     gr.MoveTo (x, y + height / 2);
     gr.CurveTo (x, y, x, y, x + width / 2, y);
     gr.CurveTo (x + width, y, x + width, y, x + width, y + height / 2);
     gr.CurveTo (x + width, y + height, x + width, y + height, x + width / 2, y + height);
     gr.CurveTo (x, y + height, x, y + height, x, y + height / 2);
     gr.Restore ();
 }
Example #25
0
        public static void DrawTriangle(Cairo.Context g, double x, double y,
		                                int width, int height, Cairo.Color color)
        {
            g.Color = color;
            g.MoveTo(x, y);
            g.LineTo(x + width/2, y-height);
            g.LineTo(x - width/2, y-height);
            g.ClosePath();
            g.Fill();
            g.Stroke();
        }
Example #26
0
 public static void RenderCircle(Cairo.Context g, Cairo.Color c, double r, double x, double y)
 {
     g.Save();
     g.Color = c;
     g.MoveTo(x, y);
     g.Arc(x, y, r, 0, 6.28);
     g.LineWidth = 3;
     g.ClosePath();
     g.Fill();
     g.Restore();
 }
Example #27
0
		void DrawVersionNumber (Cairo.Context c, ref Cairo.PointD bottomRight, string text)
		{
			c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
			c.SetFontSize (SplashFontSize);
			
			var extents = c.TextExtents (text);
			c.MoveTo (bottomRight.X - extents.Width - 1, bottomRight.Y - extents.Height);
			
			c.Color = new Cairo.Color (1, 1, 1);
			c.ShowText (text);
		}
Example #28
0
		void DrawHand (double fThickness, double length, Cairo.Color color, double radians, Cairo.Context e)
		{
			e.MoveTo (new Cairo.PointD (center.X - (length / 9 * Math.Sin (radians)), center.Y + (length / 9 * Math.Cos (radians))));
			e.LineTo (new Cairo.PointD (center.X + (length * Math.Sin (radians)), center.Y - (length * Math.Cos (radians))));
			e.ClosePath ();
			e.LineCap = Cairo.LineCap.Round;
			e.LineJoin = Cairo.LineJoin.Round;
			e.Color = color;
			e.LineWidth = fThickness;
			e.Stroke ();
		}
Example #29
0
        public static void DrawLine(Cairo.Context g, double x1, double y1,
		                            double x2, double y2,
		                            int width, Cairo.Color color)
        {
            g.Color = color;
            g.Operator = Operator.Over;
            g.LineWidth = width;
            g.MoveTo(x1, y1);
            g.LineTo(x2,y2);
            g.Stroke();
        }
Example #30
0
		protected void DrawDiamond (Cairo.Context cr, double x, double y, double size)
		{
			x += 0.5; y += 0.5;
			size -= 2;
			cr.NewPath ();
			cr.MoveTo (x + size/2, y);
			cr.LineTo (x + size, y + size/2);
			cr.LineTo (x + size/2, y + size);
			cr.LineTo (x, y + size/2);
			cr.LineTo (x + size/2, y);
			cr.ClosePath ();
		}
Example #31
0
File: Boot.cs Project: vdt/AtomOS
        private static unsafe void DrawWindow(GuiRequest *request, byte[] xData)
        {
            request->Type  = RequestType.NewWindow;
            request->Error = ErrorType.None;
            var window = (NewWindow *)request;

            window->X      = 340;
            window->Y      = 159;
            window->Width  = 600;
            window->Height = 450;

            Compositor.Server.Write(xData);

            SystemClient.Read(xData);
            if (request->Error != ErrorType.None)
            {
                Debug.Write("Error5: %d\n", (int)request->Error);
                return;
            }

            string HashCode = new string(window->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);
            int    winID    = window->WindowID;

            Debug.Write("winID: %d\n", winID);

            uint surface = Cairo.ImageSurfaceCreateForData(600 * 4, 450, 600, ColorFormat.ARGB32, aBuffer);
            uint cr      = Cairo.Create(surface);

            Cairo.SetOperator(Operator.Over, cr);

            Cairo.Rectangle(450, 600, 0, 0, cr);
            Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr);
            Cairo.Fill(cr);
            Cairo.Rectangle(446, 596, 2, 2, cr);
            Cairo.SetSourceRGBA(1, 0.87, 0.87, 0.87, cr);
            Cairo.Fill(cr);
            Cairo.Rectangle(410, 580, 30, 10, cr);
            Cairo.SetSourceRGBA(1, 1, 1, 1, cr);
            Cairo.Fill(cr);

            Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr);
            Cairo.SelectFontFace(FontWeight.Normal, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.SetFontSize(15, cr);
            Cairo.MoveTo(18, 215, cr);
            Cairo.ShowText(Marshal.C_String("Atom OS : Installation Guide"), cr);

            Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.MoveTo(18, 580, cr);
            Cairo.ShowText(Marshal.C_String("X"), cr);

            Cairo.SurfaceFlush(surface);
            Cairo.Destroy(cr);
            Cairo.SurfaceDestroy(surface);

            request->Type = RequestType.Redraw;
            var req = (Redraw *)request;

            req->WindowID = winID;
            req->X        = 0;
            req->Y        = 0;
            req->Width    = 600;
            req->Height   = 450;
            Compositor.Server.Write(xData);

            Debug.Write("Time: %d\n", Timer.TicksFromStart);
            while (true)
            {
                SystemClient.Read(xData);
                if (request->Error != ErrorType.None)
                {
                    continue;
                }
                if (request->Type != RequestType.MouseEvent)
                {
                    continue;
                }
                var mreq = (MouseEvent *)request;
                if (mreq->WindowID != winID)
                {
                    continue;
                }
                if ((mreq->Function & MouseFunction.Click) != 0)
                {
                    int x = mreq->Xpos;
                    int y = mreq->Ypos;
                    if (y < 40)
                    {
                        request->Type = RequestType.DragRequest;
                        var mv = (DragRequest *)request;
                        mv->WindowID = winID;
                        Compositor.Server.Write(xData);
                    }
                }
            }
        }
Example #32
0
File: Boot.cs Project: vdt/AtomOS
        private static unsafe void DrawTaskbar(GuiRequest *request, byte[] xData)
        {
            request->Type  = RequestType.NewWindow;
            request->Error = ErrorType.None;
            var taskbar = (NewWindow *)request;
            int height  = 30;

            taskbar->X      = 0;
            taskbar->Y      = 0;
            taskbar->Width  = VBE.Xres;
            taskbar->Height = height;

            Compositor.Server.Write(xData);

            SystemClient.Read(xData);
            if (request->Error != ErrorType.None)
            {
                Debug.Write("Error4: %d\n", (int)request->Error);
                return;
            }

            string HashCode = new string(taskbar->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);
            int    winID    = taskbar->WindowID;

            Debug.Write("winID: %d\n", winID);

            uint surface = Cairo.ImageSurfaceCreateForData(VBE.Xres * 4, height, VBE.Xres, ColorFormat.ARGB32, aBuffer);
            uint cr      = Cairo.Create(surface);

            uint pattern = Cairo.PatternCreateLinear(height, 0, 0, 0);

            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern);
            Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern);
            Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern);

            Cairo.SetOperator(Operator.Over, cr);
            Cairo.Rectangle(height, VBE.Xres, 0, 0, cr);
            Cairo.SetSource(pattern, cr);
            Cairo.Fill(cr);

            Cairo.Rectangle(2, VBE.Xres, height - 2, 0, cr);
            Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, cr);
            Cairo.Fill(cr);

            Cairo.SetSourceRGBA(1, 1, 1, 1, cr);
            Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr);
            Cairo.SetFontSize(20, cr);
            Cairo.MoveTo(20, 1215, cr);
            Cairo.ShowText(Marshal.C_String("20:10"), cr);

            Cairo.PatternDestroy(pattern);
            Cairo.Destroy(cr);
            Cairo.SurfaceDestroy(surface);

            request->Type = RequestType.Redraw;
            var req = (Redraw *)request;

            req->WindowID = winID;
            req->X        = 0;
            req->Y        = 0;
            req->Width    = VBE.Xres;
            req->Height   = height;
            Compositor.Server.Write(xData);
        }