本文整理汇总了C#中Gtk.Menu.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.SizeRequest方法的具体用法?C# Menu.SizeRequest怎么用?C# Menu.SizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Menu.SizeRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PositionMenu
private void PositionMenu (Menu menu, out int x, out int y, out bool push_in)
{
Gtk.Requisition menu_req = menu.SizeRequest ();
int monitor_num = Screen.GetMonitorAtWindow (GdkWindow);
Gdk.Rectangle monitor = Screen.GetMonitorGeometry (monitor_num < 0 ? 0 : monitor_num);
GdkWindow.GetOrigin (out x, out y);
y += Allocation.Y;
x += Allocation.X + (Direction == TextDirection.Ltr
? Math.Max (Allocation.Width - menu_req.Width, 0)
: -(menu_req.Width - Allocation.Width));
if (y + Allocation.Height + menu_req.Height <= monitor.Y + monitor.Height) {
y += Allocation.Height;
} else if (y - menu_req.Height >= monitor.Y) {
y -= menu_req.Height;
} else if (monitor.Y + monitor.Height - (y + Allocation.Height) > y) {
y += Allocation.Height;
} else {
y -= menu_req.Height;
}
push_in = false;
}
示例2: PositionPopupMenu
void PositionPopupMenu (Menu menu, out int x, out int y, out bool pushIn)
{
this.GdkWindow.GetOrigin (out x, out y);
x += this.menuPopupLocation.X;
y += this.menuPopupLocation.Y;
Requisition request = menu.SizeRequest ();
Gdk.Rectangle geometry = Screen.GetMonitorGeometry (Screen.GetMonitorAtPoint (x, y));
y = Math.Max (geometry.Top, Math.Min (y, geometry.Bottom - request.Height));
x = Math.Max (geometry.Left, Math.Min (x, geometry.Right - request.Width));
pushIn = true;
}
示例3: PositionMenu
private void PositionMenu(Menu menu, out int x, out int y, out bool push_in)
{
x = menu_x;
y = menu_y;
int monitor = ((Widget) menu).Screen.GetMonitorAtPoint (x, y );
Gdk.Rectangle rect = ((Widget) menu).Screen.GetMonitorGeometry (monitor);
int space_above = y - rect.Y;
int space_below = rect.Y + rect.Height - y;
Requisition requisition = menu.SizeRequest ();
if (requisition.Height <= space_above ||
requisition.Height <= space_below) {
if (requisition.Height <= space_below)
y += event_box.Allocation.Height;
else
y -= requisition.Height;
} else if (requisition.Height > space_below &&
requisition.Height > space_above) {
if (space_below >= space_above)
y = rect.Y + rect.Height - requisition.Height;
else
y = rect.Y;
} else {
y = rect.Y;
}
push_in = true;
}