public virtual Gtk.Window ShowTooltipWindow (MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			int ox = 0, oy = 0;
			if (editor.GdkWindow != null)
				editor.GdkWindow.GetOrigin (out ox, out oy);
			
			int w;
			double xalign;
			GetRequiredPosition (editor, tipWindow, out w, out xalign);
			w += 10;

			int x = mouseX + ox + editor.Allocation.X;
			int y = mouseY + oy + editor.Allocation.Y;
			Gdk.Rectangle geometry = editor.Screen.GetUsableMonitorGeometry (editor.Screen.GetMonitorAtPoint (x, y));
			
			x -= (int) ((double) w * xalign);
			y += 10;
			
			if (x + w >= geometry.X + geometry.Width)
				x = geometry.X + geometry.Width - w;
			if (x < geometry.Left)
				x = geometry.Left;
			
			int h = tipWindow.SizeRequest ().Height;
			if (y + h >= geometry.Y + geometry.Height)
				y = geometry.Y + geometry.Height - h;
			if (y < geometry.Top)
				y = geometry.Top;
			
			tipWindow.Move (x, y);
			
			tipWindow.ShowAll ();

			return tipWindow;
		}
		public GtkEmbed (Gtk.Widget w)
		{
			if (!GtkMacInterop.SupportsGtkIntoNSViewEmbedding ())
				throw new NotSupportedException ("GTK/NSView embedding is not supported by the installed GTK");

			embeddedWidget = w;
			var s = w.SizeRequest ();
			SetFrameSize (new CGSize (s.Width, s.Height));
			WatchForFocus (w);
		}
示例#3
0
		public Gdk.Rectangle GetTopLevelPosition (Gtk.Widget w)
		{
			foreach (TopLevelChild info in topLevels) {
				if (info.Child == w) {
					Gtk.Requisition req = w.SizeRequest ();
					return new Gdk.Rectangle (info.X, info.Y, req.Width, req.Height);
				}
			}
			return new Gdk.Rectangle (0,0,0,0);
		}
示例#4
0
		public static void GetMenuPosition (Gtk.Menu menu,
						    out int  x, 
						    out int  y, 
						    out bool push_in)
		{
			Gtk.Requisition menu_req = menu.SizeRequest ();

			menu.AttachWidget.GdkWindow.GetOrigin (out x, out y);

			if (y + menu_req.Height >= menu.AttachWidget.Screen.Height)
				y -= menu_req.Height;
			else
				y += menu.AttachWidget.Allocation.Height;

			push_in = true;
		}
示例#5
0
文件: PathBar.cs 项目: msiyer/Pinta
		void PositionWidget (Gtk.Widget widget)
		{
			if (!(widget is Gtk.Window))
				return;
			int ox, oy;
			ParentWindow.GetOrigin (out ox, out oy);
			int w;
			int itemXPosition = GetHoverXPosition (out w);
			int dx = ox + this.Allocation.X + itemXPosition;
			int dy = oy + this.Allocation.Bottom;
			
			var req = widget.SizeRequest ();
			
			Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry (Screen, Screen.GetMonitorAtPoint (dx, dy));
			int width = System.Math.Max (req.Width, w);
			if (width >= geometry.Width - spacing * 2) {
				width = geometry.Width - spacing * 2;
				dx = geometry.Left + spacing;
			}
			widget.WidthRequest = width;
			if (dy + req.Height > geometry.Bottom)
				dy = oy + this.Allocation.Y - req.Height;
			if (dx + width > geometry.Right)
				dx = geometry.Right - width;
			(widget as Gtk.Window).Move (dx, dy);
			(widget as Gtk.Window).Resize (width, req.Height);
			widget.GrabFocus ();
		}
示例#6
0
		protected virtual void GetRequiredPosition (TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
		{
			requiredWidth = tipWindow.SizeRequest ().Width;
			xalign = 0.5;
		}
		bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, Gtk.Widget w, out int x, out int y)
		{
			DocumentLine line = widget.TextEditor.Document.GetLine (widgetExtension.Line);
			if (line == null) {
				x = y = 0;
				return false;
			}

			int lw, lh;
			var wrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
			wrapper.Layout.GetPixelSize (out lw, out lh);
			if (wrapper.IsUncached)
				wrapper.Dispose ();
			lh = (int) TextEditor.TextViewMargin.GetLineHeight (widgetExtension.Line);
			x = (int)widget.TextEditor.TextViewMargin.XOffset + lw + 4;
			y = (int)widget.TextEditor.LineToY (widgetExtension.Line);
			int lineStart = (int)widget.TextEditor.TextViewMargin.XOffset;
			var size = w.SizeRequest ();

			switch (widgetExtension.HorizontalAlignment) {
			case HorizontalAlignment.LineLeft:
				x = (int)widget.TextEditor.TextViewMargin.XOffset;
				break;
			case HorizontalAlignment.LineRight:
				x = lineStart + lw + 4;
				break;
			case HorizontalAlignment.LineCenter:
				x = lineStart + (lw - size.Width) / 2;
				if (x < lineStart)
					x = lineStart;
				break;
			case HorizontalAlignment.Left:
				x = 0;
				break;
			case HorizontalAlignment.Right:
				break;
			case HorizontalAlignment.Center:
				break;
			case HorizontalAlignment.ViewLeft:
				break;
			case HorizontalAlignment.ViewRight:
				break;
			case HorizontalAlignment.ViewCenter:
				break;
			}

			switch (widgetExtension.VerticalAlignment) {
			case VerticalAlignment.LineTop:
				break; // the default
			case VerticalAlignment.LineBottom:
				y += lh - size.Height;
				break;
			case VerticalAlignment.LineCenter:
				y = y + (lh - size.Height) / 2;
				break;
			case VerticalAlignment.AboveLine:
				y -= size.Height;
				break;
			case VerticalAlignment.BelowLine:
				y += lh;
				break;
			}
			x += widgetExtension.OffsetX;
			y += widgetExtension.OffsetY;
			return true;
		}
		public void GetRequiredPosition (Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
		{
			xalign = 0.1;
			requiredWidth = tipWindow.SizeRequest ().Width;
		}
示例#9
0
		public void GetTrayMenuPosition (Gtk.Menu menu,
		                             out int  x,
		                             out int  y,
		                             out bool push_in)
		{
			// some default values in case something goes wrong
			push_in = true;
			x = 0;
			y = 0;
			
			Gdk.Screen screen;
			Gdk.Rectangle area;
			try {
#if WIN32 || MAC
				menu.Screen.Display.GetPointer (out x, out y);
				screen = menu.Screen;
				area.Height = 0;
#else
				Gtk.Orientation orientation;
				GetGeometry (out screen, out area, out orientation);
				x = area.X;
				y = area.Y;
#endif

				Gtk.Requisition menu_req = menu.SizeRequest ();
				if (y + menu_req.Height >= screen.Height)
					y -= menu_req.Height;
				else
					y += area.Height;
			} catch (Exception e) {
				Logger.Error ("Exception in GetTrayMenuPosition: " + e.ToString ());
			}
		}
示例#10
0
		void PositionWidget (Gtk.Widget widget)
		{
			if (!(widget is Gtk.Window))
				return;
			int ox, oy;
			ParentWindow.GetOrigin (out ox, out oy);
			int w;
			int dx = ox + this.Allocation.X + GetHoverXPosition (out w);
			int dy = oy + this.Allocation.Bottom;
			
			var req = widget.SizeRequest ();
			
			int width = System.Math.Max (req.Width, w);
			widget.WidthRequest = width;
			Gdk.Rectangle geometry = Screen.GetMonitorGeometry (Screen.GetMonitorAtPoint (dx, dy));
			
			if (dy + req.Height > geometry.Bottom)
				dy = oy + this.Allocation.Y - req.Height;
			if (dx + width > geometry.Right)
				dx = geometry.Right - width;
			(widget as Gtk.Window).Move (dx, dy);
			widget.GrabFocus ();
		}