Пример #1
0
        public override void Render(Gdk.Drawable window, Gdk.Rectangle bounds, Gtk.StateType state)
        {
            int iy = bounds.Y + (bounds.Height - imgSize) / 2;

            if (image != null) {
                int dy = (imgSize - image.Height) / 2;
                int dx = (imgSize - image.Width) / 2;
                window.DrawPixbuf (Container.Style.BackgroundGC (state), image, 0, 0, bounds.X + dx, iy + dy, -1, -1, Gdk.RgbDither.None, 0, 0);
            }

            window.DrawRectangle (Container.Style.DarkGC (state), false, bounds.X, iy, imgSize - 1, imgSize - 1);

            bounds.X += imgSize + spacing;
            base.Render (window, bounds, state);
        }
Пример #2
0
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            base.Render (window, widget, background_area, cell_area, expose_area, flags);
            int xPos = cell_area.X;
            if(this.Pixbuf != null){
                window.DrawPixbuf(widget.Style.MidGC( StateType.Normal), this.Pixbuf, 0, 0, xPos + 1, cell_area.Y + 1, 16, 16, Gdk.RgbDither.Normal, 0, 0);
                xPos += 20;
            }
            using (var layout = new Pango.Layout(widget.PangoContext)) {
                layout.Alignment = Pango.Alignment.Left;
                layout.SetText(this.Text ?? "");

                StateType state = flags.HasFlag(CellRendererState.Selected) ?
                    widget.IsFocus ? StateType.Selected : StateType.Active : StateType.Normal;

                window.DrawLayout(widget.Style.TextGC(state), xPos, cell_area.Y + 2, layout);
            }
        }
Пример #3
0
        private void DrawPosition(Gdk.Window window)
        {
            Gdk.GC gc = Style.ForegroundGC (StateType.Normal);

            for (int i = 0; i < 8; i++)
              {
                  for (int j = 0; j < 8; j += 1)
                    {

                        FigureType fig =
                            position.GetFigureAt (i,
                                      j);

                        if (fig != FigureType.None)
                          {
                              int x, y;

                              if (!side)
                            {
                                //White
                                x = start_x +
                                    i *
                                    space
                                    +
                                    i *
                                    size;
                                y = start_y +
                                    j *
                                    space
                                    +
                                    j *
                                    size;
                            }
                              else
                            {
                                //Black
                                x = start_x +
                                    (7 -
                                     i) *
                                    (space
                                     +
                                     size);
                                y = start_y +
                                    (7 -
                                     j) *
                                    (space
                                     +
                                     size);
                            }

                              window.DrawPixbuf
                                  (gc,
                                   figure.
                                   GetPixbuf
                                   (fig),
                                   0, 0,
                                   x, y,
                                   size,
                                   size,
                                   Gdk.
                                   RgbDither.
                                   None, 0, 0);
                          }
                    }
              }

            return;
        }
Пример #4
0
 public override void draw(Gdk.Window win, int x, int y)
 {
     Gdk.GC context = new Gdk.GC(win);
      		GraphicsStorage store = GraphicsStorage.GetInstance();
     win.DrawPixbuf(context, store.LSat, 0, 0, x, y, store.LSat.Width, store.LSat.Height, RgbDither.Normal, 1, 1);
 }
Пример #5
0
        public void Draw(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            if (!_visible)
            {
                return;
            }

            if (_w > 0 && _h > 0)
            {
                Gdk.GC gc = new Gdk.GC(d);

                d.DrawPixbuf(gc, _background, 0, 0, _x, _y, _w, _h, Gdk.RgbDither.None, 0, 0);

                int x0 = _x, x1 = _x + _w;
                int y0 = _y, y1 = _y + _h;

                g.MoveTo(x0 + 3, y0);
                g.LineTo(x1 - 3, y0);
                g.LineTo(x1, y0 + 3);
                g.LineTo(x1, y1 - 3);
                g.LineTo(x1 - 3, y1);
                g.LineTo(x0 + 3, y1);
                g.LineTo(x0, y1 - 3);
                g.LineTo(x0, y0 + 3);
                g.LineTo(x0 + 3, y0);
                g.ClosePath();
                g.LineWidth = 6;
                g.Color = BorderColor;
                g.Stroke();
            }

            g.Save();

            DrawContents(d, g, width, height, screenChanged);

            g.Restore();
        }
		public void Draw (TextEditor editor, Gdk.Drawable win, int lineNr, Gdk.Rectangle lineArea)
		{
			EnsureLayoutCreated (editor);
			int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
			int errorNumber = lineNr - lineNumber;
			int x = editor.TextViewMargin.XOffset;
			int y = lineArea.Y;
			int right = editor.Allocation.Width;
			int errorCounterWidth = 0;
			
			int ew = 0, eh = 0;
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			int x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
//			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset  + lineSegment.EditableLength) : false;
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			bool isCaretInLine = lineSegment.Offset <= editor.Caret.Offset && editor.Caret.Offset <= lineSegment.EndOffset;
			int highlighted = active == 0 && isCaretInLine ? 1 : 0;
			int selected = 0;
			LayoutDescriptor layout = layouts[errorNumber];
			x2 = right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0);
			
			x2 -= errorCounterWidth;
			x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			
			using (var g = Gdk.CairoHelper.Create (win)) {
				g.LineWidth = Math.Max (1.0, editor.Options.Zoom);
				g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
				g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
				g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
				g.LineTo (new Cairo.PointD (right, y));
				g.ClosePath ();
				g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
				g.Fill ();
				
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
				g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
				if (errorNumber == errors.Count - 1)
					g.LineTo (new Cairo.PointD (lineArea.Right, y + editor.LineHeight));
				g.Stroke ();
				
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					if (divider >= x2) {
						g.MoveTo (new Cairo.PointD (divider + 0.5, y));
						g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Stroke ();
					}
				}
			}
			win.DrawLayout (selected == 0 ? gc : gcSelected, x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2, layout.Layout);
			if (ShowIconsInBubble)
				win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors[errorNumber].IsError ? errorPixbuf : warningPixbuf, 0, 0, x2, y + (editor.LineHeight - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
		}
		public bool DrawBackground (TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout2, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
		{
			if (!IsExpanded || DebuggingService.IsDebugging)
				return true;
			EnsureLayoutCreated (editor);
			int x = editor.TextViewMargin.XOffset;
			int right = editor.Allocation.Width;
			int errorCounterWidth = 0;
			bool isCaretInLine = startOffset <= editor.Caret.Offset && editor.Caret.Offset <= endOffset;
			int ew = 0, eh = 0;
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			int x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
			bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.EditableLength) : false;
			
			int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
			int highlighted = active == 0 && isCaretInLine ? 1 : 0;
			int selected = 0;
			
			int topSize = editor.LineHeight / 2;
			int bottomSize = editor.LineHeight / 2 + editor.LineHeight % 2;
			
			using (var g = Gdk.CairoHelper.Create (win)) {
				g.LineWidth = Math.Max (1.0, editor.Options.Zoom);
				if (!fitsInSameLine) {
					if (isEolSelected) {
						x -= (int)editor.HAdjustment.Value;
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y + editor.LineHeight, editor.TextViewMargin.TextStartPosition, editor.LineHeight), editor.ColorStyle.Default.BackgroundColor, true);
						editor.TextViewMargin.DrawRectangleWithRuler (win, x + editor.TextViewMargin.TextStartPosition, new Gdk.Rectangle (x + editor.TextViewMargin.TextStartPosition, y + editor.LineHeight, editor.Allocation.Width + (int)editor.HAdjustment.Value, editor.LineHeight), editor.ColorStyle.Selection.BackgroundColor, true);
						x += (int)editor.HAdjustment.Value;
					} else {
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y + editor.LineHeight, x2, editor.LineHeight), editor.ColorStyle.Default.BackgroundColor, true);
					}
				}
				DrawRectangle (g, x, y, right, topSize);
				g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
				g.Fill ();
				DrawRectangle (g, x, y + topSize, right, bottomSize);
				g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
				g.Fill ();
				
				g.MoveTo (new Cairo.PointD (x, y + 0.5));
				g.LineTo (new Cairo.PointD (x + right, y + 0.5));
				g.Color = colorMatrix[active, TOP, LINE, highlighted, selected];
				g.Stroke ();
				
				g.MoveTo (new Cairo.PointD (x, y + editor.LineHeight - 0.5));
				g.LineTo (new Cairo.PointD ((fitsInSameLine ? x + right : x2 + 1), y + editor.LineHeight - 0.5));
				g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
				g.Stroke ();
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					g.MoveTo (new Cairo.PointD (divider + 0.5, y));
					g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
				}
				
				// draw background
				if (layout2.StartSet || selectionStart == endOffset) {
					int startX;
					int endX;
					
					if (selectionStart != endOffset) {
						var start = layout2.Layout.IndexToPos ((int)layout2.SelectionStartIndex);
						startX = (int)(start.X / Pango.Scale.PangoScale);
						var end = layout2.Layout.IndexToPos ((int)layout2.SelectionEndIndex);
						endX = (int)(end.X / Pango.Scale.PangoScale);
					} else {
						startX = x2;
						endX = startX;
					}
					
					if (editor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX)
						endX = startX + 2;
					startX += startXPos;
					endX += startXPos;
					startX = Math.Max (editor.TextViewMargin.XOffset, startX);
					// clip region to textviewmargin start
					if (isEolSelected)
						endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
					if (startX < endX) {
						DrawRectangle (g, startX, y, endX - startX, topSize);
						g.Color = colorMatrix[active, TOP, LIGHT, highlighted, 1];
						g.Fill ();
						DrawRectangle (g, startX, y + topSize, endX - startX, bottomSize);
						g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
						g.Fill ();
						
						g.MoveTo (new Cairo.PointD (startX, y + 0.5));
						g.LineTo (new Cairo.PointD (endX, y + 0.5));
						g.Color = colorMatrix[active, TOP, LINE, highlighted, 1];
						g.Stroke ();
						
						if (startX < x2) {
							g.MoveTo (new Cairo.PointD (startX, y + editor.LineHeight - 0.5));
							g.LineTo (new Cairo.PointD (System.Math.Min (endX, x2 + 1), y + editor.LineHeight - 0.5));
							g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
							g.Stroke ();
							if (x2 + 1 < endX) {
								g.MoveTo (new Cairo.PointD (x2 + 1, y + editor.LineHeight - 0.5));
								g.LineTo (new Cairo.PointD (endX, y + editor.LineHeight - 0.5));
								g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
								g.Stroke ();
							}
						}
						
						if (editor.Options.ShowRuler) {
							int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
							g.MoveTo (new Cairo.PointD (divider + 0.5, y));
							g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
							g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
							g.Stroke ();
						}
					}
				}
				
				if (!fitsInSameLine)
					y += editor.LineHeight;
				double y2 = y + 0.5;
				double y2Bottom = y2 + editor.LineHeight - 1;
				selected = isEolSelected && (CollapseExtendedErrors || errors.Count == 1) ? 1 : 0;
				
				// draw message text background
				if (CollapseExtendedErrors || errors.Count == 1) {
					if (!fitsInSameLine) {
						// draw box below line 
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2 - 1));
						g.ClosePath ();
						g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
						g.Fill ();
						
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.Stroke ();
					} else {
						// draw 'arrow marker' in the same line
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						double mid = y2 + topSize;
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
						
						g.LineTo (new Cairo.PointD (right, mid));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
						g.Color = colorMatrix[active, TOP, DARK, highlighted, selected];
						g.Fill ();
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, mid));
						
						g.LineTo (new Cairo.PointD (right, mid));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.ClosePath ();
						
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Fill ();
						
						// draw border
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
						
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.Stroke ();
					}
				} else {
					if (!fitsInSameLine) {
						// draw box below line
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2 - 1));
						g.ClosePath ();
					} else {
						// draw filled arrow box
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2Bottom));
						g.LineTo (new Cairo.PointD (right, y2));
						g.ClosePath ();
					}
					g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
					g.Fill ();
					
					// draw light bottom line
					g.MoveTo (new Cairo.PointD (right, y2Bottom));
					g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					g.Stroke ();
					
					// stroke left line
					if (fitsInSameLine) {
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2));
						g.LineTo (new Cairo.PointD (x2 - editor.LineHeight / 2 + 0.5, y2 + editor.LineHeight / 2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom));
					} else {
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y2 - 1));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2Bottom + 1));
					}
					
					g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
					g.Stroke ();
					
					// stroke top line
					if (fitsInSameLine) {
						g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
						g.MoveTo (new Cairo.PointD (right, y2));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y2));
						g.Stroke ();
					}
				}
				
				if (editor.Options.ShowRuler) {
					int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
					if (divider >= x2) {
						g.MoveTo (new Cairo.PointD (divider + 0.5, y2));
						g.LineTo (new Cairo.PointD (divider + 0.5, y2Bottom));
						g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
						g.Stroke ();
					}
				}
				
				if (errors.Count > 1 && errorCountLayout != null) {
					int rX = x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth;
					int rY = y + editor.LineHeight / 6;
					int rW = errorCounterWidth - 2;
					int rH = editor.LineHeight * 3 / 4;
					BookmarkMarker.DrawRoundRectangle (g, rX, rY, 8, rW, rH);
					
					g.Color = oldIsOver ? new Cairo.Color (0.3, 0.3, 0.3) : new Cairo.Color (0.5, 0.5, 0.5);
					g.Fill ();
					if (CollapseExtendedErrors) {
						win.DrawLayout (gcLight, x2 + (ShowIconsInBubble ? errorPixbuf.Width : 0) + border + LayoutWidth + 4, y + (editor.LineHeight - eh) / 2 + eh % 2, errorCountLayout);
					} else {
						g.MoveTo (rX + rW / 2 - rW / 4, rY + rH - rH / 4);
						g.LineTo (rX + rW / 2 + rW / 4, rY + rH - rH / 4);
						g.LineTo (rX + rW / 2, rY + rH / 4);
						g.ClosePath ();
						
						g.Color = new Cairo.Color (1, 1, 1);
						g.Fill ();
					}
				}
				
				for (int i = 0; i < layouts.Count; i++) {
					LayoutDescriptor layout = layouts[i];
					x2 = right - layout.Width - border - errorPixbuf.Width;
					if (i == 0)
						x2 -= errorCounterWidth;
					x2 = System.Math.Max (x2, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
					if (i > 0) {
						editor.TextViewMargin.DrawRectangleWithRuler (win, x, new Gdk.Rectangle (x, y, right, editor.LineHeight), isEolSelected ? editor.ColorStyle.Selection.BackgroundColor : editor.ColorStyle.Default.BackgroundColor, true);
						g.MoveTo (new Cairo.PointD (x2 + 0.5, y));
						g.LineTo (new Cairo.PointD (x2 + 0.5, y + editor.LineHeight));
						g.LineTo (new Cairo.PointD (right, y + editor.LineHeight));
						g.LineTo (new Cairo.PointD (right, y));
						g.ClosePath ();
						
						if (CollapseExtendedErrors) {
							Cairo.Gradient pat = new Cairo.LinearGradient (x2, y, x2, y + editor.LineHeight);
							pat.AddColorStop (0, colorMatrix[active, TOP, LIGHT, highlighted, selected]);
							pat.AddColorStop (1, colorMatrix[active, BOTTOM, LIGHT, highlighted, selected]);
							g.Pattern = pat;
						} else {
							g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
						}
						g.Fill ();
						if (editor.Options.ShowRuler) {
							int divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
							if (divider >= x2) {
								g.MoveTo (new Cairo.PointD (divider + 0.5, y));
								g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
								g.Color = colorMatrix[active, BOTTOM, DARK, highlighted, selected];
								g.Stroke ();
							}
						}
					}
					int lw, lh;
					layout.Layout.GetPixelSize (out lw, out lh);
					win.DrawLayout (selected == 0 ? gc : gcSelected, x2 + errorPixbuf.Width + border, y + (editor.LineHeight - layout.Height) / 2 + layout.Height % 2, layout.Layout);
					if (ShowIconsInBubble)
						win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors[i].IsError ? errorPixbuf : warningPixbuf, 0, 0, x2, y + (editor.LineHeight - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
					y += editor.LineHeight;
					if (!UseVirtualLines)
						break;
				}
			}
			return true;
		}
Пример #8
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Cairo.Color greenish = new Color(.3, .8, .8);
            Cairo.Color gray = new Color(.4, .4, .4);
            Cairo.Color white = new Color(1, 1, 1);

            string lvl, hp, hpm, mp, mpm, s;

            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                X + xpic, Y + ypic,
                Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            #endregion Status

            Graphics.ShadowedText(g, greenish, "Attack", X + x0, Y + ym);
            Graphics.ShadowedText(g, greenish, "Halve", X + x0, Y + yn);
            Graphics.ShadowedText(g, greenish, "Void", X + x0, Y + yo);
            Graphics.ShadowedText(g, greenish, "Absorb", X + x0, Y + yp);

            g.SetFontSize(16);

            double x = (double)x1;
            double r = (double)(ym + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Halves(e))
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                else
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yn + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Halves(e))
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                else
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yo + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Voids(e))
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                else
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                x += te.XAdvance;
            }

            x = (double)x1;
            r = (double)(yp + ys);
            foreach (Element e in Enum.GetValues(typeof(Element)))
            {
                if (x > W - stop)
                {
                    x = x1;
                    r = r + ys;
                }

                s = e.ToString() + " ";
                te = g.TextExtents(s);
                if (Selected.Absorbs(e))
                    Graphics.ShadowedText(g, white, e.ToString(), X + x, Y + r);
                else
                    Graphics.ShadowedText(g, gray, e.ToString(), X + x, Y + r);
                x += te.XAdvance;
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #9
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm, exp, next, llvl;

            #region Top Row

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                X + xpic, Y + ypic,
                Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();
            exp = Selected.Exp.ToString();
            next = Selected.ToNextLevel.ToString();
            llvl = Selected.LimitLevel.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            Graphics.ShadowedText(g, "Exp:", X + x8, Y + ya);
            Graphics.ShadowedText(g, "Next lvl:", X + x8, Y + yb);
            Graphics.ShadowedText(g, "Limit lvl:", X + x8, Y + yc);

            te = g.TextExtents(exp);
            Graphics.ShadowedText(g, exp, X + x12 - te.Width, Y + ya);
            te = g.TextExtents(next);
            Graphics.ShadowedText(g, next, X + x12 - te.Width, Y + yb);
            te = g.TextExtents(llvl);
            Graphics.ShadowedText(g, llvl, X + x11 - te.Width, Y + yc);

            #endregion Top

            #region Left

            string str, vit, dex, mag, spi, lck;
            string atk, atkp, def, defp, mat, mdf, mdfp;

            str = Selected.Strength.ToString();
            vit = Selected.Vitality.ToString();
            dex = Selected.Dexterity.ToString();
            mag = Selected.Magic.ToString();
            spi = Selected.Spirit.ToString();
            lck = Selected.Luck.ToString();

            atk = Ally.Attack(Selected).ToString();
            atkp = Ally.AttackPercent(Selected).ToString();
            def = Ally.Defense(Selected).ToString();
            defp = Ally.DefensePercent(Selected).ToString();
            mat = Ally.MagicAttack(Selected).ToString();
            mdf = Ally.MagicDefense(Selected).ToString();
            mdfp = Ally.MagicDefensePercent(Selected).ToString();

            Cairo.Color greenish = new Color(.3, .8, .8);

            Graphics.ShadowedText(g, greenish, "Strength", X + x0, Y + yq + (line * 0));
            Graphics.ShadowedText(g, greenish, "Vitality", X + x0, Y + yq + (line * 1));
            Graphics.ShadowedText(g, greenish, "Dexterity", X + x0, Y + yq + (line * 2));
            Graphics.ShadowedText(g, greenish, "Magic", X + x0, Y + yq + (line * 3));
            Graphics.ShadowedText(g, greenish, "Spirit", X + x0, Y + yq + (line * 4));
            Graphics.ShadowedText(g, greenish, "Luck", X + x0, Y + yq + (line * 5));

            Graphics.ShadowedText(g, greenish, "Attack", X + x0, Y + yr + (line * 0));
            Graphics.ShadowedText(g, greenish, "Attack %", X + x0, Y + yr + (line * 1));
            Graphics.ShadowedText(g, greenish, "Defense", X + x0, Y + yr + (line * 2));
            Graphics.ShadowedText(g, greenish, "Defense %", X + x0, Y + yr + (line * 3));
            Graphics.ShadowedText(g, greenish, "Magic", X + x0, Y + yr + (line * 4));
            Graphics.ShadowedText(g, greenish, "Magic def", X + x0, Y + yr + (line * 5));
            Graphics.ShadowedText(g, greenish, "Magic def %", X + x0, Y + yr + (line * 6));

            te = g.TextExtents(str);
            Graphics.ShadowedText(g, str, X + x1 - te.Width, Y + yq + (line * 0));
            te = g.TextExtents(vit);
            Graphics.ShadowedText(g, vit, X + x1 - te.Width, Y + yq + (line * 1));
            te = g.TextExtents(dex);
            Graphics.ShadowedText(g, dex, X + x1 - te.Width, Y + yq + (line * 2));
            te = g.TextExtents(mag);
            Graphics.ShadowedText(g, mag, X + x1 - te.Width, Y + yq + (line * 3));
            te = g.TextExtents(spi);
            Graphics.ShadowedText(g, spi, X + x1 - te.Width, Y + yq + (line * 4));
            te = g.TextExtents(lck);
            Graphics.ShadowedText(g, lck, X + x1 - te.Width, Y + yq + (line * 5));

            te = g.TextExtents(atk);
            Graphics.ShadowedText(g, atk, X + x1 - te.Width, Y + yr + (line * 0));
            te = g.TextExtents(atkp);
            Graphics.ShadowedText(g, atkp, X + x1 - te.Width, Y + yr + (line * 1));
            te = g.TextExtents(def);
            Graphics.ShadowedText(g, def, X + x1 - te.Width, Y + yr + (line * 2));
            te = g.TextExtents(defp);
            Graphics.ShadowedText(g, defp, X + x1 - te.Width, Y + yr + (line * 3));
            te = g.TextExtents(mat);
            Graphics.ShadowedText(g, mat, X + x1 - te.Width, Y + yr + (line * 4));
            te = g.TextExtents(mdf);
            Graphics.ShadowedText(g, mdf, X + x1 - te.Width, Y + yr + (line * 5));
            te = g.TextExtents(mdfp);
            Graphics.ShadowedText(g, mdfp, X + x1 - te.Width, Y + yr + (line * 6));

            #endregion Left

            #region Right

            g.Color = new Color(.1, .1, .2);
            g.Rectangle(x9, yi, 8 * xs, yj - yi);
            g.Fill();
            g.Rectangle(x9, yk, 8 * xs, yl - yk);
            g.Fill();

            Cairo.Color gray1 = new Color(.2, .2, .2);
            Cairo.Color gray2 = new Color(.7, .7, .8);

            int links, slots;

            slots = Selected.Weapon.Slots.Length;
            links = Selected.Weapon.Links;

            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys - zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys + zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                    X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                if (Selected.Weapon.Slots[i] == null)
                    Graphics.RenderCircle(g, gray1, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                else
                    Graphics.RenderCircle(g, Selected.Weapon.Slots[i].Color, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
            }

            slots = Selected.Armor.Slots.Length;
            links = Selected.Armor.Links;

            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys - zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys + zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                    X + x9 + (i * xs) + (xs / 2), Y + yk - ys);

                if (Selected.Armor.Slots[i] == null)
                    Graphics.RenderCircle(g, gray1, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
                else
                    Graphics.RenderCircle(g, Selected.Armor.Slots[i].Color, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
            }

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x7, Y + yh);
            g.ShowText("Wpn.");
            g.MoveTo(X + x7, Y + yj);
            g.ShowText("Arm.");
            g.MoveTo(X + x7, Y + yl);
            g.ShowText("Acc.");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Weapon.Name, X + x8, Y + yh);
            Graphics.ShadowedText(g, Selected.Armor.Name, X + x8, Y + yj);
            Graphics.ShadowedText(g, Selected.Accessory.Name, X + x8, Y + yl);

            #endregion Right

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #10
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;

            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                X + xpic, Y + ypic,
                Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + yc);

            #endregion Status

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #11
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;
            string weapon, armor, acc;

            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                X + xpic, Y + ypic,
                Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y + ya);

            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y + yb);

            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y + yb);

            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y + yc);

            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y + yc);

            #endregion Status

            #region Equipment

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x7, Y + yi);
            g.ShowText("Wpn.");
            g.MoveTo(X + x7, Y + yj);
            g.ShowText("Arm.");
            g.MoveTo(X + x7, Y + yk);
            g.ShowText("Acc.");
            g.Color = new Color(1, 1, 1);

            weapon = Selected.Weapon.Name;
            armor = Selected.Armor.Name;
            acc = Selected.Accessory.Name;

            te = g.TextExtents(weapon);
            Graphics.ShadowedText(g, weapon, X + x8, Y + yi);
            te = g.TextExtents(armor);
            Graphics.ShadowedText(g, armor, X + x8, Y + yj);
            te = g.TextExtents(acc);
            Graphics.ShadowedText(g, acc, X + x8, Y + yk);

            #endregion Equipment

            if (IsControl)
                Graphics.RenderCursor(g, X + cx, Y + cy - 10);

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
        protected override void Render(Gdk.Drawable drawable, 
            Widget widget, Gdk.Rectangle background_area, 
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, 
            CellRendererState flags)
        {
            StateType state = RendererStateToWidgetState(flags);
            int text_indent = 6;
            int text_layout_width, text_layout_height;
            Gdk.Pixbuf render_icon = radio_icon;
            Track track = null;
            RadioTrackInfo radio_track = null;
            string text = Text;

            if(widget is TreeView) {
                TreePath path;
                if((widget as TreeView).GetPathAtPos(cell_area.X, cell_area.Y, out path)) {
                    track = model.GetTrack(path);
                    radio_track = model.GetRadioTrackInfo(path);
                }
            }

            FontDescription font_description = widget.PangoContext.FontDescription.Copy();

            if(playing_icon != null && track != null && PlayerEngineCore.CurrentTrack is RadioTrackInfo
                && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Title == track.Title
                && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Annotation == track.Annotation) {
                render_icon = playing_icon;
                font_description.Style = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Bold;
            } else if(radio_track != null && radio_track.ParsingPlaylist) {
                render_icon = loading_icon;
                font_description.Style = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                text = String.Format("{0}: {1}", Catalog.GetString("Loading"), Text);
            } else if(radio_track != null && radio_track.PlaybackError != TrackPlaybackError.None) {
                render_icon = error_icon;
                font_description.Style = Pango.Style.Italic;
                font_description.Weight = Pango.Weight.Normal;
                string prefix = null;

                switch(radio_track.PlaybackError) {
                    case TrackPlaybackError.ResourceNotFound:
                        prefix = Catalog.GetString("Missing");
                        break;
                    case TrackPlaybackError.CodecNotFound:
                        prefix = Catalog.GetString("No Codec");
                        break;
                    case TrackPlaybackError.Unknown:
                        prefix = Catalog.GetString("Unknown Error");
                        break;
                    default:
                        break;
                }

                if(prefix != null) {
                    text = String.Format("({0}) {1}", prefix, Text);
                }

                if(!(CellRendererState.Selected & flags).Equals(CellRendererState.Selected)) {
                    state = StateType.Insensitive;
                }

                if(track != null) {
                    track.Title = String.Empty;
                }
            } else {
                font_description.Style = Pango.Style.Normal;
                font_description.Weight = Pango.Weight.Normal;
            }

            Gdk.GC main_gc = widget.Style.TextGC(state);

            if(track != null) {
                drawable.DrawPixbuf(main_gc, render_icon, 0, 0,
                cell_area.X - render_icon.Width,
                cell_area.Y + ((cell_area.Height - render_icon.Height) / 2),
                render_icon.Width, render_icon.Height,
                RgbDither.None, 0, 0);
            } else {
                text_indent = 0;
            }

            Pango.Layout text_layout = new Pango.Layout(widget.PangoContext);
            text_layout.FontDescription = font_description;
            text_layout.SetMarkup(GLib.Markup.EscapeText(text));
            text_layout.GetPixelSize(out text_layout_width, out text_layout_height);

            drawable.DrawLayout(main_gc,
                cell_area.X + text_indent,
                cell_area.Y + ((cell_area.Height - text_layout_height) / 2),
                text_layout);
        }
Пример #13
0
        public static void RenderProfile(Gdk.Drawable d, int x, int y, Character c)
        {
            Gdk.GC gc = new Gdk.GC(d);

            d.DrawPixbuf(gc, c.Profile, 0, 0, x, y, c.Profile.Width, c.Profile.Height, Gdk.RgbDither.None, 0, 0);
        }
Пример #14
0
        public void draw(Gdk.Window win, Gdk.Color terr, Gdk.Color textcolor, Pango.Context pango_context)
        {
            Gdk.GC textcoloring = new Gdk.GC(win);
               		textcoloring.RgbFgColor = textcolor;
               	int carriedUnits = 0;
               	string extraLabel = "";
            GraphicsStorage store = GraphicsStorage.GetInstance();
            int cenTerrX = MapTerritory.centerX;
            int cenTerrY = MapTerritory.centerY;

               	/* Show flag */
               	Gdk.Pixbuf flag = store.AppropriateFlag(owner.CountryID);
               	if (flag != null && owner.Active)
               		win.DrawPixbuf(textcoloring, flag, 0, 0, cenTerrX, cenTerrY, flag.Width, flag.Height, RgbDither.Normal, 1, 1);

            /* Draw the map */
               	MapTerritory.draw(win, terr, textcolor);

               	/* Show radiation if destroyed */
               	if (destroyed)
            win.DrawPixbuf(textcoloring, store.Radiation, 0, 0, cenTerrX, cenTerrY, store.Radiation.Width, store.Radiation.Height, RgbDither.Normal, 1, 1);

               	/* Determine personnel carrier status */
               	foreach(TacticalUnit joe in units)
               		carriedUnits += joe.UnitsAboardCount;
               	if (carriedUnits > 0)
               		extraLabel = "(" + carriedUnits + ")";

            /* Draw the first N units staggered, then use a label to show further #'s */
               	for (int offset=0; offset < units.Count && offset < 3; offset++)
               	{
               		((TacticalUnit)units[offset]).draw(win, offset*5);
               	}

               	/* Label */
               	if (units.Count > 1 || carriedUnits > 0)
               	{
               	        Pango.Layout label = new Pango.Layout (pango_context);
            label.Wrap = Pango.WrapMode.Word;
            label.FontDescription = FontDescription.FromString ("Tahoma 8");
            label.SetMarkup ( units.Count.ToString() + extraLabel );

            int szX, szY;
            label.GetPixelSize(out szX, out szY);

            /*Redraw*/
            //			win.InvalidateRect(new Gdk.Rectangle(MapTerritory.centerX, MapTerritory.centerY, szX, szY), true);

            win.DrawLayout (textcoloring, MapTerritory.centerX, MapTerritory.centerY, label);
               	}
        }
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            bool hide_counts = source.EnabledCount <= 0;

            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_counts = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            if (!hide_counts) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10;

            if (!hide_counts && max_title_layout_width < 0) {
                hide_counts = true;
            }

            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            Gdk.GC main_gc = widget.Style.TextGC (state);

            drawable.DrawLayout (main_gc,
                cell_area.X + (icon == null ? 0 : icon.Width) + 6,
                Middle (cell_area, title_layout_height),
                title_layout);

            title_layout.Dispose ();

            if (icon != null) {
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    cell_area.X, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            if (hide_counts) {
                fd.Dispose ();
                return;
            }

            if (view != null && view.Cr != null) {
                view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                    ? view.Theme.TextMidColor
                    : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                view.Cr.MoveTo (
                    cell_area.X + cell_area.Width - count_layout_width - 2,
                    cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                PangoCairoHelper.ShowLayout (view.Cr, count_layout);
            }

            count_layout.Dispose ();
            fd.Dispose ();
        }
Пример #16
0
        public void showNuke(Gdk.Window win, int frame)
        {
            Gdk.GC whocares = new Gdk.GC(win);
             			GraphicsStorage store = GraphicsStorage.GetInstance();

             			Gdk.Pixbuf gfx = store.getFrame(store.Detonation, frame, store.DetonationFrames);

             			int x = MapTerritory.centerX - (gfx.Width/2);
             			int y = MapTerritory.centerY - (gfx.Height/2);

            win.DrawPixbuf(whocares, gfx, 0, 0, x, y, gfx.Width, gfx.Height, RgbDither.Normal, 1, 1);
        }
Пример #17
0
 public static void DrawProfile(Gdk.Drawable d, Gdk.GC gc, string name, int x, int y)
 {
     d.DrawPixbuf(gc, GetProfile(name), 0, 0, x, y,
         PROFILE_WIDTH, PROFILE_HEIGHT,
         Gdk.RgbDither.None, 0, 0);
 }
Пример #18
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            Character c = Globals.Party[2];
            if (c != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfileSmall(c.Name), 0, 0,
                    X + xpic, Y + ypic,
                    Graphics.PROFILE_WIDTH_SMALL, Graphics.PROFILE_HEIGHT_SMALL,
                    Gdk.RgbDither.None, 0, 0);

                Graphics.ShadowedText(g, c.Name, X + x1, Y + y0);
                Graphics.ShadowedText(g, "Level:", X + x2, Y + y1);

                string lvl = c.Level.ToString();
                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x3 - te.Width, Y + y1);

                string temp = "Exp:";
                te = g.TextExtents(temp);
                Graphics.ShadowedText(g, temp, X + x4 - te.Width, Y + y0);

                temp = "For level up:";
                te = g.TextExtents(temp);
                Graphics.ShadowedText(g, temp, X + x4 - te.Width, Y + y1);

                string exp = c.Exp.ToString() + "p";
                te = g.TextExtents(exp);
                Graphics.ShadowedText(g, exp, X + x5 - te.Width, Y + y0);

                string expNext = c.ToNextLevel.ToString() + "p";
                te = g.TextExtents(expNext);
                Graphics.ShadowedText(g, expNext, X + x5 - te.Width, Y + y1);
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #19
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;

            #region Character 1

            if (Globals.Party[0] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[0].Name), 0, 0,
                    X + x1, Y + yp,
                    Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y0 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y0 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y0 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                if (Globals.Party[0].Fury)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Fury]", X + x7, Y + y0);
                else if (Globals.Party[0].Sadness)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Sadness]", X + x7, Y + y0);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[0].Death)
                    namec = new Color(0.8, 0, 0);
                else if (Globals.Party[0].NearDeath)
                    namec = new Color(.8, .8, 0);

                Graphics.ShadowedText(g, namec, Globals.Party[0].Name,
                    X + x3,
                    Y + y0);

                lvl = Globals.Party[0].Level.ToString();
                hp = Globals.Party[0].HP.ToString() + "/";
                hpm = Globals.Party[0].MaxHP.ToString();
                mp = Globals.Party[0].MP.ToString() + "/";
                mpm = Globals.Party[0].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y0 + ya);

                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y0 + yb);

                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y0 + yb);

                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y0 + yc);

                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y0 + yc);
            }
            #endregion Character 1

            #region Character 2

            if (Globals.Party[1] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[1].Name), 0, 0,
                    X + x1, Y + yp + (y1 - y0),
                    Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y1 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y1 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y1 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                if (Globals.Party[1].Fury)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Fury]", X + x7, Y + y1);
                else if (Globals.Party[1].Sadness)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Sadness]", X + x7, Y + y1);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[1].Death)
                    namec = new Color(0.8, 0, 0);
                else if (Globals.Party[1].NearDeath)
                    namec = new Color(.8, .8, 0);

                Graphics.ShadowedText(g, namec, Globals.Party[1].Name,
                    X + x3,
                    Y + y1);

                lvl = Globals.Party[1].Level.ToString();
                hp = Globals.Party[1].HP.ToString() + "/";
                hpm = Globals.Party[1].MaxHP.ToString();
                mp = Globals.Party[1].MP.ToString() + "/";
                mpm = Globals.Party[1].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y1 + ya);

                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y1 + yb);

                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y1 + yb);

                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y1 + yc);

                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y1 + yc);
            }

            #endregion Character 2

            #region Character 3

            if (Globals.Party[2] != null)
            {
                d.DrawPixbuf(gc, Graphics.GetProfile(Globals.Party[2].Name), 0, 0,
                    X + x1, Y + yp + (y2 - y0),
                    Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT, Gdk.RgbDither.None, 0, 0);

                g.Color = new Color(.3, .8, .8);
                g.MoveTo(X + x3, Y + y2 + ya);
                g.ShowText("LV");
                g.MoveTo(X + x3, Y + y2 + yb);
                g.ShowText("HP");
                g.MoveTo(X + x3, Y + y2 + yc);
                g.ShowText("MP");
                g.Color = new Color(1, 1, 1);

                if (Globals.Party[2].Fury)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Fury]", X + x7, Y + y2);
                else if (Globals.Party[2].Sadness)
                    Graphics.ShadowedText(g, new Color(.7, 0, .7), "[Sadness]", X + x7, Y + y2);

                Color namec = new Color(1, 1, 1);
                if (Globals.Party[2].Death)
                    namec = new Color(0.8, 0, 0);
                else if (Globals.Party[2].NearDeath)
                    namec = new Color(.8, .8, 0);

                Graphics.ShadowedText(g, namec, Globals.Party[2].Name, X + x3, Y + y2);

                lvl = Globals.Party[2].Level.ToString();
                hp = Globals.Party[2].HP.ToString() + "/";
                hpm = Globals.Party[2].MaxHP.ToString();
                mp = Globals.Party[2].MP.ToString() + "/";
                mpm = Globals.Party[2].MaxMP.ToString();

                te = g.TextExtents(lvl);
                Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y2 + ya);

                te = g.TextExtents(hp);
                Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y2 + yb);

                te = g.TextExtents(hpm);
                Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y2 + yb);

                te = g.TextExtents(mp);
                Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y2 + yc);

                te = g.TextExtents(mpm);
                Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y2 + yc);
            }

            #endregion Character 3

            if (IsControl)
                Graphics.RenderCursor(g, X + cx, Y + cy);

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Пример #20
0
        public void Draw(Gdk.Drawable d)
        {
            if (!Visible)
                return;

            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            d.DrawPixbuf(gc, _background, 0, 0, _x, _y, _w, _h, Gdk.RgbDither.None, 0, 0);

            int x0 = _x, x1 = _x + _w;
            int y0 = _y, y1 = _y + _h;

            g.MoveTo(x0 + 3, y0);
            g.LineTo(x1 - 3, y0);
            g.LineTo(x1, y0 + 3);
            g.LineTo(x1, y1 - 3);
            g.LineTo(x1 - 3, y1);
            g.LineTo(x0 + 3, y1);
            g.LineTo(x0, y1 - 3);
            g.LineTo(x0, y0 + 3);
            g.LineTo(x0 + 3, y0);
            g.ClosePath();
            g.LineWidth = 6;
            g.Color = new Color(0.8, 0.8, 0.8, _opaque ? 1 : 0.6);
            g.Stroke();

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();

            DrawContents(d);
        }
Пример #21
0
		protected override void Render (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
		{
			int x;
			int y;
			int width;
			int height;
			
			Gdk.Pixbuf buf = widget.RenderIcon(_stockId, Gtk.IconSize.Menu, string.Empty);
			
			Gtk.StateType state = Gtk.StateType.Normal;
			
			if (Prelight)
			{
				state = Gtk.StateType.Prelight;
			}
			if (Active)
			{
				state = Gtk.StateType.Active;	
			}
			
			GetSize(widget, ref cell_area, out x, out y, out width, out height); 
			Gtk.Style.PaintBox(widget.Style, window, state,
			                      Gtk.ShadowType.In, cell_area, widget, "buttondefault",
			                      cell_area.X + x, cell_area.Y + y,
			                      width, height);
			
			Gdk.GC gc = new Gdk.GC(window);
			
			if (buf != null)
			{
				int xOffset = 2 + ((width - buf.Width) / 2) + cell_area.X;
				int yOffset = 2 + ((height - buf.Height) / 2) + cell_area.Y;
								
				window.DrawPixbuf(gc, buf, 0, 0, xOffset, yOffset, buf.Width, buf.Height, Gdk.RgbDither.None, 0, 0);	
			}
			
			_x = cell_area.X + x;
			_y = cell_area.Y + y;
		}
		public void DrawIcon (Mono.TextEditor.TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int x, int y, int width, int height)
		{
			if (DebuggingService.IsDebugging)
				return;
			win.DrawPixbuf (editor.Style.BaseGC (Gtk.StateType.Normal), errors.Any (e => e.IsError) ? errorPixbuf : warningPixbuf, 0, 0, x + (width - errorPixbuf.Width) / 2, y + (height - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
		}
Пример #23
0
        private void DrawAnimate(Gdk.Window window)
        {
            Gdk.GC gc = Style.ForegroundGC (StateType.Normal);

            if (info.stage != MoveStage.SetPosition)
              {
                  return;
              }

            for (int i = 0; i < info.animate_list.Count; i++)
              {
                  int x_from, y_from, x_to, y_to, x, y;

                  AnimationTaskItem item =
                      (AnimationTaskItem) info.
                      animate_list[i];

                  if (!side)
                    {
                        //White
                        x_from = start_x +
                            item.from.x * (space +
                                   size);
                        y_from = start_y +
                            item.from.y * (space +
                                   size);

                        x_to = start_x +
                            item.to.x * (space +
                                 size);
                        y_to = start_y +
                            item.to.y * (space +
                                 size);
                    }
                  else
                    {
                        //Black
                        x_from = start_x + (7 -
                                item.from.x) *
                            (space + size);
                        y_from = start_y + (7 -
                                item.from.y) *
                            (space + size);

                        x_to = start_x + (7 -
                                  item.to.x) *
                            (space + size);
                        y_to = start_y + (7 -
                                  item.to.y) *
                            (space + size);
                    }

                  x = x_from +
                      (int) ((x_to -
                          x_from) * item.progress);
                  y = y_from +
                      (int) ((y_to -
                          y_from) * item.progress);

                  window.DrawPixbuf (gc,
                             figure.GetPixbuf (item.
                                       fig),
                             0, 0, x, y, size, size,
                             Gdk.RgbDither.None, 0,
                             0);

              }
            return;
        }
Пример #24
0
        protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
            Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (source == null || source is SourceManager.GroupSource) {
                return;
            }

            view = widget as SourceView;
            bool selected = view != null && view.Selection.IterIsSelected (iter);
            StateType state = RendererStateToWidgetState (widget, flags);

            RenderSelection (drawable, background_area, selected, state);

            int title_layout_width = 0, title_layout_height = 0;
            int count_layout_width = 0, count_layout_height = 0;
            int max_title_layout_width;

            int img_padding = 6;
            int expander_icon_spacing = 3;
            int x = cell_area.X;
            bool np_etc = (source.Order + Depth * 100) < 40;
            if (!np_etc) {
                x += Depth * img_padding + (int)Xpad;
            } else {
                // Don't indent NowPlaying and Play Queue as much
                x += Math.Max (0, (int)Xpad - 2);
            }

            Gdk.GC main_gc = widget.Style.TextGC (state);

            // Draw the expander if the source has children
            double exp_h = (cell_area.Height - 2.0*Ypad) / 3.2;
            double exp_w = exp_h * 1.6;
            if (view != null && view.Cr != null && source.Children != null && source.Children.Count > 0) {
                var r = new Gdk.Rectangle (x, cell_area.Y + (int)((cell_area.Height - exp_h) / 2.0), (int)exp_w, (int)exp_h);
                view.Theme.DrawArrow (view.Cr, r, source.Expanded ? Math.PI/2.0 : 0.0);
            }

            if (!np_etc) {
                x += (int) exp_w;
                x += 2; // a little spacing after the expander
                expander_right_x = x;
            }

            // Draw icon
            Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight);

            bool dispose_icon = false;
            if (state == StateType.Insensitive) {
                // Code ported from gtk_cell_renderer_pixbuf_render()
                var icon_source = new IconSource () {
                    Pixbuf = icon,
                    Size = IconSize.SmallToolbar,
                    SizeWildcarded = false
                };

                icon = widget.Style.RenderIcon (icon_source, widget.Direction, state,
                    (IconSize)(-1), widget, "SourceRowRenderer");

                dispose_icon = true;
                icon_source.Dispose ();
            }

            if (icon != null) {
                x += expander_icon_spacing;
                drawable.DrawPixbuf (main_gc, icon, 0, 0,
                    x, Middle (cell_area, icon.Height),
                    icon.Width, icon.Height, RgbDither.None, 0, 0);

                x += icon.Width;

                if (dispose_icon) {
                    icon.Dispose ();
                }
            }

            // Setup font info for the title/count, and see if we should show the count
            bool hide_count = source.EnabledCount <= 0 || source.Properties.Get<bool> ("SourceView.HideCount");
            FontDescription fd = widget.PangoContext.FontDescription.Copy ();
            fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source
                ? Pango.Weight.Bold
                : Pango.Weight.Normal;

            if (view != null && source == view.NewPlaylistSource) {
                fd.Style = Pango.Style.Italic;
                hide_count = true;
            }

            Pango.Layout title_layout = new Pango.Layout (widget.PangoContext);
            Pango.Layout count_layout = null;

            // If we have a count to draw, setup its fonts and see how wide it is to see if we have room
            if (!hide_count) {
                count_layout = new Pango.Layout (widget.PangoContext);
                count_layout.FontDescription = fd;
                count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.EnabledCount));
                count_layout.GetPixelSize (out count_layout_width, out count_layout_height);
            }

            // Hide the count if the title has no space
            max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10;
            if (!hide_count && max_title_layout_width <= 0) {
                hide_count = true;
            }

            // Draw the source Name
            title_layout.FontDescription = fd;
            title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale);
            title_layout.Ellipsize = EllipsizeMode.End;
            title_layout.SetText (source.Name);
            title_layout.GetPixelSize (out title_layout_width, out title_layout_height);

            x += img_padding;
            drawable.DrawLayout (main_gc, x, Middle (cell_area, title_layout_height), title_layout);

            title_layout.Dispose ();

            // Draw the count
            if (!hide_count) {
                if (view != null && view.Cr != null) {
                    view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight)
                        ? view.Theme.TextMidColor
                        : view.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);

                    view.Cr.MoveTo (
                        cell_area.X + cell_area.Width - count_layout_width - 2,
                        cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0);
                    PangoCairoHelper.ShowLayout (view.Cr, count_layout);
                }

                count_layout.Dispose ();
            }

            fd.Dispose ();
        }
Пример #25
0
        private void DrawDrag(Gdk.Window window)
        {
            Gdk.GC gc = Style.ForegroundGC (StateType.Normal);

            window.DrawPixbuf (gc,
                       figure.GetPixbuf (position.
                                 takenFig), 0,
                       0, info.drag.x - size / 2,
                       info.drag.y - size / 2, size,
                       size, Gdk.RgbDither.None, 0, 0);
        }
Пример #26
0
			protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
			{
				if (!Visible)
					return;
				int x = cell_area.X + 1;
				int y = cell_area.Y + 1;
				window.DrawPixbuf (widget.Style.BaseGC (StateType.Normal), pixbuf, 0, 0, x, y, pixbuf.Width, pixbuf.Height, Gdk.RgbDither.None, 0, 0);
			}
Пример #27
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Gdk.GC gc = new Gdk.GC(d);
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;

            string lvl, hp, hpm, mp, mpm;
            string weapon, armor;

            #region Slots

            g.Color = new Color(.1, .1, .2);
            g.Rectangle(x9, yi, 8 * xs, yj - yi);
            g.Fill();
            g.Rectangle(x9, yk, 8 * xs, yl - yk);
            g.Fill();

            Cairo.Color gray1 = new Color(.2, .2, .2);
            Cairo.Color gray2 = new Color(.7, .7, .8);

            int links, slots;

            slots = Selected.Weapon.Slots.Length;
            links = Selected.Weapon.Links;

            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys - zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yi - ys + zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yi - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                    X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                if (Selected.Weapon.Slots[i] == null)
                    Graphics.RenderCircle(g, gray1, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
                else
                    Graphics.RenderCircle(g, Selected.Weapon.Slots[i].Color, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yi - ys);
            }

            slots = Selected.Armor.Slots.Length;
            links = Selected.Armor.Links;

            for (int j = 0; j < links; j++)
            {
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys - zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys - zs);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys);
                Graphics.RenderLine(g, gray2, 3,
                    X + x9 + (xs / 2) + (j * 2 * xs), Y + yk - ys + zs,
                    X + x9 + (xs / 2) + ((j * 2 + 1) * xs), Y + yk - ys + zs);
            }
            for (int i = 0; i < slots; i++)
            {
                Graphics.RenderCircle(g, gray2, 14,
                    X + x9 + (i * xs) + (xs / 2), Y + yk - ys);

                if (Selected.Armor.Slots[i] == null)
                    Graphics.RenderCircle(g, gray1, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
                else
                    Graphics.RenderCircle(g, Selected.Armor.Slots[i].Color, 10,
                        X + x9 + (i * xs) + (xs / 2), Y + yk - ys);
            }

            #endregion

            #region Character Status

            d.DrawPixbuf(gc, Graphics.GetProfile(Selected.Name), 0, 0,
                X + xpic, Y + ypic,
                Graphics.PROFILE_WIDTH, Graphics.PROFILE_HEIGHT,
                Gdk.RgbDither.None, 0, 0);

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x3, Y + y + ya);
            g.ShowText("LV");
            g.MoveTo(X + x3, Y + y + yb);
            g.ShowText("HP");
            g.MoveTo(X + x3, Y + y + yc);
            g.ShowText("MP");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, Selected.Name, X + x3, Y + y);

            lvl = Selected.Level.ToString();
            hp = Selected.HP.ToString() + "/";
            hpm = Selected.MaxHP.ToString();
            mp = Selected.MP.ToString() + "/";
            mpm = Selected.MaxMP.ToString();

            te = g.TextExtents(lvl);
            Graphics.ShadowedText(g, lvl, X + x4 - te.Width, Y + y + ya);
            te = g.TextExtents(hp);
            Graphics.ShadowedText(g, hp, X + x5 - te.Width, Y + y + yb);
            te = g.TextExtents(hpm);
            Graphics.ShadowedText(g, hpm, X + x6 - te.Width, Y + y + yb);
            te = g.TextExtents(mp);
            Graphics.ShadowedText(g, mp, X + x5 - te.Width, Y + y + yc);
            te = g.TextExtents(mpm);
            Graphics.ShadowedText(g, mpm, X + x6 - te.Width, Y + y + yc);

            #endregion Status

            #region Equipment

            g.Color = new Color(.3, .8, .8);
            g.MoveTo(X + x7, Y + yh);
            g.ShowText("Wpn.");
            g.MoveTo(X + x7, Y + yj);
            g.ShowText("Arm.");
            g.Color = new Color(1, 1, 1);

            Graphics.ShadowedText(g, "Check", x7a, yja);
            Graphics.ShadowedText(g, "Arr.", x7a, yla);

            weapon = Selected.Weapon.Name;
            armor = Selected.Armor.Name;

            te = g.TextExtents(weapon);
            Graphics.ShadowedText(g, weapon, X + x8, Y + yh);
            te = g.TextExtents(armor);
            Graphics.ShadowedText(g, armor, X + x8, Y + yj);

            #endregion

            if (IsControl)
                Graphics.RenderCursor(g, X + cx, Y + cy - ys);

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }