本文整理汇总了C#中Gtk.Widget.SizeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.SizeRequest方法的具体用法?C# Widget.SizeRequest怎么用?C# Widget.SizeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Widget
的用法示例。
在下文中一共展示了Widget.SizeRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalcWidgetPosition
bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, 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 tmpWrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
tmpWrapper.Layout.GetPixelSize (out lw, out lh);
if (tmpWrapper.IsUncached)
tmpWrapper.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;
//We don't want Widget to appear outside TextArea(cut off)...
x = Math.Max (0, x);
y = Math.Max (0, y);
return true;
}
示例2: SetColumnWidth
private void SetColumnWidth(int index, Widget widget, int width, bool? visible = null)
{
Column c = mColumns[widget];
if (c != null)
{
if (visible != null)
c.Visible = visible.Value;
int dx = width - c.Width;
c.Width += dx;
Requisition r = widget.SizeRequest();
widget.SetSizeRequest(c.Width, r.Height);
this.Move(widget, c.X - mCurrentScollOffset, TopOffset); // move to same position, helper to redraw parent
// move all following
for (int i = index + 1; i < mColumns.Count; i++)
{
var kvp = mColumns.ElementAt(i);
c = kvp.Value;
if (c.Visible)
{
widget = kvp.Key;
c.X += dx;
this.Move(widget, c.X - mCurrentScollOffset, TopOffset);
}
}
}
}
示例3: PositionWidget
private bool PositionWidget (Widget widget, out int x, out int y, int yPadding)
{
int button_y, panel_width, panel_height;
Gtk.Requisition requisition = widget.SizeRequest ();
event_box.GdkWindow.GetOrigin (out x, out button_y);
(event_box.Toplevel as Gtk.Window).GetSize (out panel_width, out panel_height);
bool on_bottom = button_y + panel_height + requisition.Height >= event_box.Screen.Height;
y = on_bottom
? button_y - requisition.Height - yPadding
: button_y + panel_height + yPadding;
return on_bottom;
}
示例4: add_tool
public void add_tool(Widget w) {
if(w is Button || w is ToggleButton) {
w.HeightRequest = 30;
((Button)w).Relief = ReliefStyle.None;
} else if (w is ComboBox || w is ComboBoxEntry) {
w.WidthRequest = 200;
w.HeightRequest = 30;
} else if (w is Label) {
w.HeightRequest = 30;
} else if (w is VSeparator) {
w.HeightRequest = 30;
w.WidthRequest = 5;
}
this.fixed1.Add(w);
this.fixed1.Move(w,_nextx,_y);
_nextx = _nextx + w.SizeRequest().Width + _spacing;
w.ShowAll();
w.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) {
this.image1.TooltipText = ((Widget)o).TooltipText;
};
w.LeaveNotifyEvent += delegate(object o, LeaveNotifyEventArgs args) {
this.image1.TooltipText = "";
};
}