本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}