示例#1
0
		public static Gdk.Pixbuf LoadIcon (Gtk.Widget widget, string name, Gtk.IconSize size)
		{
			Gdk.Pixbuf res = widget.RenderIcon (name, size, null);
			if ((res != null)) {
				return res;
			} else {
				int sz;
				int sy;
				global::Gtk.Icon.SizeLookup (size, out  sz, out  sy);
				try {
					return Gtk.IconTheme.Default.LoadIcon (name, sz, 0);
				} catch (System.Exception) {
					if ((name != "gtk-missing-image")) {
						return Stetic.IconLoader.LoadIcon (widget, "gtk-missing-image", size);
					} else {
						Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz);
						Gdk.GC gc = new Gdk.GC (pmap);
						gc.RgbFgColor = new Gdk.Color (255, 255, 255);
						pmap.DrawRectangle (gc, true, 0, 0, sz, sz);
						gc.RgbFgColor = new Gdk.Color (0, 0, 0);
						pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1));
						gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
						gc.RgbFgColor = new Gdk.Color (255, 0, 0);
						pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
						pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
						return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
					}
				}
			}
		}
示例#2
0
 void SetRecognizeIcon(Gtk.Image img, float confidence)
 {
     if(confidence == 2) //Исправлено пользователем.
     {
         img.Pixbuf = img.RenderIcon(Stock.Apply, IconSize.Button, "");
         img.TooltipText =  String.Format("Исправлено.");
     }
     else if(confidence > 0.8)
     {
         img.Pixbuf = img.RenderIcon(Stock.Yes, IconSize.Button, "");
         img.TooltipText =  String.Format("ОК. Доверие: {0}", confidence);
     }
     else if(confidence == -1) //Распознования не проводилось
     {
         img.Pixbuf = img.RenderIcon(Stock.DialogQuestion, IconSize.Button, "");
         img.TooltipText =  String.Format("Распознование не проводилось.");
     }
     else if(confidence == -2) //Результат не прошел проверку.
     {
         img.Pixbuf = img.RenderIcon(Stock.No, IconSize.Button, "");
         img.TooltipText =  String.Format("Результат не прошёл проверку.");
     }
     else
     {
         img.Pixbuf = img.RenderIcon(Stock.DialogWarning, IconSize.Button, "");
         img.TooltipText =  String.Format("Не точно. Доверие: {0}", confidence);
     }
 }
示例#3
0
文件: Misc.cs 项目: GNOME/longomatch
 /// <summary>
 /// Loads the stock icon for a given name and size.
 /// </summary>
 /// <returns>The stock icon.</returns>
 /// <param name="widget">Widget to get the icon for. Themes can modify the stock icon for a specific widget.</param>
 /// <param name="name">Name.</param>
 /// <param name="size">Size as Gtk.IconSize.</param>
 public static Gdk.Pixbuf LoadStockIcon(Gtk.Widget widget, string name, Gtk.IconSize size)
 {
     Gdk.Pixbuf res = widget.RenderIcon (name, size, null);
     if ((res != null)) {
         return res;
     } else {
         return LoadMissingIcon (size);
     }
 }
		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 RenderDoc(Cairo.Context CairoContext, Gtk.Widget widget, int height)
        {
            Pixbuf icon = widget.RenderIcon (_IconName, _IconsSize, "");

            Pango.Layout Layout = Pango.CairoHelper.CreateLayout (CairoContext);
            Layout.FontDescription = _font;
            Layout.SetMarkup (_Text);

            int layout_x = icon.Width + 5;
            int layoutWidth, layoutHeight;
            Layout.GetPixelSize (out layoutWidth, out layoutHeight);

            int layout_y = (height - layoutHeight) / 2;
            CairoContext.MoveTo ((double) layout_x, (double) layout_y);
            Pango.CairoHelper.ShowLayout (CairoContext, Layout);

            Gdk.CairoHelper.SetSourcePixbuf (CairoContext, icon, 0, 0);
            CairoContext.Paint ();
            Layout.FontDescription.Dispose ();
            Layout.Dispose ();
        }