当前位置: 首页>>代码示例>>C#>>正文


C# Gtk.TranslateCoordinates方法代码示例

本文整理汇总了C#中Gtk.TranslateCoordinates方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.TranslateCoordinates方法的具体用法?C# Gtk.TranslateCoordinates怎么用?C# Gtk.TranslateCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk的用法示例。


在下文中一共展示了Gtk.TranslateCoordinates方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCoordinates

        public Gdk.Rectangle GetCoordinates(Gtk.Widget w)
        {
            int px, py;
            if (!w.TranslateCoordinates (this, 0, 0, out px, out py))
                return new Gdk.Rectangle (0,0,0,0);

            Gdk.Rectangle rect = w.Allocation;
            rect.X = px - Allocation.X;
            rect.Y = py - Allocation.Y;
            return rect;
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:WorkbenchWindow.cs

示例2: PlaceSelectionBoxInternal

		void PlaceSelectionBoxInternal (Gtk.Widget widget)
		{
			int px, py;
			if (!widget.TranslateCoordinates (this, 0, 0, out px, out py))
				return;

			Gdk.Rectangle rect = widget.Allocation;
			rect.X = px;
			rect.Y = py;
			selectionBox.Reposition (rect);
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:11,代码来源:WidgetDesignerBackend.cs

示例3: ShowContextMenu

		public override bool ShowContextMenu (CommandManager commandManager, Gtk.Widget widget, double x, double y, CommandEntrySet entrySet, object initialCommandTarget = null)
		{
			Gtk.Application.Invoke (delegate {
				// Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
				Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
				var menu = new MDMenu (commandManager, entrySet, CommandSource.ContextMenu, initialCommandTarget);
				var nsview = MacInterop.GtkQuartz.GetView (widget);
				var toplevel = widget.Toplevel as Gtk.Window;
				int trans_x, trans_y;
				widget.TranslateCoordinates (toplevel, (int)x, (int)y, out trans_x, out trans_y);

				// Window coordinates in gtk are the same for cocoa, with the exception of the Y coordinate, that has to be flipped.
				var pt = new PointF ((float)trans_x, (float)trans_y);
				int w,h;
				toplevel.GetSize (out w, out h);
				pt.Y = h - pt.Y;

				var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown,
					pt,
					0, 0,
					MacInterop.GtkQuartz.GetWindow (toplevel).WindowNumber,
					null, 0, 0, 0);

				NSMenu.PopUpContextMenu (menu, tmp_event, nsview);
			});

			return true;
		}
开发者ID:sheff146,项目名称:monodevelop,代码行数:28,代码来源:MacPlatform.cs

示例4: Show

		public void Show (Gtk.Widget parent, int x, int y, Action closeHandler, bool selectFirstItem = false)
		{
			#if MAC
			if (Platform.IsMac) {
				int tx, ty;

				// x, y are in gtk coordinates, so they need to be translated for Cocoa.
				parent.TranslateCoordinates (parent.Toplevel, x, y, out tx, out ty);
				ContextMenuExtensionsMac.ShowContextMenu (parent, tx, ty, this, closeHandler, selectFirstItem);
				return;
			}
			#endif

			ContextMenuExtensionsGtk.ShowContextMenu (parent, x, y, this, closeHandler, selectFirstItem);
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:15,代码来源:ContextMenu.cs

示例5: ShowContextMenu

		public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, NSMenu menu)
		{
			int x, y;

			parent.TranslateCoordinates (parent.Toplevel, (int)evt.X, (int)evt.Y, out x, out y);

			ShowContextMenu (parent, x, y, menu);
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:8,代码来源:ContextMenuExtensionsMac.cs

示例6: ShowFixesMenu

		bool ShowFixesMenu (Gtk.Widget parent, Gdk.Rectangle evt, FixMenuDescriptor entrySet)
		{
			if (parent == null || parent.GdkWindow == null)
				return true;
			try {
				#if MAC
				parent.GrabFocus ();
				int x, y;
				x = (int)evt.X;
				y = (int)evt.Y;
				// Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event
				Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime);
				var menu = CreateNSMenu (entrySet);
				menu.Delegate = new ClosingMenuDelegate (document.Editor);
				var nsview = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView (parent);
				var toplevel = parent.Toplevel as Gtk.Window;
				int trans_x, trans_y;
				parent.TranslateCoordinates (toplevel, (int)x, (int)y, out trans_x, out trans_y);

				// Window coordinates in gtk are the same for cocoa, with the exception of the Y coordinate, that has to be flipped.
				var pt = new CoreGraphics.CGPoint ((float)trans_x, (float)trans_y);
				int w,h;
				toplevel.GetSize (out w, out h);
				pt.Y = h - pt.Y;

				var tmp_event = AppKit.NSEvent.MouseEvent (AppKit.NSEventType.LeftMouseDown,
				pt,
				0, 0,
				MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow (toplevel).WindowNumber,
				null, 0, 0, 0);

				AppKit.NSMenu.PopUpContextMenu (menu, tmp_event, nsview);
				#else
				var menu = CreateGtkMenu (entrySet);
				menu.Events |= Gdk.EventMask.AllEventsMask;
				menu.SelectFirst (true);

				menu.Hidden += delegate {
					document.Editor.SuppressTooltips = false;
				};
				menu.ShowAll ();
				menu.SelectFirst (true);
				menu.MotionNotifyEvent += (o, args) => {
					if (args.Event.Window == Editor.Parent.TextArea.GdkWindow) {
						StartMenuCloseTimer ();
					} else {
						CancelMenuCloseTimer ();
					}
				};

				GtkWorkarounds.ShowContextMenu (menu, parent, null, evt);
				#endif
			} catch (Exception ex) {
				LoggingService.LogError ("Error while context menu popup.", ex);
			}
			return true;
		}
开发者ID:nerzhulart,项目名称:monodevelop,代码行数:57,代码来源:CodeActionEditorExtension.cs


注:本文中的Gtk.TranslateCoordinates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。