當前位置: 首頁>>代碼示例>>C#>>正文


C# Menu.SizeRequest方法代碼示例

本文整理匯總了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;
		}
開發者ID:jira-sarec,項目名稱:ICSE-2012-TraceLab,代碼行數:25,代碼來源:MenuButton.cs

示例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;
		}
開發者ID:silk,項目名稱:monodevelop,代碼行數:12,代碼來源:ExtensibleTextEditor.cs

示例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;
        }
開發者ID:GNOME,項目名稱:last-exit,代碼行數:35,代碼來源:TrayIcon.cs


注:本文中的Gtk.Menu.SizeRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。