本文整理汇总了C#中Gtk.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.SizeRequest方法的具体用法?C# Gtk.SizeRequest怎么用?C# Gtk.SizeRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk
的用法示例。
在下文中一共展示了Gtk.SizeRequest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowTooltipWindow
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;
}
示例2: GtkEmbed
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: GetTopLevelPosition
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: GetMenuPosition
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: PositionWidget
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: GetRequiredPosition
protected virtual void GetRequiredPosition (TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
{
requiredWidth = tipWindow.SizeRequest ().Width;
xalign = 0.5;
}
示例7: CalcWidgetPosition
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;
}
示例8: GetRequiredPosition
public void GetRequiredPosition (Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
{
xalign = 0.1;
requiredWidth = tipWindow.SizeRequest ().Width;
}
示例9: GetTrayMenuPosition
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: PositionWidget
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 ();
}