Example #1
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);
        }
		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) + 0.5, Math.Floor (metrics.LineYRenderStartPosition) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth);

			if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) {
				cr.SetSourceRGBA (0.8, 0.8, 1, 0.9);
			} else {
				cr.SetSourceRGBA (0.2, 0.2, 1, 0.9);
			}
			cr.Stroke ();
		}
Example #3
0
 public static void DrawPixbuf(Cairo.Context cr, Pixbuf pixbuf)
 {
     cr.SetSourceRGBA(0.0, 0.0, 0.0, 1.0);
     cr.Operator = Cairo.Operator.DestIn;
     Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 0, 0);
     cr.Paint ();
     cr.Operator = Cairo.Operator.Over;
     cr.Paint ();
 }
Example #4
0
 protected override bool OnDrawn(Cairo.Context cr)
 {
     cr.Save ();
     Gdk.RGBA color = Hyena.Gui.GtkUtilities.ColorBlend (
         StyleContext.GetBackgroundColor (StateFlags.Normal),
         StyleContext.GetColor (StateFlags.Normal));
     cr.SetSourceRGBA (color.Red, color.Green, color.Blue, color.Alpha);
     DrawCairo (cr);
     cr.Restore ();
     return false;
 }
Example #5
0
        public void FillRectangle(Rectangle rect,Cairo.Context ctx,bool known,bool selected)
        {
            if(known)
                    ctx.SetSourceRGBA (0, 0,0.7, 0.3);
                else
                    ctx.SetSourceRGBA (0.7, 0,0, 1.3);

                ctx.LineWidth = selected ? 8.2 : 0.8 ;
                Rectangle r = ImageCoordsToWindow (rect);
                Log.Debug("Fill Rectangle"+rect.ToString()+ "  >>>  "+r.ToString()  + "  ["+XOffset +","+YOffset+"]" );
                ctx.MoveTo (r.X, r.Y);
                ctx.LineTo (r.X + r.Width, r.Y);
                ctx.LineTo (r.X + r.Width, r.Y + r.Height);
                ctx.LineTo (r.X, r.Y + r.Height);
                ctx.LineTo (r.X, r.Y);
                ctx.Stroke ();
        }
		static void DrawCloseButton (Cairo.Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				double fillColor = .74;

				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);

				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();

				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);

					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();


					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new Cairo.LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.Pattern = lg;
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();
				}
			}
		}
		void DrawIconMarginBackground (TextEditor ed, Cairo.Context cr, MarginDrawMetrics metrics)
		{
			cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
			cr.SetSourceColor (IconMarginColor.Color);
			cr.Fill ();
			cr.MoveTo (metrics.Right - 0.5, metrics.Y);
			cr.LineTo (metrics.Right - 0.5, metrics.Bottom);
			cr.SetSourceColor (IconMarginColor.BorderColor);
			cr.Stroke ();
			if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) {
				cr.Rectangle (metrics.X, metrics.Y, metrics.Width, metrics.Height);
				cr.SetSourceRGBA (ed.ColorStyle.IndicatorMargin.Color.R, ed.ColorStyle.IndicatorMargin.Color.G, ed.ColorStyle.IndicatorMargin.Color.B, 0.5);
				cr.Fill ();
			}
		}
		void DrawEolMarker (Cairo.Context cr, DocumentLine line, bool selected, double x, double y)
		{
			if (!textEditor.Options.IncludeWhitespaces.HasFlag (IncludeWhitespaces.LineEndings))
				return;

			Pango.Layout layout;
			Pango.Rectangle rect;

			var index = GetEolMarkerIndex (line.UnicodeNewline);
			layout = eolMarkerLayout [index];
			rect = eolMarkerLayoutRect [index];
			cr.Save ();
			cr.Translate (x, y + System.Math.Max (0, LineHeight - rect.Height - 1));
			var col = ColorStyle.PlainText.Foreground;

			if (selected && !SelectionColor.TransparentForeground) {
				col = SelectionColor.Foreground;
			} else {
				if (line != null && line.NextLine != null && line.NextLine.StartSpan != null && line.NextLine.StartSpan.Count > 0) {
					var span = line.NextLine.StartSpan.Peek ();
					var chunkStyle = ColorStyle.GetChunkStyle (span.Color);
					if (chunkStyle != null)
						col = ColorStyle.GetForeground (chunkStyle);
				}
			}

			cr.SetSourceRGBA (col.R, col.G, col.B, whitespaceMarkerAlpha * 1.4); // needs to more opaque due to font rendering
			cr.ShowLayout (layout);
			cr.Restore ();
		}
			public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
			{
				var line = editor.GetLine (loc.Line);
				var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;

				cr.Rectangle (Math.Floor (x) + 0.5, Math.Floor (y) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth);

				if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) {
					cr.SetSourceRGBA (0.8, 0.8, 1, 0.9);
				} else {
					cr.SetSourceRGBA (0.2, 0.2, 1, 0.9);
				}
				cr.Stroke ();
			}
		void RenderLineNumberIcon (Widget widget, Cairo.Context cr, Gdk.Rectangle cell_area, int markupHeight, int yOffset)
		{
			if (Frame == null)
				return;

			cr.Save ();

			#if CENTER_ROUNDED_RECTANGLE
			cr.Translate (cell_area.X + Padding, (cell_area.Y + (cell_area.Height - RoundedRectangleHeight) / 2.0));
			#else
			cr.Translate (cell_area.X + Padding, cell_area.Y + Padding + yOffset);
			#endif

			cr.Antialias = Cairo.Antialias.Subpixel;

			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.Clip ();

			if (IsUserCode)
				cr.SetSourceRGBA (0.90, 0.60, 0.87, 1.0); // 230, 152, 223
			else
				cr.SetSourceRGBA (0.77, 0.77, 0.77, 1.0); // 197, 197, 197

			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.Fill ();

			cr.SetSourceRGBA (0.0, 0.0, 0.0, 0.11);
			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.LineWidth = 2;
			cr.Stroke ();

			var lineNumber = !string.IsNullOrEmpty (Frame.File) ? Frame.Line : -1;

			using (var layout = PangoUtil.CreateLayout (widget, lineNumber != -1 ? lineNumber.ToString () : "???")) {
				layout.Alignment = Pango.Alignment.Left;
				layout.FontDescription = LineNumberFont;

				int width, height;
				layout.GetPixelSize (out width, out height);

				double y_offset = (RoundedRectangleHeight - height) / 2.0;
				double x_offset = (RoundedRectangleWidth - width) / 2.0;

				// render the text shadow
				cr.Save ();
				cr.SetSourceRGBA (0.0, 0.0, 0.0, 0.34);
				cr.Translate (x_offset, y_offset + 1);
				cr.ShowLayout (layout);
				cr.Restore ();

				cr.SetSourceRGBA (1.0, 1.0, 1.0, 1.0);
				cr.Translate (x_offset, y_offset);
				cr.ShowLayout (layout);
			}

			cr.Restore ();
		}
			public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
			{
				cr.Arc (metrics.X + metrics.Width / 2 + 2, metrics.Y + metrics.Height / 2, 7 * editor.Options.Zoom, 0, Math.PI * 2);
				isFailed = false;
				var test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier);
				bool searchCases = false;

				if (unitTest.IsIgnored) {
					cr.SetSourceRGB (0.9, 0.9, 0);
				} else {

					if (test != null) {
						var result = test.GetLastResult ();
						if (result == null) {
							cr.SetSourceRGB (0.5, 0.5, 0.5);
							searchCases = true;

						} else if (result.IsNotRun) {
							cr.SetSourceRGBA (0.9, 0.9, 0, test.IsHistoricResult ? 0.5 : 1.0);
						} else if (result.IsSuccess) {
							cr.SetSourceRGBA (0, 1, 0, test.IsHistoricResult ? 0.2 : 1.0);
						} else if (result.IsFailure) {
							cr.SetSourceRGBA (1, 0, 0, test.IsHistoricResult ? 0.2 : 1.0);
							failMessage = result.Message;
							isFailed = true;
						} else if (result.IsInconclusive) {
							cr.SetSourceRGBA (0, 1, 1, test.IsHistoricResult ? 0.2 : 1.0);
						} else {
							cr.SetSourceRGB (0.5, 0.5, 0.5);
						}
					} else {
						cr.SetSourceRGB (0.5, 0.5, 0.5);
						searchCases = true;
					}
					if (searchCases) {
						foreach (var caseId in unitTest.TestCases) {
							test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier + caseId);
							if (test != null) {
								var result = test.GetLastResult ();
								if (result == null || result.IsNotRun || test.IsHistoricResult) {
								} else if (result.IsNotRun) {
									cr.SetSourceRGB (0.9, 0.9, 0);
								} else if (result.IsSuccess) {
									cr.SetSourceRGB (0, 1, 0);
								} else if (result.IsFailure) {
									cr.SetSourceRGB (1, 0, 0);
									failMessage = result.Message;
									isFailed = true;
									break;
								} else if (result.IsInconclusive) {
									cr.SetSourceRGB (0, 1, 1);
								} 
							}
						}
					}
				}

				cr.FillPreserve ();
				if (unitTest.IsIgnored) {
					cr.SetSourceRGB (0.4, 0.4, 0);
					cr.Stroke ();

				} else {
					if (test != null) {
						var result = test.GetLastResult ();
						if (result == null) {
							cr.SetSourceRGB (0.2, 0.2, 0.2);
							cr.Stroke ();
						} else if (result.IsNotRun && !test.IsHistoricResult) {
							cr.SetSourceRGB (0.4, 0.4, 0);
							cr.Stroke ();
						} else if (result.IsSuccess && !test.IsHistoricResult) {
							cr.SetSourceRGB (0, 0.5, 0);
							cr.Stroke ();
						} else if (result.IsFailure && !test.IsHistoricResult) {
							cr.SetSourceRGB (0.5, 0, 0);
							cr.Stroke ();
						} else if (result.IsInconclusive && !test.IsHistoricResult) {
							cr.SetSourceRGB (0, 0.7, 0.7);
							cr.Stroke ();
						} 
					}
				}
				cr.NewPath ();
			}
Example #12
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);
        }
Example #13
0
		void RenderShadowedText (Cairo.Context context, Gdk.Point position, double opacity, Pango.Layout layout)
		{
			context.MoveTo (position.X, position.Y + 2);
			context.SetSourceRGBA (0, 0, 0, 0.3 * opacity);
			Pango.CairoHelper.ShowLayout (context, layout);
			
			context.MoveTo (position.X, position.Y);
			context.SetSourceRGBA (1, 1, 1, opacity);
			Pango.CairoHelper.ShowLayout (context, layout);
		}
		void DrawIndicator (Cairo.Context cr, Cairo.Color color, Cairo.Color borderColor)
		{
			const int indicatorPadding = 3;
			const int indicatorDiameter = 8;
			var x1 = Allocation.Width / 2d;
			var y1 = indicatorPadding + indicatorDiameter / 2d;

			cr.Arc (x1, y1 + 1, indicatorDiameter / 2d, 0, 2 * Math.PI);
			cr.SetSourceRGBA (0, 0, 0, 0.2);
			cr.Fill ();

			cr.Arc (x1, y1, indicatorDiameter / 2d, 0, 2 * Math.PI);
			cr.SetSourceColor (color);
			cr.Fill ();

			cr.Arc (x1, y1, indicatorDiameter / 2d - 1, 0, 2 * Math.PI);
			cr.SetSourceRGBA (1, 1, 1, 0.1);
			cr.Stroke ();

			cr.Arc (x1, y1, indicatorDiameter / 2d, 0, 2 * Math.PI);
			cr.SetSourceColor (borderColor);
			cr.Stroke ();
		}
Example #15
0
        public void Draw(Cairo.Context g, double scale, bool fillSelection)
        {
            g.Save ();
            g.Translate (0.5, 0.5);
            g.Scale (scale, scale);

            g.AppendPath (selection_path);

            if (fillSelection)
            {
                g.SetSourceRGBA(0.7, 0.8, 0.9, 0.2);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.FillPreserve ();
            }

            g.LineWidth = 1 / scale;

            // Draw a white line first so it shows up on dark backgrounds
            g.SetSourceRGB (1, 1, 1);
            g.StrokePreserve ();

            // Draw a black dashed line over the white line
            g.SetDash (new double[] { 2 / scale, 4 / scale }, 0);
            g.SetSourceRGB (0, 0, 0);

            g.Stroke ();
            g.Restore ();
        }
Example #16
0
 protected void paintTrail(Cairo.Context context, int x, int y)
 {
     context.Save ();
     context.SetSourceRGB (0, 1, 0);
     context.Translate (x, y);
     context.Rectangle (new Cairo.Rectangle (0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA (0, 1, 0, 0.3);
     context.FillPreserve ();
     context.NewPath ();
     context.Restore ();
 }
Example #17
0
 protected void paintSquare(Cairo.Context context, int x, int y, bool fill)
 {
     context.Save ();
     context.SetSourceRGB (0, 0, 1);
     context.Translate (x, y);
     context.Rectangle (new Cairo.Rectangle (0, 0, fieldSize, fieldSize));
     context.SetSourceRGBA (0, 0, 0, fill ? 0.5 : 0.3);
     context.FillPreserve ();
     context.NewPath ();
     context.Restore ();
 }
Example #18
0
		void RenderButton (Cairo.Context context, Gdk.Point corner, double opacity, bool hovered)
		{
			Gdk.Rectangle region = new Gdk.Rectangle (corner.X,
			                                          corner.Y,
			                                          ButtonSize.Width, ButtonSize.Height);



			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
			using (var lg = new LinearGradient (0, region.Top, 0, region.Bottom)) {
				if (hovered) {
					lg.AddColorStop (0, new Cairo.Color (.15, .76, .09, opacity));
					lg.AddColorStop (1, new Cairo.Color (.41, .91, .46, opacity));
				} else {
					lg.AddColorStop (0, new Cairo.Color (.41, .91, .46, opacity));
					lg.AddColorStop (1, new Cairo.Color (.15, .76, .09, opacity));
				}

				context.SetSource (lg);
				context.FillPreserve ();
			}

			context.SetSourceRGBA (.29, .79, .28, opacity);
			context.LineWidth = 1;
			context.Stroke ();

			region.Inflate (-1, -1);
			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 2);

			using (var lg = new LinearGradient (0, region.Top, 0, region.Bottom)) {
				lg.AddColorStop (0, new Cairo.Color (1, 1, 1, .74 * opacity));
				lg.AddColorStop (0.1, new Cairo.Color (1, 1, 1, 0));
				lg.AddColorStop (0.9, new Cairo.Color (0, 0, 0, 0));
				lg.AddColorStop (1, new Cairo.Color (0, 0, 0, .34 * opacity));

				context.SetSource (lg);
				context.Stroke ();
			}

			using (var layout = ButtonLayout (PangoContext)) {
				int w, h;
				layout.GetPixelSize (out w, out h);

				RenderShadowedText (context, new Gdk.Point (corner.X + ButtonSize.Width / 2 - w / 2, corner.Y + ButtonSize.Height / 2 - h / 2 - 1), opacity, layout);
			}
		}
Example #19
0
 public override void DrawRowRule(Cairo.Context cr, int x, int y, int width, int height)
 {
     cr.SetSourceRGBA (rule_color.R, rule_color.G, rule_color.B, Context.FillAlpha);
     cr.Rectangle (x, y, width, height);
     cr.Fill ();
 }
Example #20
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);
                    }
                }
            }
        }
		public void Draw (Cairo.Context cr, Cairo.Rectangle area)
		{
			TextViewMargin textViewMargin = editor.TextViewMargin;
			ISyntaxMode mode = Document.SyntaxMode != null && editor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode (Document);

			TextViewMargin.LayoutWrapper lineLayout = null;
			double brightness = HslColor.Brightness (editor.ColorStyle.PlainText.Background);

			int colorCount = foldSegments.Count + 2;
			cr.SetSourceColor (GetColor (-1, brightness, colorCount));
			cr.Rectangle (area);
			cr.Fill ();
			var rectangles = new Cairo.Rectangle[foldSegments.Count];
			const int xPadding = 4;
			const int yPadding = 2;
			const int rightMarginPadding = 16;
			for (int i = foldSegments.Count - 1; i >= 0 ; i--) {
				var segment = foldSegments [i];
				if (segment.IsInvalid)
					continue;
				var segmentStartLine = segment.StartLine;
				var segmentEndLine = segment.EndLine;

				int curWidth = 0;
				var endLine = segmentEndLine.NextLine;
				var y = editor.LineToY (segmentStartLine.LineNumber);
				if (y < editor.VAdjustment.Value) {
					segmentStartLine = editor.GetLine (editor.YToLine (editor.VAdjustment.Value));
					y = editor.LineToY (segmentStartLine.LineNumber);
				}

				for (var curLine = segmentStartLine; curLine != endLine && y < editor.VAdjustment.Value + editor.Allocation.Height; curLine = curLine.NextLine) {
					var curLayout = textViewMargin.CreateLinePartLayout (mode, curLine, curLine.Offset, curLine.Length, -1, -1);
					var width = (int)(curLayout.Width);
					curWidth = System.Math.Max (curWidth, width);
					y += editor.GetLineHeight (curLine);
				}

				double xPos = textViewMargin.XOffset;
				double rectangleWidth = 0, rectangleHeight = 0;
				
				lineLayout = textViewMargin.CreateLinePartLayout (mode, segmentStartLine, segmentStartLine.Offset, segmentStartLine.Length, -1, -1);
				var rectangleStart = lineLayout.Layout.IndexToPos (GetFirstNonWsIdx (lineLayout.Layout.Text));
				xPos = System.Math.Max (textViewMargin.XOffset, (textViewMargin.XOffset + textViewMargin.TextStartPosition + rectangleStart.X / Pango.Scale.PangoScale) - xPadding);

				lineLayout = textViewMargin.CreateLinePartLayout (mode, segmentEndLine, segmentEndLine.Offset, segmentEndLine.Length, -1, -1);
				
				var rectangleEnd = lineLayout.Layout.IndexToPos (GetFirstNonWsIdx (lineLayout.Layout.Text));
				xPos = System.Math.Min (xPos, System.Math.Max (textViewMargin.XOffset, (textViewMargin.XOffset + textViewMargin.TextStartPosition + rectangleEnd.X / Pango.Scale.PangoScale) - xPadding));

				rectangleWidth = textViewMargin.XOffset + textViewMargin.TextStartPosition + curWidth - xPos + xPadding * 2;

				if (i < foldSegments.Count - 1) {
					rectangleWidth = System.Math.Max ((rectangles [i + 1].X + rectangles[i + 1].Width + rightMarginPadding) - xPos, rectangleWidth);
				}

				y = editor.LineToY (segment.StartLine.LineNumber);
				var yEnd = editor.LineToY (segment.EndLine.LineNumber + 1) + (segment.EndLine.LineNumber == editor.LineCount ? editor.LineHeight : 0);
				if (yEnd == 0)
					yEnd = editor.VAdjustment.Upper;
				rectangleHeight = yEnd - y;

				rectangles[i] = new Cairo.Rectangle (xPos, y - yPadding, rectangleWidth, rectangleHeight + yPadding * 2);
			}

			for (int i = 0; i < foldSegments.Count; i++) {
				Cairo.Rectangle clampedRect;
				var rect = rectangles[i];

				if (i == foldSegments.Count - 1) {
/*					var radius = (int)(editor.Options.Zoom * 2);
					int w = 2 * radius;
					using (var shadow = new Blur (
						System.Math.Min ((int)rect.Width + w * 2, editor.Allocation.Width),
						System.Math.Min ((int)rect.Height + w * 2, editor.Allocation.Height), 
						radius)) {
						using (var gctx = shadow.GetContext ()) {
							gctx.Color = new Cairo.Color (0, 0, 0, 0);
							gctx.Fill ();

							var a = 0;
							var b = 0;
							DrawRoundRectangle (gctx, true, true, w - a, w - b, editor.LineHeight / 4, rect.Width + a * 2, rect.Height + a * 2);
							var bg = editor.ColorStyle.Default.CairoColor;
							gctx.Color = new Cairo.Color (bg.R, bg.G, bg.B, 0.6);
							gctx.Fill ();
						}

						cr.Save ();
						cr.Translate (rect.X - w - editor.HAdjustment.Value, rect.Y - editor.VAdjustment.Value - w);
						shadow.Draw (cr);
						cr.Restore ();
					}*/

					var curPadSize = 1;

					var age = (DateTime.Now - startTime).TotalMilliseconds;
					var alpha = 0.1;
					if (age < animationLength) {
						var animationState = age / (double)animationLength;
						curPadSize = (int)(3 + System.Math.Sin (System.Math.PI * animationState) * 3);
						alpha = 0.1 + (1.0 - animationState) / 5;
					}

					var bg = editor.ColorStyle.PlainText.Foreground;
					cr.SetSourceRGBA (bg.R, bg.G, bg.B, alpha);
					clampedRect = ClampRect (rect.X - editor.HAdjustment.Value - curPadSize , rect.Y - editor.VAdjustment.Value - curPadSize, editor.LineHeight / 2, rect.Width + curPadSize * 2, rect.Height + curPadSize * 2, area);
					DrawRoundRectangle (cr, true, true, clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height);
					cr.Fill ();

					if (age < animationLength) {
						var animationState = age / (double)animationLength;
						curPadSize = (int)(2 + System.Math.Sin (System.Math.PI * animationState) * 2);
						clampedRect = ClampRect (rect.X - editor.HAdjustment.Value - curPadSize, rect.Y - editor.VAdjustment.Value - curPadSize, editor.LineHeight / 2, rect.Width + curPadSize * 2, rect.Height + curPadSize * 2, area);
						DrawRoundRectangle (cr, true, true, clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height);
						cr.SetSourceColor (GetColor (i, brightness, colorCount));
						cr.Fill ();

						continue;
					}
				}

				clampedRect = ClampRect (rect.X - editor.HAdjustment.Value, rect.Y - editor.VAdjustment.Value, editor.LineHeight / 2, rect.Width, rect.Height, area);
				DrawRoundRectangle (cr, true, true,  clampedRect.X, clampedRect.Y, editor.LineHeight / 2, clampedRect.Width, clampedRect.Height);
				
				cr.SetSourceColor (GetColor (i, brightness, colorCount));
				cr.Fill ();
			}
		}
		// Taken from Mono.TextEditor.HelperMethods.
		public static void SetSourceColor (Cairo.Context cr, Cairo.Color color)
		{
			cr.SetSourceRGBA (color.R, color.G, color.B, color.A);
		}
Example #23
0
        //Draws the dots on the screen, end is a moot parameter
        public void DrawDot(Cairo.Context ctx, PointD start, PointD end)
        {
            if (!start.Equals (prevDot)) {

                    ctx.SetSourceRGBA (R, G, B, A);
                    ctx.Arc (start.X, start.Y, 1, 0, 2 * Math.PI);
                    ctx.StrokePreserve ();
                    ctx.Fill ();
                if (startRecordPoints) {

                    currentDrawnPoints.Add (start);

                }
                prevDot = start;

            }
        }
Example #24
0
		void DecorateTabsAndSpaces (Cairo.Context ctx, LayoutWrapper layout, int offset, int length, double xPos, double y, int selectionStart, int selectionEnd)
		{
			uint curIndex = 0, byteIndex = 0;
			bool first = true, oldSelected = false;
			int index, trailing;
			layout.Layout.XyToIndex ((int)textEditor.HAdjustment.Value, 0, out index, out trailing);
			var curchunk = layout.Chunks != null ? layout.Chunks.FirstOrDefault () : null;
			for (int i = index; i < layout.LineChars.Length; i++) {
				char ch = layout.LineChars [i];
				if (ch != ' ' && ch != '\t')
					continue;
				if (ch == ' ' && !textEditor.Options.IncludeWhitespaces.HasFlag (IncludeWhitespaces.Space))
					continue;
				if (ch == '\t' && !textEditor.Options.IncludeWhitespaces.HasFlag (IncludeWhitespaces.Tab))
					continue;
				bool selected = selectionStart <= offset + i && offset + i < selectionEnd;
				if (first || oldSelected != selected) {
					first = false;
					oldSelected = selected;
				}
				if (!selected && textEditor.Options.ShowWhitespaces != ShowWhitespaces.Always)
					continue;
				Pango.Rectangle pos = layout.Layout.IndexToPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)i, ref curIndex, ref byteIndex));
				double ypos = y + pos.Y / Pango.Scale.PangoScale;
				double xpos = xPos + pos.X / Pango.Scale.PangoScale;
				if (xpos > textEditor.Allocation.Width)
					break;
				Pango.Rectangle pos2 = layout.Layout.IndexToPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)i + 1, ref curIndex, ref byteIndex));
				double ypos2 = y + pos2.Y / Pango.Scale.PangoScale;
				double xpos2 = xPos + pos2.X / Pango.Scale.PangoScale;
				Cairo.Color col = new Cairo.Color (0, 0, 0);
				if (SelectionColor.TransparentForeground) {
					while (curchunk != null && curchunk.EndOffset < offset + i)
						curchunk = curchunk.Next;
					if (curchunk != null && curchunk.SpanStack.Count > 0 && curchunk.SpanStack.Peek ().Color != "Plain Text") {
						var chunkStyle = ColorStyle.GetChunkStyle (curchunk.SpanStack.Peek ().Color);
						if (chunkStyle != null)
							col = ColorStyle.GetForeground (chunkStyle);
					} else {
						col = ColorStyle.PlainText.Foreground;
					}
				} else {
					col = selected ? SelectionColor.Foreground : col = ColorStyle.PlainText.Foreground;
				}
				ctx.SetSourceRGBA (col.R, col.G, col.B, whitespaceMarkerAlpha);

				if (ch == '\t') {
					DrawTabMarker (ctx, selected, xpos, xpos2, ypos);
				} else {
					DrawSpaceMarker (ctx, selected, xpos, xpos2, ypos);
				}
			}
		}
Example #25
0
 //Original function which draws a straight line from start to end
 void DrawLine(Cairo.Context ctx, PointD start, PointD end)
 {
     ctx.SetSourceRGBA(R,G,B,A);
     ctx.MoveTo(start);
     ctx.LineTo(end);
     ctx.Stroke();
 }
		void InnerDecorateTabsAndSpaces (Cairo.Context ctx, LayoutWrapper layout, int offset, double x, double y, int selectionStart, int selectionEnd, char spaceOrTab)
		{
			var chars = layout.LineChars;
			if (Array.IndexOf (chars, spaceOrTab) == -1)
				return;

			uint curIndex = 0, byteIndex = 0;
			bool first = true, oldSelected = false;
			var curchunk = layout.Chunks != null ? layout.Chunks.FirstOrDefault () : null;

			var dotThickness = textEditor.Options.Zoom * 2;
			var textEditorWidth = textEditor.Allocation.Width;

			//Get 1st visible character index from left based on HAdjustment
			int index, trailing;
			layout.Layout.XyToIndex ((int)textEditor.HAdjustment.Value, 0, out index, out trailing);

			double ypos;
			if (spaceOrTab == ' ') {
				ypos = System.Math.Floor (y + (LineHeight - dotThickness) / 2);
			} else {
				ypos = 0.5 + System.Math.Floor (y + LineHeight / 2);
			}

			var showOnlySelected = textEditor.Options.ShowWhitespaces != ShowWhitespaces.Always;

			var lastColor = new Cairo.Color ();
			bool firstDraw = true;
			var foregroundColor = ColorStyle.PlainText.Foreground;

			int lastIndex = -1;
			int lastPosX = 0;

			for (int i = index; i < chars.Length; i++) {
				if (spaceOrTab != chars [i])
					continue;

				bool selected = selectionStart <= offset + i && offset + i < selectionEnd;
				if (first || oldSelected != selected) {
					first = false;
					oldSelected = selected;
				}

				if (showOnlySelected && !selected)
					continue;
				int line, posX;
				if (lastIndex == i) {
					posX = lastPosX;
				} else {
					layout.Layout.IndexToLineX ((int)TranslateToUTF8Index (chars, (uint)i, ref curIndex, ref byteIndex), false, out line, out posX);
				}
				double xpos = x + posX / Pango.Scale.PangoScale;
				if (xpos > textEditorWidth)
					break;
				layout.Layout.IndexToLineX ((int)TranslateToUTF8Index (chars, (uint)i + 1, ref curIndex, ref byteIndex), false, out line, out posX);
				lastPosX = posX;
				lastIndex = i + 1;
				double xpos2 = x + posX / Pango.Scale.PangoScale;
				var col = new Cairo.Color (0, 0, 0);
				if (SelectionColor.TransparentForeground) {
					while (curchunk != null && curchunk.EndOffset < offset + i)
						curchunk = curchunk.Next;
					if (curchunk != null && curchunk.SpanStack.Count > 0 && curchunk.SpanStack.Peek ().Color != "Plain Text") {
						var chunkStyle = ColorStyle.GetChunkStyle (curchunk.SpanStack.Peek ().Color);
						if (chunkStyle != null)
							col = ColorStyle.GetForeground (chunkStyle);
					} else {
						col = foregroundColor;
					}
				} else {
					col = selected ? SelectionColor.Foreground : foregroundColor;
				}

				if (firstDraw || (lastColor.R != col.R && lastColor.G != col.G && lastColor.B != col.B)) {
					ctx.SetSourceRGBA (col.R, col.G, col.B, whitespaceMarkerAlpha);
					lastColor = col;
					firstDraw = false;
				}

				if (spaceOrTab == ' ') {
					ctx.Rectangle (xpos + (xpos2 - xpos - dotThickness) / 2, ypos, dotThickness, dotThickness);
				} else {
					ctx.MoveTo (0.5 + xpos, ypos);
					ctx.LineTo (0.5 + xpos2 - charWidth / 2, ypos);
				}
			}
			if (!firstDraw) {//Atleast one draw was called
				if (spaceOrTab == ' ') {
					ctx.Fill ();
				} else {
					ctx.Stroke ();
				}
			}
		}
Example #27
0
        private void RenderSelection(Cairo.Context cr, Gdk.Rectangle background_area,
            bool selected, StateFlags state)
        {
            if (view == null) {
                return;
            }

            if (selected) {
                Gdk.Rectangle rect = background_area;
                rect.X -= 2;
                rect.Width += 4;

                // clear the standard GTK selection and focus
                Gdk.RGBA rgba = view.StyleContext.GetBackgroundColor (StateFlags.Normal);
                cr.SetSourceRGBA (rgba.Red, rgba.Green, rgba.Blue, rgba.Alpha);
                cr.Rectangle (rect.X, rect.Y, rect.Width, rect.Height);
                cr.Fill ();

                // draw the hot cairo selection
                if (!view.EditingRow) {
                    view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2);
                }
            } else if (!TreeIter.Zero.Equals (iter) && iter.Equals (view.HighlightedIter)) {
                view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
                    background_area.Width - 2, background_area.Height - 2, false);
            } else if (view.NotifyStage.ActorCount > 0) {
                if (!TreeIter.Zero.Equals (iter) && view.NotifyStage.Contains (iter)) {
                    Actor<TreeIter> actor = view.NotifyStage[iter];
                    Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor (view.StyleContext.GetBackgroundColor (StateFlags.Active));
                    color.A = Math.Sin (actor.Percent * Math.PI);

                    view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
                        background_area.Width - 2, background_area.Height - 2, true, true, color);
                }
            }
        }
		void DrawScrollShadow (Cairo.Context cr, double x, double y, double _lineHeight)
		{
			if (textEditor.HAdjustment.Value > 0) {
				cr.LineWidth = textEditor.Options.Zoom;
				for (int i = 0; i < verticalShadowAlphaTable.Length; i++) {
					cr.SetSourceRGBA (0, 0, 0, 1 - verticalShadowAlphaTable [i]);
					cr.MoveTo (x + i * cr.LineWidth + 0.5, y);
					cr.LineTo (x + i * cr.LineWidth + 0.5, y + 1 + _lineHeight);
					cr.Stroke ();
				}
			}
		}
Example #29
0
        /// <summary>
        /// Draws the label.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="bordertype">Bordertype.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="xpos">Xpos.</param>
        /// <param name="ypos">Ypos.</param>
        private static void DrawLabel(Cairo.Context context, BorderType bordertype, IPin pin, int xpos = 0, int ypos = 0)
        {
            const int widht = 100;
            const int height = BoldHeight;
            const int fontsize = 12;
            //Rect
            context.Rectangle (xpos, ypos, widht, 26);
            context.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
            context.Fill ();

            string displaytext = pin.Name;

            if (displaytext.Length > 12) {
                displaytext = displaytext.Substring (0, 12);
                displaytext += "...";
            }

            if (bordertype == BorderType.Line) {
                //Border
                context.SetSourceRGB (0, 0, 0);
                context.LineWidth = .5;
                context.Rectangle (xpos, ypos, widht, height);
                context.Stroke ();
            }

            //ColorFlag
            context.Rectangle (xpos, ypos, 5, height);
            context.SetSourceRGB (pin.PlotColor.Red, pin.PlotColor.Green, pin.PlotColor.Blue);
            context.Fill ();

            //Number
            context.SetSourceRGB (0, 0, 0);
            context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
            context.SetFontSize (fontsize);
            context.MoveTo (xpos + 5, ypos + fontsize);
            context.ShowText (pin.DisplayNumberShort);

            context.MoveTo (xpos + 5, ypos + fontsize * 2);
            context.ShowText (displaytext);
        }
			void DrawArrow (Cairo.Context g, double x, double y)
			{
				var editor = mode.editor;
				double phi = 1.618;
				double arrowLength = editor.LineHeight * phi;
				double arrowHeight = editor.LineHeight / phi;
				
				g.MoveTo (x - arrowLength, y - arrowHeight);
				g.LineTo (x, y);
				g.LineTo (x - arrowLength, y + arrowHeight);
				
				g.LineTo (x - arrowLength / phi, y);
				g.ClosePath ();
				g.SetSourceRGB (1.0, 0, 0);
				g.StrokePreserve ();
				
				g.SetSourceRGBA (1.0, 0, 0, 0.1);
				g.Fill ();
			}
Example #31
0
        /// <summary>
        /// Draws the label flat.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="bordertype">Bordertype.</param>
        /// <param name="labelposition">Labelposition.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="xpos">Xpos.</param>
        /// <param name="ypos">Ypos.</param>
        private static void DrawLabelFlat(Cairo.Context context, BorderType bordertype, LabelPosition labelposition, IPin pin, int xpos = 0, int ypos = 0)
        {
            string displaytext = "";
            var color = GdkToCairo (pin.PlotColor);

            displaytext = pin.DisplayNumberShort + " " + pin.Name;

            if (displaytext.Length > 12) {
                displaytext = displaytext.Substring (0, 12);
                displaytext += "...";
            }

            if (bordertype == BorderType.Line) {
                DrawRoundedRectangle (context, xpos, ypos, LabelWidth - LabelBorderWeight, FlatHeight, 5);
                context.SetSourceRGBA (color.R, color.G, color.B, color.A);
                context.LineWidth = LabelBorderWeight;
                context.Stroke ();
            }

            //PinToLabelLine
            int xposlabelline = 0;
            int yposlabelline = 0;
            switch (labelposition) {
            case LabelPosition.Left:
                xposlabelline = xpos + LabelWidth;
                yposlabelline = ypos + (FlatHeight / 2);
                break;
            case LabelPosition.Right:
                xposlabelline = xpos;
                yposlabelline = ypos + (FlatHeight / 2);
                break;
            case LabelPosition.Bottom:
                xpos = xpos + LabelWidth / 2;
                yposlabelline = ypos;
                break;
            default:
                break;
            }

            if (PinLocations.ContainsKey ((int)pin.RealNumber)) {
                DrawLines (
                    context,
                    xposlabelline,
                    yposlabelline,
                    (int)(MCUImageXZero + PinLocations [(int)pin.RealNumber].x),
                    (int)(MCUImageYZero + PinLocations [(int)pin.RealNumber].y),
                    color
                );
            }

            //Number
            context.SetSourceRGB (0, 0, 0);
            context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
            context.SetFontSize (LabelFontSize);
            context.MoveTo (xpos + 5, ypos + LabelFontSize + LabelBorderWeight);
            context.ShowText (displaytext);
        }
Example #32
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad = radius - 0.5;
            int centerX = region.X + region.Width / 2;
            int centerY = region.Y + region.Height / 2;

            context.MoveTo (centerX + rad, centerY);
            context.Arc (centerX, centerY, rad, 0, Math.PI * 2);

            double high;
            double low;
            switch (state) {
            case StateType.Selected:
                high = 0.85;
                low = 1.0;
                break;
            case StateType.Prelight:
                high = 1.0;
                low = 0.9;
                break;
            case StateType.Insensitive:
                high = 0.95;
                low = 0.83;
                break;
            default:
                high = 1.0;
                low = 0.85;
                break;
            }
            using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
                lg.AddColorStop (0, new Cairo.Color (high, high, high));
                lg.AddColorStop (1, new Cairo.Color (low, low, low));
                context.SetSource (lg);
                context.FillPreserve ();
            }

            context.SetSourceRGBA (0, 0, 0, 0.4);
            context.LineWidth = 1;
            context.Stroke ();
        }
Example #33
0
 /// <summary>
 /// Draws the lines.
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="xStart">X start.</param>
 /// <param name="yStart">Y start.</param>
 /// <param name="xEnd">X end.</param>
 /// <param name="yEnd">Y end.</param>
 /// <param name="color">Color.</param>
 private static void DrawLines(Cairo.Context context, int xStart, int yStart, int xEnd, int yEnd, Cairo.Color color)
 {
     context.Save ();
     context.SetSourceRGBA (color.R, color.G, color.B, color.A);
     context.MoveTo (xStart, yStart);
     context.LineTo (xEnd, yEnd);
     context.ClosePath ();
     context.Restore ();
     context.LineWidth = 1;
     context.Stroke ();
 }