示例#1
0
 public override void GetSize(Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int w, out int h)
 {
     x_offset = 0;
     y_offset = 0;
     w = width + ((int) Xpad) * 2;
     h = height + ((int) Ypad) * 2;
 }
		public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
		{
			base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);
			if (CategoryIcon != null) {
				height = (int)CategoryIcon.Height + ((int)Ypad * 2) + topLevelTemplateHeadingTotalYPadding;
			}
		}
 protected void AttachAligned(int column, int row, string labelText,
     double xalign, double yalign, Widget widget,
     int colspan, bool leftAlign)
 {
     Table.AttachAligned(column, row, labelText, xalign, yalign, widget,
       colspan, leftAlign);
 }
示例#4
0
        public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            var parent = reference.ParentWindow;
            popover = new PopoverWindow ((Gtk.Widget)((WidgetBackend)Toolkit.GetBackend (child)).NativeWidget, orientation);
            popover.SetPadding (frontend.Padding);
            popover.TransientFor = ((WindowFrameBackend)Toolkit.GetBackend (parent)).Window;
            popover.DestroyWithParent = true;
            popover.Hidden += (o, args) => {
                popover.ReleaseInnerWidget ();
                sink.OnClosed ();
                popover.Destroy ();
            };

            var screenBounds = reference.ScreenBounds;
            if (positionRect == Rectangle.Zero)
                positionRect = new Rectangle (Point.Zero, screenBounds.Size);
            positionRect = positionRect.Offset (screenBounds.Location);
            var position = new Point (positionRect.Center.X, popover.ArrowPosition == Popover.Position.Top ? positionRect.Bottom : positionRect.Top);
            popover.ShowAll ();
            popover.GrabFocus ();
            int w, h;
            popover.GetSize (out w, out h);
            popover.Move ((int)position.X - w / 2, (int)position.Y);
            popover.SizeAllocated += (o, args) => { popover.Move ((int)position.X - args.Allocation.Width / 2, (int)position.Y); popover.GrabFocus (); };
        }
示例#5
0
        private void AddWidget (PreferenceBase preference, Widget widget, Widget mnemonic_widget)
        {
            uint start_row = NRows;
            uint start_col = 0;

            Label label = null;

            if (!(widget is CheckButton) && preference.ShowLabel) {
                label = AttachLabel (preference.Name, start_row);
                start_col++;
            }

            widget.Show ();
            Attach (widget, start_col, 2, start_row, start_row + 1,
                AttachOptions.Expand | AttachOptions.Fill,
                AttachOptions.Expand | AttachOptions.Fill, 0, 0);

            if (label != null) {
                label.MnemonicWidget = mnemonic_widget ?? widget;
            }

            if (!String.IsNullOrEmpty (preference.Description)) {
                if (tp_host == null) {
                     tp_host = TooltipSetter.CreateHost ();
                }

                TooltipSetter.Set (tp_host, widget, preference.Description);
                if (label != null) {
                    TooltipSetter.Set (tp_host, label, preference.Description);
                }
            }
        }
示例#6
0
	public unsafe MphotoToplevel (IImageRepository _repo, string[] args, params object[] props)
		: base ("Mphoto", "0.0", Modules.UI, args, props)
	{
		cwh = new Glade.XMLCustomWidgetHandler (GladeCustomWidgetHandler);
		Glade.XML.SetCustomHandler (cwh);
		gxml = new Glade.XML (null, "mphoto.glade", null, null);

		Console.WriteLine ("Autoconnect");
		gxml.Autoconnect (this);

//        CreateCustomWidget ("browser_icon_list");
//        CreateCustomWidget ("collections_tree_view");
//        CreateCustomWidget ("imageinfo_tree_view");
//        CreateCustomWidget ("eog_image_view");
//        CreateCustomWidget ("keywords_widget");

		this.leftside_notebook = (Gtk.Notebook) gxml["browser_left_notebook"];
		this.top_level_notebook = (Gtk.Notebook) gxml["top_level_notebook"];

		this.toplevel = gxml["mphoto_browser"];
		this.label_zoom_value = (Gtk.Label) gxml["label_zoom_value"];
		this.search_dialog = (Gtk.Window) gxml["search_dialog"];

		this.Repository = _repo;

		// initialize the tree views to the side
		imageinfo_tree_view.IconList = icon_list;
		keywords_widget.IconList = icon_list;

		collections_tree_view.RowActivated += new RowActivatedHandler (CollectionsTreeViewActivateHandler);
		icon_list.Activated += new EventHandler (IconlistActivated);

		GlobalMphotoToplevel = this;
	}
示例#7
0
		public ClosableExpander AddListItem (string name, Widget widget, PObject obj)
		{
			if (noContentLabel != null) {
				contentBox.Remove (noContentLabel);
				noContentLabel.Destroy ();
				noContentLabel = null;
			}
			
			var expander = new ClosableExpander ();
			expanders++;
			expander.ContentLabel = name;
			expander.SetWidget (widget);
			expander.BorderWidth = 4;
			expander.Closed += delegate(object sender, EventArgs e) {
				expanders--;
				var expanderWidget = (ClosableExpander)sender;
				obj.Remove ();
				contentBox.Remove (expanderWidget);
				expanderWidget.Destroy ();
				if (expanders == 0)
					Clear ();
			};
			contentBox.PackStart (expander, true, true, 0);
			contentBox.Show ();
			expander.Expanded = false;
			return expander;
		}
 /// <summary>
 /// Constructs a new MonospacedTextViewControl wrapper.
 /// </summary>
 /// <param name="widget">
 /// The TextView widget to be wrapped.
 /// </param>
 public MonospacedTextViewControl(Widget widget)
     : base(widget)
 {
     TextTag tag = new TextTag("Monospaced");
     tag.Family = "Monospace";
     buffer.TagTable.Add(tag);
 }
        public bool OnEvent(Widget w)
        {
            Gdk.Rectangle viewport = w.Allocation;
            if (buffer == null) {
                double scale = Math.Max (viewport.Width / (double) info.Bounds.Width,
                             viewport.Height / (double) info.Bounds.Height);

                scale *= 1.2;
                buffer = new ImageInfo (info, w,
                            new Gdk.Rectangle (0, 0,
                                       (int) (info.Bounds.Width * scale),
                                       (int) (info.Bounds.Height * scale)));
                start = DateTime.UtcNow;
                //w.QueueDraw ();
                zoom = 1.0;
            }

            double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0);

            int n_x = (int) Math.Floor ((buffer.Bounds.Width - viewport.Width) * percent);
            int n_y = (int) Math.Floor ((buffer.Bounds.Height - viewport.Height) * percent);

            if (n_x != pan_x || n_y != pan_y) {
                //w.GdkWindow.Scroll (- (n_x - pan_x), - (n_y - pan_y));
                w.QueueDraw ();
                w.GdkWindow.ProcessUpdates (false);
                Console.WriteLine ("{0} {1} elapsed", DateTime.UtcNow, DateTime.UtcNow - start);
            }
            pan_x = n_x;
            pan_y = n_y;

            return percent < 1.0;
        }
		public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry, Widget editor)
		{
			GtkFeatureWidget fw = (GtkFeatureWidget) editor;
			ReferenceManager refmgr = new ReferenceManager ((DotNetProject) entry);
			refmgr.GtkPackageVersion = fw.SelectedVersion;
			refmgr.Dispose ();
		}
示例#11
0
 public static Gdk.Color GetGdkTextMidColor (Widget widget)
 {
     Cairo.Color color = GetCairoTextMidColor (widget);
     Gdk.Color gdk_color = new Gdk.Color ((byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255));
     Gdk.Colormap.System.AllocColor (ref gdk_color, true, true);
     return gdk_color;
 }
		public GtkTreeModelResult (Widget parent, TreeModel treeModel, int column, TreeIter iter) : base (parent)
		{
			ParentWidget = parent;
			TModel = treeModel;
			Column = column;
			resultIter = iter;
		}
示例#13
0
        public WelcomePageBarButton(string title, string href, string iconResource = null)
        {
            FontFamily = Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows;
            HoverColor = Styles.WelcomeScreen.Links.HoverColor;
            Color = Styles.WelcomeScreen.Links.Color;
            FontSize = Styles.WelcomeScreen.Links.FontSize;

            VisibleWindow = false;
            this.Text = GettextCatalog.GetString (title);
            this.actionLink = href;
            if (!string.IsNullOrEmpty (iconResource)) {
                imageHover = Xwt.Drawing.Image.FromResource (iconResource);
                imageNormal = imageHover.WithAlpha (0.7);
            }

            IconTextSpacing = Styles.WelcomeScreen.Links.IconTextSpacing;
            image = new Xwt.ImageView ();
            label = CreateLabel ();
            imageWidget = image.ToGtkWidget ();
            box.PackStart (imageWidget, false, false, 0);
            if (imageNormal == null)
                imageWidget.NoShowAll = true;
            box.PackStart (label, false, false, 0);
            box.ShowAll ();
            Add (box);

            Update ();

            Events |= (Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonReleaseMask);
        }
		public void InitCell (Widget container, bool diffMode, string[] lines, TreePath path)
		{
			if (isDisposed)
				return;
			this.lines = lines;
			this.diffMode = diffMode;
			this.path = path;
			
			if (diffMode) {
				if (lines != null && lines.Length > 0) {
					int maxlen = -1;
					int maxlin = -1;
					for (int n=0; n<lines.Length; n++) {
						if (lines [n].Length > maxlen) {
							maxlen = lines [n].Length;
							maxlin = n;
						}
					}
					DisposeLayout ();
					layout = CreateLayout (container, lines [maxlin]);
					layout.GetPixelSize (out width, out lineHeight);
					height = lineHeight * lines.Length;
				}
				else
					width = height = 0;
			}
			else {
				DisposeLayout ();
				layout = CreateLayout (container, string.Join (Environment.NewLine, lines));
				layout.GetPixelSize (out width, out height);
			}
		}
 public void Activate(Widget toplevel, Gdk.EventButton eb)
 {
     if (eb != null)
         Popup (null, null, null, eb.Button, eb.Time);
     else
         Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
 }
		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);

			if (PackageSourceViewModel == null)
				return;
				
			using (var layout = new Pango.Layout (widget.PangoContext)) {
				layout.Alignment = Pango.Alignment.Left;
				layout.SetMarkup (GetPackageSourceNameMarkup ());
				int packageSourceNameWidth = GetLayoutWidth (layout);
				StateType state = GetState (widget, flags);

				layout.SetMarkup (GetPackageSourceDescriptionMarkup ());

				window.DrawLayout (widget.Style.TextGC (state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout);

				if (!PackageSourceViewModel.IsValid) {
					using (var ctx = Gdk.CairoHelper.Create (window)) {
						ctx.DrawImage (widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing);
					}

					layout.SetMarkup (GetPackageSourceErrorMarkup ());
					int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing);
					window.DrawLayout (widget.Style.TextGC (state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout);
				}
			}
		}
示例#17
0
		public SdiWorkspaceWindow (DefaultWorkbench workbench, IViewContent content, Notebook tabControl, TabLabel tabLabel) : base ()
		{
			this.workbench = workbench;
			this.tabControl = tabControl;
			this.content = content;
			this.tabLabel = tabLabel;
			this.tabPage = content.Control;
			
			content.WorkbenchWindow = this;
			
			content.ContentNameChanged += new EventHandler(SetTitleEvent);
			content.DirtyChanged       += new EventHandler(SetTitleEvent);
			content.BeforeSave         += new EventHandler(BeforeSave);
			content.ContentChanged     += new EventHandler (OnContentChanged);
			
			ShadowType = ShadowType.None;
			box = new VBox ();
			box.PackStart (content.Control);
			Add (box);
			box.Show ();
			
			SetTitleEvent(null, null);
			
			commandHandler = new ViewCommandHandlers (this);
			Show ();
		}
示例#18
0
文件: CairoCell.cs 项目: GNOME/pdfmod
        protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState state)
        {
            if (Theme == null) {
                Theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (widget);
                Theme.Context.Radius = 3;
            }

            Context cr = Gdk.CairoHelper.Create (window);

            // Setup the drawing boundaries/positioning
            cr.Rectangle (cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
            cr.Clip ();
            cr.Translate (cell_area.X, cell_area.Y);

            // Clear any existing drawing
            cr.Rectangle (0, 0, cell_area.Width, cell_area.Height);
            cr.Color = Theme.ViewFill;
            cr.Fill ();

            if (state == CellRendererState.Selected) {
                Theme.DrawRowSelection (cr, 0, 0, cell_area.Width, cell_area.Height, true);
            } else if (state == CellRendererState.Focused) {
                Theme.DrawRowSelection (cr, 0, 0, cell_area.Width, cell_area.Height, false);
            }

            var border = Theme.TotalBorderWidth;
            cr.Translate (border, border);
            var width = cell_area.Width - 2 * border;
            var height = cell_area.Height - 2 * border;

            Render (cr, width, height, state);

            Hyena.Gui.CairoExtensions.DisposeContext (cr);
        }
示例#19
0
		protected static string HighlightMatch (Widget widget, string text, string toMatch)
		{
			var lane = StringMatcher.GetMatcher (toMatch, false).GetMatch (text);
			if (lane != null) {
				StringBuilder result = new StringBuilder ();
				int lastPos = 0;
				for (int n=0; n < lane.Length; n++) {
					int pos = lane[n];
					if (pos - lastPos > 0)
						result.Append (GLib.Markup.EscapeText (text.Substring (lastPos, pos - lastPos)));
					result.Append ("<span foreground=\"");
					var color = Mono.TextEditor.HslColor.GenerateHighlightColors (widget.Style.Base (StateType.Normal), 
						widget.Style.Text (StateType.Normal), 3)[2];
					result.Append (color.ToPangoString ());
					result.Append ("\">");
					result.Append (GLib.Markup.EscapeText (text[pos].ToString ()));
					result.Append ("</span>");
					lastPos = pos + 1;
				}
				if (lastPos < text.Length)
					result.Append (GLib.Markup.EscapeText (text.Substring (lastPos, text.Length - lastPos)));
				return result.ToString ();
			}
			
			return GLib.Markup.EscapeText (text);
		}
        public OneWidgetDialog(Widget widget)
        {
            this.Build ();

            var att = widget.GetType ().GetCustomAttributes (typeof(WidgetWindowAttribute), false);
            if (att.Length > 0)
                this.SetDefaultSize ((att [0] as WidgetWindowAttribute).DefaultWidth,
                                     (att [0] as WidgetWindowAttribute).DefaultHeight);

            widget.Show ();
            VBox.Add (widget);

            att = widget.GetType ().GetCustomAttributes (typeof(DisplayNameAttribute), true);
            if (att.Length > 0)
                Title = (att [0] as DisplayNameAttribute).DisplayName;

            tdiTab = widget as ITdiTab;
            if(tdiTab != null)
            {
                if(!String.IsNullOrWhiteSpace (tdiTab.TabName))
                    Title = tdiTab.TabName;
                tdiTab.TabParent = this;
                tdiTab.TabNameChanged += TdiTab_TabNameChanged;
                tdiTab.CloseTab += TdiTab_CloseTab;
            }

            this.ReshowWithInitialSize ();
        }
示例#21
0
		public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
		{
			x_offset = 0;
			y_offset = 0;
			width = 0;
			height = 0;
		}
示例#22
0
		public MouseTracker (Gtk.Widget owner)
		{
			this.owner = owner;
			Hovered = false;
			MousePosition = new Gdk.Point(0, 0);

			owner.Events = owner.Events | Gdk.EventMask.PointerMotionMask;

			owner.MotionNotifyEvent += (object o, MotionNotifyEventArgs args) => {
				MousePosition = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y);
				if (MouseMoved != null)
					MouseMoved (this, EventArgs.Empty);
			};

			owner.EnterNotifyEvent += (o, args) => {
				Hovered = true;
				if (HoveredChanged != null)
					HoveredChanged (this, EventArgs.Empty);
			};

			owner.LeaveNotifyEvent += (o, args) => {
				Hovered = false;
				if (HoveredChanged != null)
					HoveredChanged (this, EventArgs.Empty);
			};
		}
        public override void Render(Drawable window,
                                     Widget widget,
                                     Rectangle cell_area,
                                     Rectangle expose_area,
                                     StateType cell_state,
                                     IPhoto photo)
        {
            string text = GetRenderText (photo);

            var layout = new Pango.Layout (widget.PangoContext);
            layout.SetText (text);

            Rectangle layout_bounds;
            layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height);

            layout_bounds.Y = cell_area.Y;
            layout_bounds.X = cell_area.X + (cell_area.Width - layout_bounds.Width) / 2;

            if (layout_bounds.IntersectsWith (expose_area)) {
                Style.PaintLayout (widget.Style, window, cell_state,
                                   true, expose_area, widget, "IconView",
                                   layout_bounds.X, layout_bounds.Y,
                                   layout);
            }
        }
示例#24
0
        protected void Construct (Widget buttonWidget, Menu menu, bool showArrow)
        {
            WidgetFlags |= WidgetFlags.NoWindow;

            button_widget = buttonWidget;
            Menu = menu;

            toggle_button.Parent = this;
            toggle_button.FocusOnClick = false;
            toggle_button.Relief = ReliefStyle.None;
            toggle_button.Pressed += delegate { ShowMenu (); toggle_button.Active = true; };
            toggle_button.Activated += delegate { ShowMenu (); };

            box.Parent = this;

            if (showArrow) {
                box.PackStart (button_widget, true, true, 0);
                alignment = new Alignment (0f, 0.5f, 0f, 0f);
                arrow = new Arrow (ArrowType.Down, ShadowType.None);
                alignment.Add (arrow);
                box.PackStart (alignment, false, false, 5);
                size_widget = box;
                FocusChain = new Widget[] {toggle_button, box};
                alignment.ShowAll ();
                alignment.NoShowAll = true;
            } else {
                toggle_button.Add (button_widget);
                size_widget = toggle_button;
            }

            ShowAll ();
        }
示例#25
0
 public BorderWidget(Widget widget)
 {
     this.PackStart (box, false, false, 0);
     box.Add (widget);
     box.ExposeEvent += expose_box;
     box.SizeRequested += size_requested;
 }
 public PhotoPopup(Widget parent)
     : base()
 {
     foreach (MenuNode node in AddinManager.GetExtensionNodes ("/FSpot/Menus/PhotoPopup"))
         Append (node.GetMenuItem (parent));
     ShowAll ();
 }
示例#27
0
文件: CellUtil.cs 项目: m13253/xwt
		public static CellViewBackend CreateCellRenderer (ApplicationContext actx, Widget widget, ICellRendererTarget col, object target, ICellViewFrontend view)
		{
			CellViewBackend crd;

			if (view is ITextCellViewFrontend) {
				crd = new CustomCellRendererText ();
			}
			else if (view is ICheckBoxCellViewFrontend) {
				crd = new CustomCellRendererToggle ();
			}
			else if (view is IImageCellViewFrontend) {
				crd = new CustomCellRendererImage ();
			}
			else if (view is ICanvasCellViewFrontend) {
				crd = new CustomCellRenderer ();
			}
			else
				throw new NotSupportedException ("Unknown cell view type: " + view.GetType ());

			crd.Initialize (view, col, target);
			col.PackStart (target, crd.CellRenderer, false);
			col.SetCellDataFunc (target, crd.CellRenderer, (cellLayout, cell, treeModel, iter) => crd.LoadData (treeModel, iter));
			view.AttachBackend (widget, crd);
			return crd;
		}
示例#28
0
        public NoteWidget(INote note)
        {
            this.KeyPressEvent += OnNoteWidgetKeyPressed;
            this.note = note;
            this.text = ( (note == null) || (note.Text == null) ) ? string.Empty : note.Text.Trim ();

            this.ShowTabs = false;

            viewPage = MakeViewPage ();
            editPage = MakeEditPage ();

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            viewPageId = AppendPage (viewPage, new Gtk.Label ("View"));

            // The label below does not need to be translated because it's
            // for debugging purposes only.
            editPageId = AppendPage (editPage, new Gtk.Label ("Edit"));

            if (text == null || text == string.Empty) {
                // Go into edit mode (switch to the edit page)
                ShowPage (editPageId);
            } else {
                // Go to view mode (switch to the view page)
                ShowPage (viewPageId);
            }
            this.textView.Buffer.Changed += OnTextViewChanged;
        }
示例#29
0
 protected override void OnAdded (Widget widget)
 {
     if (first_add) {
         first_add = false;
         base.OnAdded (widget);
     }
 }
示例#30
0
 public static ScrolledWindow AddScrolledWindow(Widget widget)
 {
     ScrolledWindow swindow = new ScrolledWindow();
     swindow.Add(widget);
     swindow.Show();
     return swindow;
 }
示例#31
0
 public static void SetBackgroundColor(this Gtk.Widget widget, Gtk.StateType state, Xwt.Drawing.Color color)
 {
     widget.SetBackgroundColor(state.ToGtk3StateFlags(), color);
 }
示例#32
0
 public static void SetBackgroundColor(this Gtk.Widget widget, Xwt.Drawing.Color color)
 {
     widget.SetBackgroundColor(Gtk.StateFlags.Normal, color);
 }
示例#33
0
 public static Xwt.Drawing.Color GetBackgroundColor(this Gtk.Widget widget, Gtk.StateFlags state)
 {
     return(widget.StyleContext.GetBackgroundColor(state).ToXwtValue());
 }
示例#34
0
 public static Xwt.Drawing.Color GetBackgroundColor(this Gtk.Widget widget, Gtk.StateType state)
 {
     return(widget.GetBackgroundColor(state.ToGtk3StateFlags()));
 }
示例#35
0
 public static Xwt.Drawing.Color GetBackgroundColor(this Gtk.Widget widget)
 {
     return(widget.GetBackgroundColor(Gtk.StateFlags.Normal));
 }
示例#36
0
 public static Gdk.Rectangle ToWindowCoordinates(Gtk.Widget widget, Gdk.Window w, Gdk.Rectangle rect)
 {
     return(new Gdk.Rectangle(ToWindowCoordinates(widget, w, rect.X, rect.Y), rect.Size));
 }
示例#37
0
 public static void SetBackgroundColor(this Gtk.Widget widget, Gtk.StateFlags state, Xwt.Drawing.Color color)
 {
     widget.OverrideBackgroundColor(state, color.ToGtkRgbaValue());
 }
示例#38
0
 public void ShowPopup(Gtk.Widget widget, Gdk.Rectangle caret, PopupPosition position)
 {
     ShowPopup(widget, null, caret, position);
 }
示例#39
0
 public void ShowPopup(Gtk.Widget widget, Gdk.EventButton evt, PopupPosition position)
 {
     ShowPopup(widget, evt, Gdk.Rectangle.Zero, position);
 }
示例#40
0
        public static Xwt.Drawing.Context CreateXwtContext(this Gtk.Widget w)
        {
            var c = Gdk.CairoHelper.Create(w.GdkWindow);

            return(gtkToolkit.WrapContext(w, c));
        }
示例#41
0
 /// <summary>
 /// This method can be used to get a reliave Leave event for a widget, which
 /// is not fired if the pointer leaves the widget to enter a child widget.
 /// To ubsubscribe the event, dispose the object returned by the method.
 /// </summary>
 public static IDisposable SubscribeLeaveEvent(this Gtk.Widget w, System.Action leaveHandler)
 {
     return(new LeaveEventData(w, leaveHandler));
 }
示例#42
0
        public static T ReplaceWithWidget <T> (this Gtk.Widget oldWidget, T newWidget, bool transferChildren = false) where T : Gtk.Widget
        {
            Gtk.Container parent = (Gtk.Container)oldWidget.Parent;
            if (parent == null)
            {
                throw new InvalidOperationException();
            }

            if (parent is Box)
            {
                var box = (Box)parent;
                var bc  = (Gtk.Box.BoxChild)parent [oldWidget];
                box.Add(newWidget);
                var nc = (Gtk.Box.BoxChild)parent [newWidget];
                nc.Expand   = bc.Expand;
                nc.Fill     = bc.Fill;
                nc.PackType = bc.PackType;
                nc.Padding  = bc.Padding;
                nc.Position = bc.Position;
                box.Remove(oldWidget);
            }
            else if (parent is Table)
            {
                var table = (Table)parent;
                var bc    = (Gtk.Table.TableChild)parent [oldWidget];
                table.Add(newWidget);
                var nc = (Gtk.Table.TableChild)parent [newWidget];
                nc.BottomAttach = bc.BottomAttach;
                nc.LeftAttach   = bc.LeftAttach;
                nc.RightAttach  = bc.RightAttach;
                nc.TopAttach    = bc.TopAttach;
                nc.XOptions     = bc.XOptions;
                nc.XPadding     = bc.XPadding;
                nc.YOptions     = bc.YOptions;
                nc.YPadding     = bc.YPadding;
                table.Remove(oldWidget);
            }
            else if (parent is Paned)
            {
                var paned  = (Paned)parent;
                var bc     = (Gtk.Paned.PanedChild)parent [oldWidget];
                var resize = bc.Resize;
                var shrink = bc.Shrink;
                if (oldWidget == paned.Child1)
                {
                    paned.Remove(oldWidget);
                    paned.Add1(newWidget);
                }
                else
                {
                    paned.Remove(oldWidget);
                    paned.Add2(newWidget);
                }
                var nc = (Gtk.Paned.PanedChild)parent [newWidget];
                nc.Resize = resize;
                nc.Shrink = shrink;
            }
            else
            {
                throw new NotSupportedException();
            }

            if (transferChildren)
            {
                if (newWidget is Paned && oldWidget is Paned)
                {
                    var panedOld = (Paned)oldWidget;
                    var panedNew = (Paned)(object)newWidget;
                    if (panedOld.Child1 != null)
                    {
                        var c      = panedOld.Child1;
                        var bc     = (Gtk.Paned.PanedChild)panedOld [c];
                        var resize = bc.Resize;
                        var shrink = bc.Shrink;
                        panedOld.Remove(c);
                        panedNew.Add1(c);
                        var nc = (Gtk.Paned.PanedChild)panedNew [c];
                        nc.Resize = resize;
                        nc.Shrink = shrink;
                    }
                    if (panedOld.Child2 != null)
                    {
                        var c      = panedOld.Child2;
                        var bc     = (Gtk.Paned.PanedChild)panedOld [c];
                        var resize = bc.Resize;
                        var shrink = bc.Shrink;
                        panedOld.Remove(c);
                        panedNew.Add2(c);
                        var nc = (Gtk.Paned.PanedChild)panedNew [c];
                        nc.Resize = resize;
                        nc.Shrink = shrink;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            newWidget.Visible = oldWidget.Visible;
            return(newWidget);
        }
示例#43
0
 public static void SetHasWindow(this Gtk.Widget widget, bool value)
 {
     widget.HasWindow = value;
 }
示例#44
0
 protected override void OnRemoved(Gtk.Widget widget)
 {
     base.OnRemoved(widget);
     size_group.RemoveWidget(widget);
 }
示例#45
0
 protected override void OnRemoved(Widget widget)
 {
     base.OnRemoved(widget);
     child = null;
 }
示例#46
0
 public static void DrawImage(this Cairo.Context s, Gtk.Widget widget, Xwt.Drawing.Image image, double x, double y)
 {
     gtkToolkit.RenderImage(widget, s, image, x, y);
 }
示例#47
0
 public void Append(Gtk.Widget widget)
 {
     Append(widget, 0, 0);
 }
示例#48
0
 protected override void OnAdded(Gtk.Widget widget)
 {
     size_group.AddWidget(widget);
     base.OnAdded(widget);
 }
示例#49
0
        public MainToolbar()
        {
            executionTargetsChanged = DispatchService.GuiDispatch(new EventHandler(HandleExecutionTargetsChanged));

            IdeApp.Workspace.ActiveConfigurationChanged += (sender, e) => UpdateCombos();
            IdeApp.Workspace.ConfigurationsChanged      += (sender, e) => UpdateCombos();

            IdeApp.Workspace.SolutionLoaded   += (sender, e) => UpdateCombos();
            IdeApp.Workspace.SolutionUnloaded += (sender, e) => UpdateCombos();

            IdeApp.ProjectOperations.CurrentSelectedSolutionChanged += HandleCurrentSelectedSolutionChanged;

            WidgetFlags |= Gtk.WidgetFlags.AppPaintable;

            AddWidget(button);
            AddSpace(8);

            configurationCombo       = new Gtk.ComboBox();
            configurationCombo.Model = configurationStore;
            var ctx = new Gtk.CellRendererText();

            configurationCombo.PackStart(ctx, true);
            configurationCombo.AddAttribute(ctx, "text", 0);

            configurationCombosBox = new HBox(false, 8);

            var configurationComboVBox = new VBox();

            configurationComboVBox.PackStart(configurationCombo, true, false, 0);
            configurationCombosBox.PackStart(configurationComboVBox, false, false, 0);

            runtimeCombo       = new Gtk.ComboBox();
            runtimeCombo.Model = runtimeStore;
            ctx = new Gtk.CellRendererText();
            if (Platform.IsWindows)
            {
                ctx.Ellipsize = Pango.EllipsizeMode.Middle;
            }
            runtimeCombo.PackStart(ctx, true);
            runtimeCombo.SetCellDataFunc(ctx, RuntimeRenderCell);
            runtimeCombo.RowSeparatorFunc = RuntimeIsSeparator;

            var runtimeComboVBox = new VBox();

            runtimeComboVBox.PackStart(runtimeCombo, true, false, 0);
            configurationCombosBox.PackStart(runtimeComboVBox, false, false, 0);
            AddWidget(configurationCombosBox);

            buttonBarBox             = new Alignment(0.5f, 0.5f, 0, 0);
            buttonBarBox.LeftPadding = (uint)7;
            buttonBarBox.Add(buttonBar);
            buttonBarBox.NoShowAll = true;
            AddWidget(buttonBarBox);
            AddSpace(24);

            statusArea = new StatusArea();
            statusArea.ShowMessage(BrandingService.ApplicationName);

            var statusAreaAlign = new Alignment(0, 0, 1, 1);

            statusAreaAlign.Add(statusArea);
            contentBox.PackStart(statusAreaAlign, true, true, 0);
            AddSpace(24);

            statusAreaAlign.SizeAllocated += (object o, SizeAllocatedArgs args) => {
                Gtk.Widget toplevel = this.Toplevel;
                if (toplevel == null)
                {
                    return;
                }

                var pixel_scale = GtkWorkarounds.GetPixelScale();

                int  windowWidth   = toplevel.Allocation.Width;
                int  center        = windowWidth / 2;
                int  left          = Math.Max(center - (int)(300 * pixel_scale), args.Allocation.Left);
                int  right         = Math.Min(left + (int)(600 * pixel_scale), args.Allocation.Right);
                uint left_padding  = (uint)(left - args.Allocation.Left);
                uint right_padding = (uint)(args.Allocation.Right - right);

                if (left_padding != statusAreaAlign.LeftPadding || right_padding != statusAreaAlign.RightPadding)
                {
                    statusAreaAlign.SetPadding(0, 0, (uint)left_padding, (uint)right_padding);
                }
            };

            matchEntry = new SearchEntry();

            var searchFiles = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Files"));

            searchFiles.Activated += delegate {
                SetSearchCategory("files");
            };
            var searchTypes = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Types"));

            searchTypes.Activated += delegate {
                SetSearchCategory("type");
            };
            var searchMembers = this.matchEntry.AddMenuItem(GettextCatalog.GetString("Search Members"));

            searchMembers.Activated += delegate {
                SetSearchCategory("member");
            };

            matchEntry.ForceFilterButtonVisible = true;
            matchEntry.Entry.FocusOutEvent     += delegate {
                matchEntry.Entry.Text = "";
            };
            var cmd = IdeApp.CommandService.GetCommand(Commands.NavigateTo);

            cmd.KeyBindingChanged += delegate {
                UpdateSearchEntryLabel();
            };
            UpdateSearchEntryLabel();

            matchEntry.Ready       = true;
            matchEntry.Visible     = true;
            matchEntry.IsCheckMenu = true;
            matchEntry.Entry.ModifyBase(StateType.Normal, Style.Light(StateType.Normal));
            matchEntry.WidthRequest = 240;
            if (!Platform.IsMac && !Platform.IsWindows)
            {
                matchEntry.Entry.ModifyFont(Pango.FontDescription.FromString("Sans 9"));                   // TODO: VV: "Segoe UI 9"
            }
            matchEntry.RoundedShape   = true;
            matchEntry.Entry.Changed += HandleSearchEntryChanged;
            matchEntry.Activated     += (sender, e) => {
                var pattern = SearchPopupSearchPattern.ParsePattern(matchEntry.Entry.Text);
                if (pattern.Pattern == null && pattern.LineNumber > 0)
                {
                    popup.Destroy();
                    var doc = IdeApp.Workbench.ActiveDocument;
                    if (doc != null && doc.Editor != null)
                    {
                        doc.Select();
                        doc.Editor.Caret.Location = new Mono.TextEditor.DocumentLocation(pattern.LineNumber, pattern.Column > 0 ? pattern.Column : 1);
                        doc.Editor.CenterToCaret();
                        doc.Editor.Parent.StartCaretPulseAnimation();
                    }
                    return;
                }
                if (popup != null)
                {
                    popup.OpenFile();
                }
            };
            matchEntry.Entry.KeyPressEvent += (o, args) => {
                if (args.Event.Key == Gdk.Key.Escape)
                {
                    var doc = IdeApp.Workbench.ActiveDocument;
                    if (doc != null)
                    {
                        if (popup != null)
                        {
                            popup.Destroy();
                        }
                        doc.Select();
                    }
                    return;
                }
                if (popup != null)
                {
                    args.RetVal = popup.ProcessKey(args.Event.Key, args.Event.State);
                }
            };
            IdeApp.Workbench.RootWindow.WidgetEvent += delegate(object o, WidgetEventArgs args) {
                if (args.Event is Gdk.EventConfigure)
                {
                    PositionPopup();
                }
            };
            SizeAllocated += delegate {
                PositionPopup();
            };

            BuildToolbar();
            IdeApp.CommandService.RegisterCommandBar(buttonBar);

            AddinManager.ExtensionChanged += OnExtensionChanged;

            contentBox.PackStart(matchEntry, false, false, 0);

            var align = new Gtk.Alignment(0, 0, 1f, 1f);

            align.Show();
            align.TopPadding    = (uint)5;
            align.LeftPadding   = (uint)9;
            align.RightPadding  = (uint)18;
            align.BottomPadding = (uint)10;
            align.Add(contentBox);

            Add(align);
            SetDefaultSizes(-1, 21);

            configurationCombo.Changed += HandleConfigurationChanged;
            runtimeCombo.Changed       += HandleRuntimeChanged;
            UpdateCombos();

            button.Clicked += HandleStartButtonClicked;
            IdeApp.CommandService.RegisterCommandBar(this);

            IdeApp.CommandService.ActiveWidgetChanged += (sender, e) => {
                lastCommandTarget = new WeakReference(e.OldActiveWidget);
            };

            this.ShowAll();
            this.statusArea.statusIconBox.HideAll();
        }
示例#50
0
 protected override void OnAdded(Widget widget)
 {
     base.OnAdded(widget);
     child = widget;
 }
示例#51
0
 public void AddWidget(Gtk.Widget widget)
 {
     contentBox.PackStart(widget, false, false, 0);
 }
示例#52
0
        public void Append(Gtk.Widget widget, Gtk.AttachOptions x, Gtk.AttachOptions y)
        {
            uint row = table.NRows;

            table.Attach(widget, 0, 2, row, row + 1, x, y, 0, 0);
        }
 public string Validate(SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor)
 {
     return(null);
 }
示例#54
0
        internal void UpdateNotebook(TabStrip ts)
        {
            Gtk.Widget oldpage = null;
            int        oldtab  = -1;

            if (tabFocus != null)
            {
                oldpage  = tabFocus.Item.Widget;
                tabFocus = null;
            }
            else if (boundTabStrip != null)
            {
                oldpage = boundTabStrip.CurrentPage;
                oldtab  = boundTabStrip.CurrentTab;
            }

            ts.Clear();

            // Add missing pages
            foreach (DockObject ob in VisibleObjects)
            {
                DockGroupItem it = ob as DockGroupItem;
                ts.AddTab(it.Item.Widget, it.Item.Icon, it.Item.Label);
            }

            boundTabStrip = ts;

            if (currentTabPage != -1 && currentTabPage < boundTabStrip.TabCount)
            {
                boundTabStrip.CurrentTab = currentTabPage;
                // Discard the currentTabPage value. Current page is now tracked by the tab strip
                currentTabPage = -1;
            }
            else if (oldpage != null)
            {
                boundTabStrip.CurrentPage = oldpage;
            }

            if (boundTabStrip.CurrentTab == -1)
            {
                if (oldtab != -1)
                {
                    if (oldtab < boundTabStrip.TabCount)
                    {
                        boundTabStrip.CurrentTab = oldtab;
                    }
                    else
                    {
                        boundTabStrip.CurrentTab = boundTabStrip.TabCount - 1;
                    }
                }
                else
                {
                    boundTabStrip.CurrentTab = 0;
                }
            }
            if (Frame.CompactGuiLevel == 3 && IsNextToMargin(PositionType.Bottom, true))
            {
                boundTabStrip.BottomPadding = 3;
            }
            else
            {
                boundTabStrip.BottomPadding = 0;
            }
        }
示例#55
0
 public ResultsDataSource(Gtk.Widget widget)
 {
     this.widget = widget;
 }
示例#56
0
 void AddChild(Gtk.Widget child)
 {
     child.Parent = this;
     children.Add(new ContainerChild(this, child));
     child.Show();
 }
示例#57
0
        public void UpdateTab()
        {
            if (Child != null)
            {
                Widget w = Child;
                Remove(w);
                w.Destroy();
            }

            mainBox = new Alignment(0, 0, 1, 1);
            if (bar.Orientation == Gtk.Orientation.Horizontal)
            {
                box = new HBox();
                mainBox.LeftPadding = mainBox.RightPadding = 2;
            }
            else
            {
                box = new VBox();
                mainBox.TopPadding = mainBox.BottomPadding = 2;
            }

            Gtk.Widget customLabel = null;
            if (it.DockLabelProvider != null)
            {
                customLabel = it.DockLabelProvider.CreateLabel(bar.Orientation);
            }

            if (customLabel != null)
            {
                customLabel.ShowAll();
                box.PackStart(customLabel, true, true, 0);
            }
            else
            {
                if (it.Icon != null)
                {
                    box.PackStart(new Gtk.Image(it.Icon), false, false, 0);
                }

                if (!string.IsNullOrEmpty(it.Label))
                {
                    label           = new Gtk.Label(it.Label);
                    label.UseMarkup = true;
                    if (bar.Orientation == Gtk.Orientation.Vertical)
                    {
                        label.Angle = 270;
                    }
                    box.PackStart(label, true, true, 0);
                }
                else
                {
                    label = null;
                }
            }

            box.BorderWidth = 2;
            box.Spacing     = 2;
            mainBox.Add(box);
            mainBox.ShowAll();
            Add(mainBox);
            SetNormalColor();
        }
示例#58
0
 /// <summary>
 /// Enables the drop of components to experiment canvas
 /// </summary>
 /// <param name='canvas'>
 /// Canvas.
 /// </param>
 private void EnableDrop(Gtk.Widget canvas)
 {
     canvas.DragDataReceived += HandleDragDataReceived;
     Gtk.Drag.DestSet(canvas, DestDefaults.All, ComponentsLibraryPad.Targets, Gdk.DragAction.Copy);
 }
示例#59
0
        public StatusArea()
        {
            theme     = new StatusAreaTheme();
            renderArg = new RenderArg();

            mainContext   = new MainStatusBarContextImpl(this);
            activeContext = mainContext;
            contexts.Add(mainContext);

            VisibleWindow = false;
            NoShowAll     = true;
            WidgetFlags  |= Gtk.WidgetFlags.AppPaintable;

            statusIconBox.BorderWidth = 0;
            statusIconBox.Spacing     = 3;

            Action <bool> animateProgressBar =
                showing => this.Animate("ProgressBarFade",
                                        val => renderArg.ProgressBarAlpha = val,
                                        renderArg.ProgressBarAlpha,
                                        showing ? 1.0f : 0.0f,
                                        easing: Easing.CubicInOut);

            ProgressBegin += delegate {
                renderArg.ShowProgressBar = true;
//				StartBuildAnimation ();
                renderArg.ProgressBarFraction = 0;
                QueueDraw();
                animateProgressBar(true);
            };

            ProgressEnd += delegate {
                renderArg.ShowProgressBar = false;
//				StopBuildAnimation ();
                QueueDraw();
                animateProgressBar(false);
            };

            ProgressFraction += delegate(object sender, FractionEventArgs e) {
                renderArg.ProgressBarFraction = (float)e.Work;
                QueueDraw();
            };

            contentBox.PackStart(messageBox, true, true, 0);
            contentBox.PackEnd(statusIconBox, false, false, 0);
            contentBox.PackEnd(statusIconSeparator = new StatusAreaSeparator(), false, false, 0);
            contentBox.PackEnd(buildResultWidget   = CreateBuildResultsWidget(Orientation.Horizontal), false, false, 0);

            mainAlign              = new Alignment(0, 0.5f, 1, 0);
            mainAlign.LeftPadding  = 12;
            mainAlign.RightPadding = 8;
            mainAlign.Add(contentBox);
            Add(mainAlign);

            mainAlign.ShowAll();
            statusIconBox.Hide();
            statusIconSeparator.Hide();
            buildResultWidget.Hide();
            Show();

            this.ButtonPressEvent += delegate {
                if (sourcePad != null)
                {
                    sourcePad.BringToFront(true);
                }
            };

            statusIconBox.Shown += delegate {
                UpdateSeparators();
            };

            statusIconBox.Hidden += delegate {
                UpdateSeparators();
            };

            messageQueue = new Queue <Message> ();

            tracker                 = new MouseTracker(this);
            tracker.MouseMoved     += (sender, e) => QueueDraw();
            tracker.HoveredChanged += (sender, e) => {
                this.Animate("Hovered",
                             x => renderArg.HoverProgress = x,
                             renderArg.HoverProgress,
                             tracker.Hovered ? 1.0f : 0.0f,
                             easing: Easing.SinInOut);
            };

            IdeApp.FocusIn += delegate {
                // If there was an error while the application didn't have the focus,
                // trigger the error animation again when it gains the focus
                if (errorAnimPending)
                {
                    errorAnimPending = false;
                    TriggerErrorAnimation();
                }
            };
        }
示例#60
0
 public void SetWidget(Gtk.Widget widget)
 {
     contentBox.PackStart(widget, true, true, 0);
     header.UpdateInitialExpanderState();
 }