예제 #1
0
        public override void SetBackgroundColor(NSCell cell, Color color)
        {
            var c = cell as EtoCell;

            c.BackgroundColor = Generator.ConvertNS(color);
            c.DrawsBackground = color != Colors.Transparent;
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
                });
            }
        }
예제 #5
0
        public override void SetBackgroundColor(NSCell cell, Color color)
        {
            var c = cell as EtoCell;

            c.BackgroundColor = color.ToNS();
            c.DrawsBackground = color != Colors.Transparent;
        }
예제 #6
0
        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
        }
예제 #7
0
 public override bool ShouldTrackCell(NSTableView tableView, NSCell cell, NSTableColumn tableColumn, int row)
 {
     if (ShouldTrackCellFunc != null)
     {
         return(ShouldTrackCellFunc(tableView, cell, tableColumn, row));
     }
     return(default(bool));
 }
예제 #8
0
 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));
 }
예제 #9
0
        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);
        }
예제 #10
0
 public CGRect GetCellRect(CGRect cellFrame, NSCell cell)
 {
     foreach (var c in GetCells(cellFrame))
     {
         if (c.Cell == cell)
         {
             return(c.Frame);
         }
     }
     return(CGRect.Empty);
 }
예제 #11
0
        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);
        }
예제 #12
0
 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;
         }
     }
 }
예제 #13
0
 public override bool StartTracking(PointF startPoint, NSView inView)
 {
     foreach (NSCell c in cells)
     {
         if (c.StartTracking(startPoint, inView))
         {
             trackingCell = c;
             return(true);
         }
     }
     return(false);
 }
예제 #14
0
 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);
 }
예제 #15
0
            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()));
            }
예제 #16
0
        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);
        }
예제 #17
0
            /// <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);
            }
예제 #18
0
            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);
                }
            }
예제 #19
0
        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();
            }
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
 public override Color GetForegroundColor(NSCell cell)
 {
     return(Colors.Transparent);
 }
예제 #23
0
 public override void SetForegroundColor(NSCell cell, Color color)
 {
 }
예제 #24
0
        public override Color GetBackgroundColor(NSCell cell)
        {
            var c = (EtoCell)cell;

            return(c.BackgroundColor.ToEto());
        }
예제 #25
0
        public override void SetBackgroundColor(NSCell cell, Color color)
        {
            var c = (EtoCell)cell;

            c.BackgroundColor = color.ToNSUI();
        }
예제 #26
0
 public override nfloat GetPreferredSize(object value, CGSize cellSize, NSCell cell)
 {
     return(25);
 }
예제 #27
0
 public override Color GetForegroundColor(NSCell cell)
 {
     return(((EtoCell)cell).ForegroundColor);
 }
예제 #28
0
 public override void SetForegroundColor(NSCell cell, Color color)
 {
     ((EtoCell)cell).ForegroundColor = color;
 }
예제 #29
0
 public override Color GetBackgroundColor(NSCell cell)
 {
     return(((EtoCell)cell).BackgroundColor);
 }
예제 #30
0
        public override Color GetForegroundColor(NSCell cell)
        {
            var c = cell as EtoCell;

            return(c.TextColor.ToEto());
        }