private void HandleQueryTooltip(object o, Gtk.QueryTooltipArgs args) { var treeView = o as Gtk.TreeView; Gtk.TreePath path; Gtk.TreeViewColumn column; int x, y; treeView.ConvertWidgetToBinWindowCoords(args.X, args.Y, out x, out y); int cellX, cellY; if (treeView.GetPathAtPos(x, y, out path, out column, out cellX, out cellY)) { Gtk.TreeIter iter; if (treeView.Model.GetIter(out iter, path)) { var item = treeView.Model.GetValue(iter, 0) as ProgramDescriptionViewModel; var romListColumn = (RomListColumn)System.Array.IndexOf(treeView.Columns, column); var tooltip = string.Empty; switch (romListColumn) { case RomListColumn.None: tooltip = item.RomFileStatus; break; case RomListColumn.Title: tooltip = item.Name; break; case RomListColumn.Vendor: tooltip = item.Vendor; break; case RomListColumn.Year: ////tooltip = item.Year; break; case RomListColumn.Features: tooltip = INTV.Shared.Converter.ProgramFeaturesToPixbufConverter.GetFeatureTooltip(item, cellX, cellY); break; case RomListColumn.RomFile: tooltip = item.Rom.RomPath; break; case RomListColumn.ManualFile: throw new System.NotImplementedException("RomListView.HandleQueryTooltip(): ManualFile"); default: break; } if (!string.IsNullOrEmpty(tooltip)) { args.Tooltip.Text = tooltip; args.RetVal = true; } } } }
/// <summary> /// Provide a custom tooltip based on the cursor location. /// </summary> private void HandleQueryTooltip(object o, Gtk.QueryTooltipArgs args) { int x = args.X; int y = args.Y; string text = null; if (swap_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to switch between primary and secondary color."); } else if (reset_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to reset primary and secondary color."); } else if (primary_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to select primary color."); } else if (secondary_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to select secondary color."); } else if (PointToPalette(x, y) >= 0) { text = Catalog.GetString("Left click to set primary color. Right click to set secondary color. Middle click to choose palette color."); } args.Tooltip.Text = text; args.RetVal = (text != null); }
private void OnQueryTooltip(object o, Gtk.QueryTooltipArgs args) { if (cell_context != null && cell_context.Layout != null && !args.KeyboardTooltip) { ITooltipCell cell; Column column; int row_index; if (GetEventCell <ITooltipCell> (args.X, args.Y, out cell, out column, out row_index)) { CachedColumn cached_column = GetCachedColumnForColumn(column); string markup = cell.GetTooltipMarkup(cell_context, cached_column.Width); if (!String.IsNullOrEmpty(markup)) { Gdk.Rectangle rect = new Gdk.Rectangle(); rect.X = list_interaction_alloc.X + cached_column.X1; // get the y of the event in list coords rect.Y = args.Y - list_interaction_alloc.Y; // get the top of the cell pointed to by list_y rect.Y -= VadjustmentValue % RowHeight; rect.Y -= rect.Y % RowHeight; // convert back to widget coords rect.Y += list_interaction_alloc.Y; // TODO is this right even if the list is wide enough to scroll horizontally? rect.Width = cached_column.Width; // TODO not right - could be smaller if at the top/bottom and only partially showing rect.Height = RowHeight; args.Tooltip.Markup = markup; args.Tooltip.TipArea = rect; args.RetVal = true; } } } // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9 if (args.Tooltip != null) { args.Tooltip.Dispose(); } }
/// <summary> /// Provide a custom tooltip based on the cursor location. /// </summary> private void HandleQueryTooltip(object o, Gtk.QueryTooltipArgs args) { string?text = null; var point = new PointD(args.X, args.Y); switch (GetElementAtPoint(point)) { case WidgetElement.Palette: if (GetSwatchAtLocation(point) >= 0) { text = Translations.GetString("Left click to set primary color. Right click to set secondary color. Middle click to choose palette color."); } break; case WidgetElement.RecentColorsPalette: if (GetSwatchAtLocation(point, true) >= 0) { text = Translations.GetString("Left click to set primary color. Right click to set secondary color."); } break; case WidgetElement.PrimaryColor: text = Translations.GetString("Click to select primary color."); break; case WidgetElement.SecondaryColor: text = Translations.GetString("Click to select secondary color."); break; case WidgetElement.SwapColors: var label = Translations.GetString("Click to switch between primary and secondary color."); var shortcut_label = Translations.GetString("Shortcut key"); text = $"{label} {shortcut_label}: {"X"}"; break; case WidgetElement.ResetColors: text = Translations.GetString("Click to reset primary and secondary color."); break; } args.Tooltip.Text = text; args.RetVal = (text != null); }
/// <summary> /// Provide a custom tooltip based on the cursor location. /// </summary> private void HandleQueryTooltip(object o, Gtk.QueryTooltipArgs args) { int x = args.X; int y = args.Y; string text = null; if (swap_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to switch between primary and secondary color."); } else if (primary_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to select primary color."); } else if (secondary_rect.ContainsPoint(x, y)) { text = Catalog.GetString("Click to select secondary color."); } args.Tooltip.Text = text; args.RetVal = (text != null); }
private void OnQueryTooltip(object o, Gtk.QueryTooltipArgs args) { if (!args.KeyboardTooltip) { if (ViewLayout != null) { var pt = new Point(args.X - list_interaction_alloc.X, args.Y - list_interaction_alloc.Y); var child = ViewLayout.FindChildAtPoint(pt); if (child != null) { string markup; Rect area; pt.Offset(ViewLayout.ActualAllocation.Point); if (child.GetTooltipMarkupAt(pt, out markup, out area)) { area.Offset(-ViewLayout.ActualAllocation.X, -ViewLayout.ActualAllocation.Y); area.Offset(list_interaction_alloc.X, list_interaction_alloc.Y); args.Tooltip.Markup = markup; args.Tooltip.TipArea = (Gdk.Rectangle)area; /*if (!area.Contains (args.X, args.Y)) { * Log.WarningFormat ("Tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", area, args.X, args.Y); * }*/ args.RetVal = true; } } } else if (cell_context != null && cell_context.Layout != null) { ITooltipCell cell; Column column; int row_index; if (GetEventCell <ITooltipCell> (args.X, args.Y, out cell, out column, out row_index)) { CachedColumn cached_column = GetCachedColumnForColumn(column); string markup = cell.GetTooltipMarkup(cell_context, cached_column.Width); if (!String.IsNullOrEmpty(markup)) { Gdk.Rectangle rect = new Gdk.Rectangle(); rect.X = list_interaction_alloc.X + cached_column.X1; // get the y of the event in list coords rect.Y = args.Y - list_interaction_alloc.Y; // get the top of the cell pointed to by list_y rect.Y -= VadjustmentValue % ChildSize.Height; rect.Y -= rect.Y % ChildSize.Height; // convert back to widget coords rect.Y += list_interaction_alloc.Y; // TODO is this right even if the list is wide enough to scroll horizontally? rect.Width = cached_column.Width; // TODO not right - could be smaller if at the top/bottom and only partially showing rect.Height = ChildSize.Height; /*if (!rect.Contains (args.X, args.Y)) { * Log.WarningFormat ("ListView tooltip rect {0} does not contain tooltip point {1},{2} -- this will cause excessive requerying", rect, args.X, args.Y); * }*/ args.Tooltip.Markup = markup; args.Tooltip.TipArea = rect; args.RetVal = true; } } } } // Work around ref counting SIGSEGV, see http://bugzilla.gnome.org/show_bug.cgi?id=478519#c9 if (args.Tooltip != null) { args.Tooltip.Dispose(); } }
private void HandleMenuLayoutQueryTooltip(object o, Gtk.QueryTooltipArgs args) { var treeView = o as Gtk.TreeView; Gtk.TreePath path; Gtk.TreeViewColumn column; int x, y; treeView.ConvertWidgetToBinWindowCoords(args.X, args.Y, out x, out y); int cellX, cellY; if (treeView.GetPathAtPos(x, y, out path, out column, out cellX, out cellY)) { Gtk.TreeIter iter; if (treeView.Model.GetIter(out iter, path)) { var item = treeView.Model.GetValue(iter, 0) as FileNodeViewModel; var menuLayoutColumn = (MenuLayoutColumn)System.Array.IndexOf(treeView.Columns, column); var tooltip = string.Empty; switch (menuLayoutColumn) { case MenuLayoutColumn.None: tooltip = item.IconTipStrip; break; case MenuLayoutColumn.LongName: tooltip = MenuLayoutViewModel.LongNameTip; break; case MenuLayoutColumn.ShortName: tooltip = MenuLayoutViewModel.ShortNameTip; break; case MenuLayoutColumn.ManualFileOrDirectoryInfo: if (item is ProgramViewModel) { if (string.IsNullOrEmpty(item.Manual)) { tooltip = ProgramViewModel.ManualTip; } else { tooltip = item.Manual; } } break; case MenuLayoutColumn.FlashDataFile: if (item is ProgramViewModel) { if (string.IsNullOrEmpty(item.SaveData)) { ////tooltip = MenuLayoutCommandGroup.SetSaveDataCommand.ToolTip; } else { tooltip = item.SaveData; } } break; default: throw new System.InvalidOperationException("Unknown MenuLayoutColumn: " + menuLayoutColumn); } if (!string.IsNullOrEmpty(tooltip)) { args.Tooltip.Text = tooltip; args.RetVal = true; } } } }