本文整理汇总了C#中Gtk.Widget类的典型用法代码示例。如果您正苦于以下问题:C# Widget类的具体用法?C# Widget怎么用?C# Widget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Widget类属于Gtk命名空间,在下文中一共展示了Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddScrolledWindow
public static ScrolledWindow AddScrolledWindow(Widget widget)
{
ScrolledWindow swindow = new ScrolledWindow();
swindow.Add(widget);
swindow.Show();
return swindow;
}
示例2: InitCell
public void InitCell (Widget container, bool diffMode, string[] lines, TreePath path)
{
if (isDisposed)
return;
this.lines = lines;
this.diffMode = diffMode;
this.path = path;
if (diffMode) {
if (lines != null && lines.Length > 0) {
int maxlen = -1;
int maxlin = -1;
for (int n=0; n<lines.Length; n++) {
if (lines [n].Length > maxlen) {
maxlen = lines [n].Length;
maxlin = n;
}
}
DisposeLayout ();
layout = CreateLayout (container, lines [maxlin]);
layout.GetPixelSize (out width, out lineHeight);
height = lineHeight * lines.Length;
}
else
width = height = 0;
}
else {
DisposeLayout ();
layout = CreateLayout (container, string.Join (Environment.NewLine, lines));
layout.GetPixelSize (out width, out height);
}
}
示例3: HighlightMatch
protected static string HighlightMatch (Widget widget, string text, string toMatch)
{
var lane = StringMatcher.GetMatcher (toMatch, false).GetMatch (text);
if (lane != null) {
StringBuilder result = new StringBuilder ();
int lastPos = 0;
for (int n=0; n < lane.Length; n++) {
int pos = lane[n];
if (pos - lastPos > 0)
result.Append (GLib.Markup.EscapeText (text.Substring (lastPos, pos - lastPos)));
result.Append ("<span foreground=\"");
var color = Mono.TextEditor.HslColor.GenerateHighlightColors (widget.Style.Base (StateType.Normal),
widget.Style.Text (StateType.Normal), 3)[2];
result.Append (color.ToPangoString ());
result.Append ("\">");
result.Append (GLib.Markup.EscapeText (text[pos].ToString ()));
result.Append ("</span>");
lastPos = pos + 1;
}
if (lastPos < text.Length)
result.Append (GLib.Markup.EscapeText (text.Substring (lastPos, text.Length - lastPos)));
return result.ToString ();
}
return GLib.Markup.EscapeText (text);
}
示例4: PhotoPopup
public PhotoPopup(Widget parent)
: base()
{
foreach (MenuNode node in AddinManager.GetExtensionNodes ("/FSpot/Menus/PhotoPopup"))
Append (node.GetMenuItem (parent));
ShowAll ();
}
示例5: Render
protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
base.Render (window, widget, background_area, cell_area, expose_area, flags);
if (PackageSourceViewModel == null)
return;
using (var layout = new Pango.Layout (widget.PangoContext)) {
layout.Alignment = Pango.Alignment.Left;
layout.SetMarkup (GetPackageSourceNameMarkup ());
int packageSourceNameWidth = GetLayoutWidth (layout);
StateType state = GetState (widget, flags);
layout.SetMarkup (GetPackageSourceDescriptionMarkup ());
window.DrawLayout (widget.Style.TextGC (state), cell_area.X + textSpacing, cell_area.Y + textTopSpacing, layout);
if (!PackageSourceViewModel.IsValid) {
using (var ctx = Gdk.CairoHelper.Create (window)) {
ctx.DrawImage (widget, warningImage, cell_area.X + textSpacing + packageSourceNameWidth + imageSpacing, cell_area.Y + textTopSpacing);
}
layout.SetMarkup (GetPackageSourceErrorMarkup ());
int packageSourceErrorTextX = cell_area.X + textSpacing + packageSourceNameWidth + (int)warningImage.Width + (2 * imageSpacing);
window.DrawLayout (widget.Style.TextGC (state), packageSourceErrorTextX, cell_area.Y + textTopSpacing, layout);
}
}
}
示例6: Construct
protected void Construct (Widget buttonWidget, Menu menu, bool showArrow)
{
WidgetFlags |= WidgetFlags.NoWindow;
button_widget = buttonWidget;
Menu = menu;
toggle_button.Parent = this;
toggle_button.FocusOnClick = false;
toggle_button.Relief = ReliefStyle.None;
toggle_button.Pressed += delegate { ShowMenu (); toggle_button.Active = true; };
toggle_button.Activated += delegate { ShowMenu (); };
box.Parent = this;
if (showArrow) {
box.PackStart (button_widget, true, true, 0);
alignment = new Alignment (0f, 0.5f, 0f, 0f);
arrow = new Arrow (ArrowType.Down, ShadowType.None);
alignment.Add (arrow);
box.PackStart (alignment, false, false, 5);
size_widget = box;
FocusChain = new Widget[] {toggle_button, box};
alignment.ShowAll ();
alignment.NoShowAll = true;
} else {
toggle_button.Add (button_widget);
size_widget = toggle_button;
}
ShowAll ();
}
示例7: MouseTracker
public MouseTracker (Gtk.Widget owner)
{
this.owner = owner;
Hovered = false;
MousePosition = new Gdk.Point(0, 0);
owner.Events = owner.Events | Gdk.EventMask.PointerMotionMask;
owner.MotionNotifyEvent += (object o, MotionNotifyEventArgs args) => {
MousePosition = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y);
if (MouseMoved != null)
MouseMoved (this, EventArgs.Empty);
};
owner.EnterNotifyEvent += (o, args) => {
Hovered = true;
if (HoveredChanged != null)
HoveredChanged (this, EventArgs.Empty);
};
owner.LeaveNotifyEvent += (o, args) => {
Hovered = false;
if (HoveredChanged != null)
HoveredChanged (this, EventArgs.Empty);
};
}
示例8: GetSize
public override void GetSize(Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int w, out int h)
{
x_offset = 0;
y_offset = 0;
w = width + ((int) Xpad) * 2;
h = height + ((int) Ypad) * 2;
}
示例9: GetSize
public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
{
base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height);
if (CategoryIcon != null) {
height = (int)CategoryIcon.Height + ((int)Ypad * 2) + topLevelTemplateHeadingTotalYPadding;
}
}
示例10: AttachAligned
protected void AttachAligned(int column, int row, string labelText,
double xalign, double yalign, Widget widget,
int colspan, bool leftAlign)
{
Table.AttachAligned(column, row, labelText, xalign, yalign, widget,
colspan, leftAlign);
}
示例11: Show
public void Show(Xwt.Popover.Position orientation, Xwt.Widget reference, Xwt.Rectangle positionRect, Widget child)
{
var parent = reference.ParentWindow;
popover = new PopoverWindow ((Gtk.Widget)((WidgetBackend)Toolkit.GetBackend (child)).NativeWidget, orientation);
popover.SetPadding (frontend.Padding);
popover.TransientFor = ((WindowFrameBackend)Toolkit.GetBackend (parent)).Window;
popover.DestroyWithParent = true;
popover.Hidden += (o, args) => {
popover.ReleaseInnerWidget ();
sink.OnClosed ();
popover.Destroy ();
};
var screenBounds = reference.ScreenBounds;
if (positionRect == Rectangle.Zero)
positionRect = new Rectangle (Point.Zero, screenBounds.Size);
positionRect = positionRect.Offset (screenBounds.Location);
var position = new Point (positionRect.Center.X, popover.ArrowPosition == Popover.Position.Top ? positionRect.Bottom : positionRect.Top);
popover.ShowAll ();
popover.GrabFocus ();
int w, h;
popover.GetSize (out w, out h);
popover.Move ((int)position.X - w / 2, (int)position.Y);
popover.SizeAllocated += (o, args) => { popover.Move ((int)position.X - args.Allocation.Width / 2, (int)position.Y); popover.GrabFocus (); };
}
示例12: AddWidget
private void AddWidget (PreferenceBase preference, Widget widget, Widget mnemonic_widget)
{
uint start_row = NRows;
uint start_col = 0;
Label label = null;
if (!(widget is CheckButton) && preference.ShowLabel) {
label = AttachLabel (preference.Name, start_row);
start_col++;
}
widget.Show ();
Attach (widget, start_col, 2, start_row, start_row + 1,
AttachOptions.Expand | AttachOptions.Fill,
AttachOptions.Expand | AttachOptions.Fill, 0, 0);
if (label != null) {
label.MnemonicWidget = mnemonic_widget ?? widget;
}
if (!String.IsNullOrEmpty (preference.Description)) {
if (tp_host == null) {
tp_host = TooltipSetter.CreateHost ();
}
TooltipSetter.Set (tp_host, widget, preference.Description);
if (label != null) {
TooltipSetter.Set (tp_host, label, preference.Description);
}
}
}
示例13: MphotoToplevel
public unsafe MphotoToplevel (IImageRepository _repo, string[] args, params object[] props)
: base ("Mphoto", "0.0", Modules.UI, args, props)
{
cwh = new Glade.XMLCustomWidgetHandler (GladeCustomWidgetHandler);
Glade.XML.SetCustomHandler (cwh);
gxml = new Glade.XML (null, "mphoto.glade", null, null);
Console.WriteLine ("Autoconnect");
gxml.Autoconnect (this);
// CreateCustomWidget ("browser_icon_list");
// CreateCustomWidget ("collections_tree_view");
// CreateCustomWidget ("imageinfo_tree_view");
// CreateCustomWidget ("eog_image_view");
// CreateCustomWidget ("keywords_widget");
this.leftside_notebook = (Gtk.Notebook) gxml["browser_left_notebook"];
this.top_level_notebook = (Gtk.Notebook) gxml["top_level_notebook"];
this.toplevel = gxml["mphoto_browser"];
this.label_zoom_value = (Gtk.Label) gxml["label_zoom_value"];
this.search_dialog = (Gtk.Window) gxml["search_dialog"];
this.Repository = _repo;
// initialize the tree views to the side
imageinfo_tree_view.IconList = icon_list;
keywords_widget.IconList = icon_list;
collections_tree_view.RowActivated += new RowActivatedHandler (CollectionsTreeViewActivateHandler);
icon_list.Activated += new EventHandler (IconlistActivated);
GlobalMphotoToplevel = this;
}
示例14: AddListItem
public ClosableExpander AddListItem (string name, Widget widget, PObject obj)
{
if (noContentLabel != null) {
contentBox.Remove (noContentLabel);
noContentLabel.Destroy ();
noContentLabel = null;
}
var expander = new ClosableExpander ();
expanders++;
expander.ContentLabel = name;
expander.SetWidget (widget);
expander.BorderWidth = 4;
expander.Closed += delegate(object sender, EventArgs e) {
expanders--;
var expanderWidget = (ClosableExpander)sender;
obj.Remove ();
contentBox.Remove (expanderWidget);
expanderWidget.Destroy ();
if (expanders == 0)
Clear ();
};
contentBox.PackStart (expander, true, true, 0);
contentBox.Show ();
expander.Expanded = false;
return expander;
}
示例15: CreateCellRenderer
public static CellViewBackend CreateCellRenderer (ApplicationContext actx, Widget widget, ICellRendererTarget col, object target, ICellViewFrontend view)
{
CellViewBackend crd;
if (view is ITextCellViewFrontend) {
crd = new CustomCellRendererText ();
}
else if (view is ICheckBoxCellViewFrontend) {
crd = new CustomCellRendererToggle ();
}
else if (view is IImageCellViewFrontend) {
crd = new CustomCellRendererImage ();
}
else if (view is ICanvasCellViewFrontend) {
crd = new CustomCellRenderer ();
}
else
throw new NotSupportedException ("Unknown cell view type: " + view.GetType ());
crd.Initialize (view, col, target);
col.PackStart (target, crd.CellRenderer, false);
col.SetCellDataFunc (target, crd.CellRenderer, (cellLayout, cell, treeModel, iter) => crd.LoadData (treeModel, iter));
view.AttachBackend (widget, crd);
return crd;
}