public override void SetBackgroundColor(NSCell cell, Color color) { var c = cell as EtoCell; c.BackgroundColor = Generator.ConvertNS(color); c.DrawsBackground = color != Colors.Transparent; }
public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell) { cell.ObjectValue = value as NSObject; var size = cell.CellSizeForBounds(new CGRect(0, 0, nfloat.MaxValue, cellSize.Height)).Width; return(size); }
void ICopiableObject.CopyFrom(object other) { var ob = (CompositeCell)other; if (ob.source == null) { throw new ArgumentException("Cannot copy from a CompositeCell with a null `source`"); } context = ob.context; source = ob.source; val = ob.val; tablePosition = ob.tablePosition; direction = ob.direction; trackingCell = ob.trackingCell; cells = new List <ICellRenderer> (); foreach (var c in ob.cells) { var copy = (ICellRenderer)Activator.CreateInstance(c.GetType()); copy.CopyFrom(c); AddCell(copy); } if (tablePosition != null) { Fill(); } }
void SetupTableViewColumns() { var titlesColumn = ProcessesTableView.FindTableColumn(new NSString("ParameterDependencyTitlesColumn")); titlesColumn.Width = (nfloat)C.DefaultParameterTextFieldWidth; for (int i = 0; i < ViewModel._ParameterDependencies.Value[0].Values.Length; i++) { var title = $"t{i + 1}"; var header = new NSCell { Title = title, Bordered = true, Highlighted = false, Selectable = false, Editable = false, Alignment = NSTextAlignment.Center, State = NSCellStateValue.On }; ProcessesTableView.AddColumn(new NSTableColumn { Title = title, Width = (nfloat)C.DefaultColumnWidth, HeaderCell = header }); } }
public override void SetBackgroundColor(NSCell cell, Color color) { var c = cell as EtoCell; c.BackgroundColor = color.ToNS(); c.DrawsBackground = color != Colors.Transparent; }
public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell) { var font = cell.Font ?? NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize); var str = new NSString(Convert.ToString(value)); var attrs = NSDictionary.FromObjectAndKey(font, NSStringAttributeKey.Font); return((float)str.StringSize(attrs).Width + 8); // for border }
public override bool ShouldTrackCell(NSTableView tableView, NSCell cell, NSTableColumn tableColumn, int row) { if (ShouldTrackCellFunc != null) { return(ShouldTrackCellFunc(tableView, cell, tableColumn, row)); } return(default(bool)); }
public nfloat GetPreferredSize(object value, CGSize cellSize, int row, object dataItem) { if (copy == null) { copy = Control.Copy() as NSCell; } ColumnHandler.DataViewHandler.OnCellFormatting(ColumnHandler.Widget, dataItem, row, copy); return(GetPreferredSize(value, cellSize, copy)); }
public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell) { var img = value as Image; if (img != null) { return((float)(cellSize.Height / (float)img.Size.Height * (float)img.Size.Width)); } return(16); }
public CGRect GetCellRect(CGRect cellFrame, NSCell cell) { foreach (var c in GetCells(cellFrame)) { if (c.Cell == cell) { return(c.Frame); } } return(CGRect.Empty); }
public override nfloat GetRowHeight(NSTableView tableView, nint row) { var cell = new NSCell(source.entries[(int)row].details) { Wraps = true }; var width = tableView.FindTableColumn((NSString)"Details").Width; var bounds = new CGRect(0, 0, width, nfloat.MaxValue); return(cell.CellSizeForBounds(bounds).Height); }
public override void StopTracking(PointF lastPoint, PointF stopPoint, NSView inView, bool mouseIsUp) { if (trackingCell != null) { try { trackingCell.StopTracking(lastPoint, stopPoint, inView, mouseIsUp); } finally { trackingCell = null; } } }
public override bool StartTracking(PointF startPoint, NSView inView) { foreach (NSCell c in cells) { if (c.StartTracking(startPoint, inView)) { trackingCell = c; return(true); } } return(false); }
public RectangleF GetCellRect(RectangleF cellFrame, NSCell cell) { if (tablePosition is TableRow) { foreach (var c in GetCells(cellFrame)) { if (c.Cell == cell) { return(c.Frame); } } } return(RectangleF.Empty); }
private NSString GetToolTip(NSCell cell, CGRect rect, NSTableColumn tableColumn, nint row, CGPoint mouse) { var programDescription = Programs.ArrangedObjects()[row] as ProgramDescriptionViewModel; var toolTip = string.Empty; if (cell is NSImageCell) { if (tableColumn.Identifier == "icon") { toolTip = programDescription.RomFileStatus; } else if (tableColumn.Identifier == "features") { var space = INTV.Shared.Converter.ProgramFeaturesToImageTransformer.Padding; var offsetIntoImage = mouse.X - rect.X; nfloat leftEdgeOfImage = 0; for (int i = 0; string.IsNullOrEmpty(toolTip) && (i < programDescription.Features.Count); ++i) { var feature = programDescription.Features[i]; var rightEdgeOfImage = leftEdgeOfImage + feature.Image.Size.Width + (space / 2); if ((leftEdgeOfImage <= offsetIntoImage) && (offsetIntoImage <= rightEdgeOfImage)) { toolTip = feature.ToolTip; } else { leftEdgeOfImage += feature.Image.Size.Width + space; } } } } #if false // By leaving the string as empty, we get default behavior for tool tip, which is preferred. // It will display the full text only when it's too long to show in the cell. else if (tableColumn.Identifier == "name") { toolTip = programDescription.Name; } else if (tableColumn.Identifier == "vendor") { toolTip = programDescription.Vendor; } #endif // false else if (tableColumn.Identifier == "romFile") { toolTip = programDescription.RomFile; } return(new NSString(toolTip.SafeString())); }
public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell) { var val = value as MacImageData; if (val == null) { return(0); } var font = cell.Font ?? NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize); var str = val.Text; var attrs = NSDictionary.FromObjectAndKey(font, NSAttributedString.FontAttributeName); var size = str.StringSize(attrs).Width + 4 + 16 + MacImageListItemCell.ImagePadding * 2; // for border + image return((float)size); }
/// <inheritdoc /> public override string ToolTipForCell(NSOutlineView outlineView, NSCell cell, ref CGRect rect, NSTableColumn tableColumn, NSObject item, CGPoint mouseLocation) { var toolTip = string.Empty; var treeNode = item as NSTreeNode; var mouseOverObject = treeNode.RepresentedObject as FileNodeViewModel; var whichColumn = outlineView.TableColumns().ToList().IndexOf(tableColumn); switch (whichColumn) { case 0: if ((mouseOverObject != null) && !string.IsNullOrEmpty(mouseOverObject.IconTipStrip)) { toolTip = mouseOverObject.IconTipStrip; } break; } return(toolTip); }
public void TableWillDisplayCellForTableColumn(NSTableView tableView, NSCell cell, NSTableColumn tableColumn, nint rowIndex) { // check if anything is null first if (ControlView == null || ControlView.Window == null || ControlView.Window.Screen == null || tableView.Window == null) { return; } // hack (using public api's) to set size of popup to at least show this item's entire text. var size = cell.CellSizeForBounds(ControlView.Window.Screen.VisibleFrame); var window = tableView.Window; var frame = window.Frame; size.Width += frame.Width - tableView.Frame.Width; if (frame.Width < size.Width) { frame.Width = size.Width; window.SetFrame(frame, true); } }
void ICopiableObject.CopyFrom(object other) { var ob = (CompositeCell)other; source = ob.source; val = ob.val; tablePosition = ob.tablePosition; direction = ob.direction; trackingCell = ob.trackingCell; cells = new List <ICellRenderer> (); foreach (var c in ob.cells) { var copy = (ICellRenderer)Activator.CreateInstance(c.GetType()); copy.CopyFrom(c); AddCell(copy); } if (tablePosition != null) { Fill(); } }
public static int DetermineFitWidth(this NSCell cell, NSObject objectValueAtCell, int minWidth = 10) { int width; if (cell is NSTextFieldCell) { var font = cell.Font ?? NSFont.ControlContentFontOfSize(-1); var attrs = NSDictionary.FromObjectAndKey(font, NSAttributedString.FontAttributeName); // Determine the text on the cell NSString cellText; if (objectValueAtCell is NSString) { cellText = (NSString)objectValueAtCell; } else if (cell.Formatter != null) { cellText = cell.Formatter.StringFor(objectValueAtCell).ToNSString(); } else { cellText = objectValueAtCell.Description.ToNSString(); } width = (int)cellText.StringSize(attrs).Width + minWidth; } else if (cell.Image != null) { // if cell has an image, use that images width width = (int)Math.Max(minWidth, (int)cell.Image.Size.Width); } else { // cell is something else, just use its width width = (int)Math.Max(minWidth, (int)cell.CellSize.Width); } return(width); }
public void TableViewWillDisplayCell(NSTableView aView, NSCell aCell, NSTableColumn aTableColumn, int aRow) { NSString identifier = aTableColumn.Identifier.CastTo <NSString>(); if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame) { NSImageCell cell = aCell.CastTo <NSImageCell>(); if (aRow == SelectedIndex) { cell.Image = Properties.Resources.IconTick; cell.IsEnabled = true; } else { cell.Image = null; cell.IsEnabled = false; } } else { aCell.RepresentedObject = iSources.ObjectAtIndex((uint)aRow); } }
public override Color GetForegroundColor(NSCell cell) { return(Colors.Transparent); }
public override void SetForegroundColor(NSCell cell, Color color) { }
public override Color GetBackgroundColor(NSCell cell) { var c = (EtoCell)cell; return(c.BackgroundColor.ToEto()); }
public override void SetBackgroundColor(NSCell cell, Color color) { var c = (EtoCell)cell; c.BackgroundColor = color.ToNSUI(); }
public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell) { return(25); }
public override Color GetForegroundColor(NSCell cell) { return(((EtoCell)cell).ForegroundColor); }
public override void SetForegroundColor(NSCell cell, Color color) { ((EtoCell)cell).ForegroundColor = color; }
public override Color GetBackgroundColor(NSCell cell) { return(((EtoCell)cell).BackgroundColor); }
public override Color GetForegroundColor(NSCell cell) { var c = cell as EtoCell; return(c.TextColor.ToEto()); }