public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func <NSObject, int, object> getItem) { var view = tableView.MakeView(tableColumn.Identifier, tableView) as CellView; if (view == null) { view = new CellView { Title = string.Empty }; view.Identifier = tableColumn.Identifier; view.SetButtonType(NSButtonType.Switch); view.Bind("enabled", tableColumn, "editable", null); var col = Array.IndexOf(tableView.TableColumns(), tableColumn); view.Activated += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); var ee = new GridViewCellEventArgs(ColumnHandler.Widget, r, col, item); ColumnHandler.DataViewHandler.Callback.OnCellEditing(ColumnHandler.DataViewHandler.Widget, ee); SetObjectValue(item, control.ObjectValue); control.ObjectValue = GetObjectValue(item); ColumnHandler.DataViewHandler.Callback.OnCellEdited(ColumnHandler.DataViewHandler.Widget, ee); }; } view.Tag = row; view.Item = obj; var args = new MacCellFormatArgs(ColumnHandler.Widget, getItem(obj, row), row, view); ColumnHandler.DataViewHandler.OnCellFormatting(args); return(view); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func <NSObject, int, object> getItem) { var view = tableView.MakeView(tableColumn.Identifier, tableView) as CellView; if (view == null) { view = new CellView(); view.Cell = new EtoLabelFieldCell { VerticalAlignment = VerticalAlignment.Center }; view.Identifier = tableColumn.Identifier; view.Selectable = false; view.DrawsBackground = false; view.Bezeled = false; view.Bordered = false; view.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; view.Cell.Wraps = false; view.Cell.Scrollable = true; view.Cell.UsesSingleLineMode = true; var col = Array.IndexOf(tableView.TableColumns(), tableColumn); view.BecameFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); var ee = new GridViewCellEventArgs(ColumnHandler.Widget, r, (int)col, item); ColumnHandler.DataViewHandler.Callback.OnCellEditing(ColumnHandler.DataViewHandler.Widget, ee); }; view.EditingEnded += (sender, e) => { var notification = (NSNotification)sender; var control = (CellView)notification.Object; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = new GridViewCellEventArgs(ColumnHandler.Widget, r, (int)col, item); ColumnHandler.DataViewHandler.Callback.OnCellEdited(ColumnHandler.DataViewHandler.Widget, ee); control.ObjectValue = GetObjectValue(item); }; view.ResignedFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = new GridViewCellEventArgs(ColumnHandler.Widget, r, (int)col, item); ColumnHandler.DataViewHandler.Callback.OnCellEdited(ColumnHandler.DataViewHandler.Widget, ee); }; view.Bind("editable", tableColumn, "editable", null); } view.Item = obj; view.Tag = row; var args = new MacCellFormatArgs(ColumnHandler.Widget, getItem(obj, row), row, view); ColumnHandler.DataViewHandler.OnCellFormatting(args); return(view); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func <NSObject, int, object> getItem) { var view = tableView.MakeView(tableColumn.Identifier, tableView) as CellView; if (view == null) { view = new CellView { WeakHandler = new WeakReference(this), Identifier = tableColumn.Identifier, }; var col = Array.IndexOf(tableView.TableColumns(), tableColumn); view.BecameFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEditing(ee); }; view.EditingEnded += (sender, e) => { var notification = (NSNotification)sender; var control = (CellView)notification.Object; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEdited(ee); control.ObjectValue = GetObjectValue(item) ?? new NSString(string.Empty); }; view.ResignedFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEdited(ee); }; view.Bind(editableBinding, tableColumn, "editable", null); } var cell = view.Cell; cell.VerticalAlignment = VerticalAlignment; cell.Alignment = TextAlignment.ToNS(); view.Item = obj; view.Tag = row; var args = new MacCellFormatArgs(ColumnHandler.Widget, getItem(obj, row), row, view); ColumnHandler.DataViewHandler.OnCellFormatting(args); return(view); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func <NSObject, int, object> getItem) { var view = tableView.MakeView(tableColumn.Identifier, tableView) as CellView; if (view == null) { var col = Array.IndexOf(tableView.TableColumns(), tableColumn); view = new CellView { Handler = this, Cell = new EtoCell(), Identifier = tableColumn.Identifier, Bordered = false, AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; view.Activated += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); var cellArgs = new GridViewCellEventArgs(ColumnHandler.Widget, r, (int)col, item); ColumnHandler.DataViewHandler.Callback.OnCellEditing(ColumnHandler.DataViewHandler.Widget, cellArgs); SetObjectValue(item, control.ObjectValue); ColumnHandler.DataViewHandler.Callback.OnCellEdited(ColumnHandler.DataViewHandler.Widget, cellArgs); control.ObjectValue = GetObjectValue(item); }; view.Bind("enabled", tableColumn, "editable", null); view.Menu = menu.Copy() as NSMenu; } else if (view.Title != menu.Title) { view.Menu = menu.Copy() as NSMenu; } view.Tag = row; view.Item = obj; var formatArgs = new MacCellFormatArgs(ColumnHandler.Widget, getItem(obj, row), row, view); ColumnHandler.DataViewHandler.OnCellFormatting(formatArgs); return(view); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row, NSObject obj, Func <NSObject, int, object> getItem) { var view = tableView.MakeView(tableColumn.Identifier, tableView) as CellView; if (view == null) { view = new CellView { WeakHandler = new WeakReference(this), Cell = new EtoLabelFieldCell { Wraps = false, Scrollable = true, UsesSingleLineMode = false // true prevents proper vertical alignment }, Identifier = tableColumn.Identifier, Selectable = false, DrawsBackground = false, Bezeled = false, Bordered = false, AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; var col = Array.IndexOf(tableView.TableColumns(), tableColumn); view.BecameFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEditing(ee); }; view.EditingEnded += (sender, e) => { var notification = (NSNotification)sender; var control = (CellView)notification.Object; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEdited(ee); control.ObjectValue = GetObjectValue(item) ?? new NSString(string.Empty); }; view.ResignedFirstResponder += (sender, e) => { var control = (CellView)sender; var r = (int)control.Tag; var item = getItem(control.Item, r); SetObjectValue(item, control.ObjectValue); var ee = MacConversions.CreateCellEventArgs(ColumnHandler.Widget, tableView, r, col, item); ColumnHandler.DataViewHandler.OnCellEdited(ee); }; view.Bind(editableBinding, tableColumn, "editable", null); } var cell = (EtoLabelFieldCell)view.Cell; cell.VerticalAlignment = VerticalAlignment; cell.Alignment = TextAlignment.ToNS(); view.Item = obj; view.Tag = row; var args = new MacCellFormatArgs(ColumnHandler.Widget, getItem(obj, row), row, view); ColumnHandler.DataViewHandler.OnCellFormatting(args); return(view); }