Exemplo n.º 1
0
 private void OnButtonPress(object sender, ButtonPressEventArgs e)
 {
     timer.Stop();
     if (e.Event.Button == 1 && e.Event.Type == Gdk.EventType.ButtonPress)
     {
         TreePath       path;
         TreeViewColumn col;
         // Get the clicked location
         if (treeview1.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path, out col))
         {
             // See if the click was on the current selection
             TreePath       selPath;
             TreeViewColumn selCol;
             treeview1.GetCursor(out selPath, out selCol);
             if (selPath != null && path.Compare(selPath) == 0)
             {
                 // Check where on the row we are located, allowing 16 pixels for the image, and 2 for its border
                 Gdk.Rectangle rect = treeview1.GetCellArea(path, col);
                 if (e.Event.X > rect.X + 18)
                 {
                     timer.Interval  = treeview1.GetSettings().DoubleClickTime + 10; // We want this to be a bit longer than the double-click interval, which is normally 250 milliseconds
                     timer.AutoReset = false;
                     timer.Start();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Shows the context menu for a TreeView.
 /// </summary>
 /// <returns><c>true</c>, if context menu was shown, <c>false</c> otherwise.</returns>
 /// <param name="tree">Gtk TreeView for which the context menu is shown</param>
 /// <param name="evt">The current mouse event, or <c>null</c>.</param>
 /// <param name="entrySet">Entry set with the command definitions</param>
 /// <param name="initialCommandTarget">Initial command target.</param>
 public static bool ShowContextMenu(this Gtk.TreeView tree, Gdk.EventButton evt, Commands.CommandEntrySet entrySet,
                                    object initialCommandTarget = null)
 {
     if (evt == null)
     {
         var paths = tree.Selection.GetSelectedRows();
         if (paths != null)
         {
             var area = tree.GetCellArea(paths [0], tree.Columns [0]);
             return(Ide.IdeApp.CommandService.ShowContextMenu(tree, area.Left, area.Top, entrySet, initialCommandTarget));
         }
         else
         {
             return(Ide.IdeApp.CommandService.ShowContextMenu(tree, 0, 0, entrySet, initialCommandTarget));
         }
     }
     else
     {
         int x = (int)evt.X, y = (int)evt.Y;
         if (Platform.IsMac && tree.BinWindow == evt.Window)
         {
             tree.ConvertBinWindowToWidgetCoords(x, y, out x, out y);
         }
         return(Ide.IdeApp.CommandService.ShowContextMenu(tree, x, y, entrySet, initialCommandTarget));
     }
 }
Exemplo n.º 3
0
        public static void GetTreeViewCoordinates(Gtk.TreeView tree, int rowIndex, int colIndex, out int x, out int y)
        {
            TreePath path = new TreePath(new int[1] {
                rowIndex
            });
            TreeViewColumn column = tree.Columns[colIndex];
            Rectangle      rect   = tree.GetCellArea(path, column);

            x = rect.X;
            y = rect.Y;
        }
Exemplo n.º 4
0
        // This is needed for when the user opens
        // the context menu with the keyboard.
        void PositionContextMenu(Gtk.Menu menu,
                                 out int x, out int y, out bool push_in)
        {
            Gtk.TreeIter      iter;
            Gtk.TreePath      path;
            Gtk.TreeSelection selection;

            // Set default "return" values
            push_in = false;             // not used
            x       = 0;
            y       = 0;

            selection = tree.Selection;
            if (selection.CountSelectedRows() > 1)
            {
                Gtk.TreePath [] paths = selection.GetSelectedRows();
                store_sort.GetIter(out iter, paths [0]);
            }
            else
            {
                if (!selection.GetSelected(out iter))
                {
                    return;
                }
            }

            path = store_sort.GetPath(iter);

            int pos_x = 0;
            int pos_y = 0;

            GetWidgetScreenPos(tree, ref pos_x, ref pos_y);
            Gdk.Rectangle cell_rect = tree.GetCellArea(path, tree.Columns [0]);

            // Add 100 to x so it's not be at the far left
            x = pos_x + cell_rect.X + 100;
            y = pos_y + cell_rect.Y;
        }
Exemplo n.º 5
0
		public CellTooltipWindow (TreeView tree, TreeViewColumn col, TreePath path)
		{
			this.tree = tree;
			this.col = col;
			
			NudgeHorizontal = true;
			
			Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
			
			Gdk.Rectangle rect = tree.GetCellArea (path, col);
			rect.Inflate (2, 2);
			
			if (!tree.Model.GetIter (out iter, path)) {
				Hide ();
				return;
			}

			col.CellSetCellData (tree.Model, iter, false, false);
			int x = 0;
			int th = 0;
			CellRenderer[] renderers = col.CellRenderers;
			foreach (CellRenderer cr in renderers) {
				int sp, wi, he, xo, yo;
				col.CellGetPosition (cr, out sp, out wi);
				Gdk.Rectangle crect = new Gdk.Rectangle (x, rect.Y, wi, rect.Height);
				cr.GetSize (tree, ref crect, out xo, out yo, out wi, out he);
				if (cr != renderers [renderers.Length - 1])
					x += crect.Width + col.Spacing + 1;
				else
					x += wi + 1;
				if (he > th) th = he;
			}
			SetSizeRequest (x, th + 2);
		}