Example #1
0
	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		LinearGradient pat;		
		
		pat = new LinearGradient (0.0, 0.0,  0.0, 1.0);
		pat.AddColorStop (1, new Color (0, 0, 0, 1) );
		pat.AddColorStop (0, new Color (1, 1, 1, 1) );
		gr.Rectangle ( new PointD (0, 0),
			       1, 1
			       );
		
		gr.Pattern =  pat;
		gr.Fill ();
		pat.Destroy ();

		RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
				     0.4,  0.4, 0.5);
		
		pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
		pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
		gr.Pattern =  pat2;
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Fill ();
		pat2.Destroy ();
	}
Example #2
0
 protected void DrawPaper(Cairo.Context cr, double x, double y, double w, double h)
 {
     // make the background white with a line around
     cr.Rectangle(x+shadowOffset*2,y+shadowOffset*2,w-shadowOffset*2,h-shadowOffset*2);
     cr.Color = shadowColor;
     cr.Fill();
     GetInnerRegion(ref x,ref y,ref w,ref h);
     cr.Rectangle(x,y,w,h);
     cr.Color  = new Cairo.Color(0, 0, 0);
     cr.StrokePreserve();
     cr.Color  = new Cairo.Color(1, 1, 1);
     cr.Fill();
 }
Example #3
0
 public static void Fill(Cairo.Context context, int width, int height, Cairo.Color color)
 {
     context.NewPath();
     context.Color = color;
     context.Rectangle(0, 0, width, height);
     context.Fill();
 }
Example #4
0
 public static void Fill(Cairo.Context context, Gtk.Widget widget, Cairo.Color color)
 {
     context.NewPath();
     context.Color = color;
     context.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height);
     context.Fill();
 }
Example #5
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 #6
0
File: arc.cs Project: nlhepler/mono
	static void draw (Cairo.Context gr, int width, int height)
	{
		double xc = 0.5;
		double yc = 0.5;
		double radius = 0.4;
		double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
		double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		
		gr.Arc (xc, yc, radius, angle1, angle2);
		gr.Stroke ();
		
		/* draw helping lines */
		gr.Color = new Color(1, 0.2, 0.2, 0.6);
		gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
		gr.Fill ();
		gr.LineWidth = 0.03;
		gr.Arc (xc, yc, radius, angle1, angle1);
		gr.LineTo (new PointD(xc, yc));
		gr.Arc (xc, yc, radius, angle2, angle2);
		gr.LineTo (new PointD(xc, yc));
		gr.Stroke ();
		
	}
Example #7
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 #8
0
	/* 
	* Draw a red, green, and blue circle equally spaced inside
	* the larger circle of radius r at (xc, yc)
	*/
	static void draw_3circles (Cairo.Context gr, double xc, double yc, double radius)
	{
		double subradius = radius * (2 / 3.0 - 0.1);
		
		gr.Color =  new Color (1, 0, 0, 0.5);
		
		oval_path (gr,
			xc + radius / 3 * Math.Cos (M_PI * (0.5)),
			yc - radius / 3 * Math.Sin (M_PI * (0.5)),
			subradius, subradius);
			
		gr.Fill ();
		
		gr.Color  = new Color (0, 1, 0, 0.5);
		oval_path (gr,
			xc + radius / 3 * Math.Cos (M_PI * (0.5 + 2/.3)),
			yc - radius / 3 * Math.Sin (M_PI * (0.5 + 2/.3)),
			subradius, subradius);
			
		gr.Fill ();
		
		gr.Color = new Color (0, 0, 1, 0.5);
		
		oval_path (gr,
			xc + radius / 3 * Math.Cos (M_PI * (0.5 + 4/.3)),
			yc - radius / 3 * Math.Sin (M_PI * (0.5 + 4/.3)),
			subradius, subradius);
			
		gr.Fill ();
	}
Example #9
0
        protected override void onDraw(Cairo.Context gr)
        {
            Rectangle rBack = new Rectangle (Slot.Size);

            //rBack.Inflate (-Margin);
            //			if (BorderWidth > 0)
            //				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource (gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill ();

            if (BorderWidth > 0) {
                Foreground.SetAsSource (gr, rBack);
                CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
            }

            gr.Save ();
            if (ClipToClientRect) {
                //clip to client zone
                CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
                gr.Clip ();
            }

            if (child != null)
                child.Paint (ref gr);
            gr.Restore ();
        }
Example #10
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 ();
 }
Example #11
0
        protected override void ClippedRender (Cairo.Context cr)
        {
            Brush brush = Background;
            if (!brush.IsValid) {
                return;
            }

            double x = Double.IsNaN (brush.Width)
                ? 0
                : (RenderSize.Width - brush.Width) * XAlign;

            double y = Double.IsNaN (brush.Height)
                ? 0
                : (RenderSize.Height - brush.Height) * YAlign;

            cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
            cr.ClipPreserve ();

            if (x != 0 || y != 0) {
                cr.Translate (x, y);
            }

            cr.Antialias = Cairo.Antialias.None;
            brush.Apply (cr);
            cr.Fill ();
        }
Example #12
0
		protected override bool OnDrawn(Cairo.Context cr)
		{
			bool ret = true;
			var rect = this.Allocation;
			if (rect.Width > 0 && rect.Height > 0)
			{
				var arrowWidth = popupButton.Allocation.Width;
				var arrowPos = rect.Width - arrowWidth;
				var arrowSize = 10;

				StyleContext.Save();
				StyleContext.AddClass("entry");
				StyleContext.RenderBackground(cr, 0, 0, rect.Width, rect.Height);

				ret = base.OnDrawn(cr);

				StyleContext.RenderArrow(cr, Math.PI, arrowPos, (rect.Height - arrowSize) / 2, arrowSize);

				cr.SetSourceColor(new Cairo.Color(.8, .8, .8));
				cr.Rectangle(arrowPos - 5, 2, 1, rect.Height - 4);
				cr.Fill();

				Entry.StyleContext.RenderFrame(cr, 0, 0, rect.Width, rect.Height);
				StyleContext.Restore();

			}
			return ret;
		}
Example #13
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 #14
0
        private static void Taskbar()
        {
            var Data    = new byte[Compositor.PACKET_SIZE];
            var Request = (GuiRequest *)Data.GetDataOffset();

            Request->ClientID = 0;
            Request->Type     = RequestType.NewWindow;

            var Window = (NewWindow *)Request;

            Window->X      = 0;
            Window->Y      = 0;
            Window->Width  = VBE.Xres;
            Window->Height = 30;

            Compositor.Server.Write(Data);
            Client.Read(Data);

            string HashCode = new string(Window->Buffer);
            var    aBuffer  = SHM.Obtain(HashCode, 0, false);

            TaskbarID = Window->WindowID;

            uint surface = Cairo.ImageSurfaceCreateForData(Window->Width * 4, Window->Height, Window->Width, ColorFormat.ARGB32, aBuffer);
            uint context = Cairo.Create(surface);

            uint pattern = Cairo.PatternCreateLinear(30, 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, context);
            Cairo.Rectangle(30, VBE.Xres, 0, 0, context);
            Cairo.SetSource(pattern, context);
            Cairo.Fill(context);

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

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

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

            Redraw->WindowID = TaskbarID;
            Redraw->X        = 0;
            Redraw->Y        = 0;
            Redraw->Width    = VBE.Xres;
            Redraw->Height   = 40;
            Compositor.Server.Write(Data);

            TaskbarSurface = surface;
            TaskbarContext = context;
            Heap.Free(Data);
        }
		protected override void OnRender (Cairo.Context context)
		{
			OnLayoutOutline (context);
			context.Color = Color.MultiplyAlpha (Opacity);
			context.Fill ();

			base.OnRender (context);
		}
		public override bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
		{
			if (metrics.SelectionStart > 0)
				return true;
			cr.SetSourceColor (color);
			cr.Rectangle (metrics.TextRenderStartPosition, metrics.LineYRenderStartPosition, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
			cr.Fill ();
			return true;
		}
		bool IFoldMarginMarker.DrawBackground (TextEditor e, double marginWidth, Cairo.Context cr, Cairo.Rectangle area, DocumentLine documentLine, int line, double x, double y, double lineHeight)
		{
			if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this)
				return false;
			cr.Rectangle (x, y, marginWidth, lineHeight);
			cr.Color = LineColor.Color;
			cr.Fill ();
			return true;
		}
		public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
		{
			if (metrics.SelectionStart > 0)
				return true;
			cr.Color = color;
			cr.Rectangle (metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
			cr.Fill ();
			return true;
		}
Example #19
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 ();
 }
		void DrawMarginBackground (Cairo.Context cr, int line, double x, double y, double lineHeight)
		{
			if (editor.Caret.Line == line) {
				editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight);
				return;
			}
			cr.Rectangle (x, y, Width, lineHeight);
			cr.SetSourceColor (editor.ColorStyle.LineNumbers.Background);
			cr.Fill ();
		}
Example #21
0
        public virtual void Render(Cairo.Context cr, Layout layout, double x, double y, double w, double h)
        {
            cr.Save();
            cr.Translate (x,y);

            // make the background white
            cr.Color  = new Cairo.Color(1, 1, 1);
            cr.Rectangle(0,0,w,h);
            cr.Fill();

            // calc some values
            int lw;
            string prefix = "INV-"+InventoryAbbreviation+"-";
            string idString = Id.ToString("0000000000");

            // basic text stuff
            layout.FontDescription = FontDescription.FromString(CalcFont(Layout,layout,h));
            layout.Width = (int)(w*Scale.PangoScale);
            layout.Alignment = Alignment.Center;

            // draw the description
            int descH = 0;
            if(Layout.UseDescription){
                Layout descLayout = layout.Copy();
                descLayout.SetText (Description);
                descLayout.GetPixelSize(out lw, out descH);
                layout.Ellipsize = EllipsizeMode.Middle;
                layout.Justify = true;
                cr.Color = new Cairo.Color(0, 0, 0);
                Pango.CairoHelper.ShowLayout (cr, descLayout);
            }

            // draw the barcode	text
            int codeH = 0;
            if(Layout.UseBarcodeText){
                Layout codeLayout = layout.Copy();
                codeLayout.SetText (prefix+idString);
                codeLayout.GetPixelSize(out lw, out codeH);
                cr.MoveTo(0,h-(double)codeH);
                cr.Color = new Cairo.Color(0, 0, 0);
                Pango.CairoHelper.ShowLayout (cr, codeLayout);
            }

            // draw the barcode
            if(Layout.UseBarcode){
                double barcodeH = h-((double)codeH+(double)descH+Layout.SpacingSize*2);
                if(barcodeH>0){
                    IBarcode bc = new Code128();
                    bc.WriteString(prefix+idString);
                    bc.WriteEnd();
                    RenderBarcode(bc,cr,0,descH+Layout.SpacingSize,w,barcodeH);
                }
            }
            cr.Restore();
        }
Example #22
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 #23
0
 public override void DrawFrameBackground(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color, Cairo.Pattern pattern)
 {
     color.A = Context.FillAlpha;
     if (pattern != null) {
         cr.SetSource (pattern);
     } else {
         cr.SetSourceColor (color);
     }
     CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.All);
     cr.Fill ();
 }
Example #24
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 #25
0
 public override void Draw(Cairo.Context cr)
 {
     cr.Save();
     cr.Color = new Color(1.0, 1.0, 1.0);
     cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
     cr.Fill();
     cr.Color = new Color(0.0, 0.0, 0.0);
     cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
     cr.Stroke();
     cr.Restore();
 }
		void IIconBarMarker.DrawBackground (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
		{
			cr.Rectangle (x, y, width, height);
			cr.Color = LineColor.SecondColor;
			cr.Fill ();

			cr.MoveTo (x + width - 0.5, y);
			cr.LineTo (x + width - 0.5, y + height);
			cr.Color = LineColor.BorderColor;
			cr.Stroke ();

			if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) {
				cr.Rectangle (x, y, width, height);
				cr.Color = new Cairo.Color (ed.ColorStyle.IndicatorMargin.Color.R,
				                            ed.ColorStyle.IndicatorMargin.Color.G,
				                            ed.ColorStyle.IndicatorMargin.Color.B, 0.5);
				cr.Fill ();

			}

		}
		public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
		{
			this.editor = editor;
			var line = editor.GetLine (loc.Line);
			if (line == null)
				return;
			var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;

			cr.Rectangle (Math.Floor (x), Math.Floor (metrics.LineYRenderStartPosition) + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight : 0), tagMarkerWidth, tagMarkerHeight);
			cr.SetSourceColor ((HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5 ? Ide.Gui.Styles.Editor.SmartTagMarkerColorDark : Ide.Gui.Styles.Editor.SmartTagMarkerColorLight).ToCairoColor ());
			cr.Fill ();
		}
Example #28
0
        public static void RenderInvertedTriangle(Cairo.Context g, Cairo.Color c, double x, double y, int side)
        {
            g.Save();

            g.Color = c;
            g.MoveTo(x, y);
            g.LineTo(x - side / 2, y - side);
            g.LineTo(x + side / 2, y - side);
            g.LineTo(x, y);
            g.Fill();

            g.Restore();
        }
Example #29
0
        public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
        {
            Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
            Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (1, dark_color);

            cr.SetSource (grad);
            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill ();
            grad.Dispose ();
        }
Example #30
0
        public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity)
        {
            cr.Save ();
            cr.Translate (rect.X, rect.Y);

            var x = rect.Width / 2.0;
            var y = rect.Height / 2.0;
            using (var grad = new Cairo.RadialGradient (x, y, 0, x, y, rect.Width / 2.0)) {
                grad.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.1 * opacity));
                grad.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.35 * opacity));
                cr.SetSource (grad);
                CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
                cr.Fill ();
            }

            cr.Restore ();
        }
Example #31
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 #32
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 #33
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);
        }