Exemplo n.º 1
0
        /// <summary>
        /// Sets the location and size of the CellEditor
        /// </summary>
        /// <param name="cellRect">A Rectangle that represents the size and location
        /// of the Cell being edited</param>
        protected override void SetEditLocation(Rectangle cellRect)
        {
            // calc the size of the textbox
            ICellRenderer renderer    = this.EditingTable.ColumnModel.GetCellRenderer(this.EditingCellPos.Column);
            int           buttonWidth = ((ComboBoxCellRenderer)renderer).ButtonWidth;

            this.TextBox.Size     = new Size(cellRect.Width - 1 - buttonWidth, cellRect.Height - 1);
            this.TextBox.Location = cellRect.Location;

            this.cellWidth = cellRect.Width;
        }
Exemplo n.º 2
0
 public static bool HandleKeyUp(this ICellRenderer cell, NSEvent theEvent)
 {
     if (cell.Backend.GetIsEventEnabled(WidgetEvent.KeyReleased))
     {
         cell.Backend.Load(cell);
         cell.CellContainer.SetCurrentEventRow();
         var keyArgs = theEvent.ToXwtKeyEventArgs();
         cell.Backend.Context.InvokeUserCode(() => cell.Backend.EventSink.OnKeyReleased(keyArgs));
         return(keyArgs.Handled);
     }
     return(false);
 }
Exemplo n.º 3
0
        static NSView CreateCellView(NSTableView table, CellView cell, int column)
        {
            ICellRenderer cr = null;

            if (cell is ITextCellViewFrontend)
            {
                cr = new TextTableCell();
            }
            else if (cell is IImageCellViewFrontend)
            {
                cr = new ImageTableCell();
            }
            else if (cell is ICanvasCellViewFrontend)
            {
                cr = new CanvasTableCell();
            }
            else if (cell is ICheckBoxCellViewFrontend)
            {
                cr = new CheckBoxTableCell();
            }
            else if (cell is IRadioButtonCellViewFrontend)
            {
                cr = new RadioButtonTableCell();
            }
            else
            {
                throw new NotImplementedException();
            }
            ICellViewFrontend fr      = cell;
            CellViewBackend   backend = null;

            try {
                //FIXME: although the cell views are based on XwtComponent, they don't implement
                //       the dynamic registration based backend creation and there is no way to
                //       identify whether the frontend has already a valid backend.
                backend = cell.GetBackend() as CellViewBackend;
            } catch (InvalidOperationException) { }

            if (backend == null)
            {
                cr.Backend = new CellViewBackend(table, column);
                fr.AttachBackend(null, cr.Backend);
            }
            else
            {
                cr.Backend = backend;
            }
            return((NSView)cr);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Associates the specified ICellRenderer with the specified name
        /// </summary>
        /// <param name="name">The name to be associated with the specified ICellRenderer</param>
        /// <param name="renderer">The ICellRenderer to be added to the ColumnModel</param>
        public void SetCellRenderer(string name, ICellRenderer renderer)
        {
            if (name == null || renderer == null)
            {
                return;
            }

            name = name.ToUpper();

            if (this.cellRenderers.ContainsKey(name))
            {
                this.cellRenderers.Remove(name);
            }

            this.cellRenderers.Add(name, renderer);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Displays the drop down portion to the user
        /// </summary>
        protected virtual void ShowDropDown()
        {
            Point p = this.EditingTable.PointToScreen(this.TextBox.Location);

            p.Y += this.TextBox.Height + 1;

            Rectangle screenBounds = Screen.GetBounds(p);

            if (p.Y + this.dropDownContainer.Height > screenBounds.Bottom)
            {
                p.Y -= this.TextBox.Height + this.dropDownContainer.Height + 1;
            }

            if (p.X + this.dropDownContainer.Width > screenBounds.Right)
            {
                ICellRenderer renderer    = this.EditingTable.ColumnModel.GetCellRenderer(this.EditingCellPos.Column);
                int           buttonWidth = ((DropDownCellRenderer)renderer).ButtonWidth;

                p.X = p.X + this.TextBox.Width + buttonWidth - this.dropDownContainer.Width;
            }

            this.dropDownContainer.Location = p;

            this.parentForm.AddOwnedForm(this.dropDownContainer);
            this.activationListener.AssignHandle(this.parentForm.Handle);

            this.dropDownContainer.ShowDropDown();
            this.dropDownContainer.Activate();

            // A little bit of fun.  We've shown the popup,
            // but because we've kept the main window's
            // title bar in focus the tab sequence isn't quite
            // right.  This can be fixed by sending a tab,
            // but that on its own would shift focus to the
            // second control in the form.  So send a tab,
            // followed by a reverse-tab.

            // Send a Tab command:
            NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, KeyEventFFlags.KEYEVENTF_KEYUP, 0);

            // Send a reverse Tab command:
            NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, KeyEventFFlags.KEYEVENTF_KEYUP, 0);
            NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, KeyEventFFlags.KEYEVENTF_KEYUP, 0);
        }
Exemplo n.º 6
0
 public static bool HandleMouseMoved(this ICellRenderer cell, NSEvent theEvent)
 {
     if (cell.Backend.GetIsEventEnabled(WidgetEvent.MouseMoved))
     {
         CGPoint p = cell.CellView.ConvertPointFromEvent(theEvent);
         if (cell.CellView.Bounds.Contains(p))
         {
             cell.Backend.Load(cell);
             cell.CellContainer.SetCurrentEventRow();
             var offset = cell.Backend.CellBounds.Location;
             MouseMovedEventArgs args = new MouseMovedEventArgs((long)TimeSpan.FromSeconds(theEvent.Timestamp).TotalMilliseconds, p.X + offset.X, p.Y + offset.Y);
             cell.Backend.Context.InvokeUserCode(() => cell.Backend.EventSink.OnMouseMoved(args));
             return(args.Handled);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Sets the location and size of the CellEditor
        /// </summary>
        /// <param name="cellRect">A Rectangle that represents the size and location
        /// of the Cell being edited</param>
        protected override void SetEditLocation(Rectangle cellRect)
        {
            // calc the size of the textbox
            ICellRenderer renderer    = this.EditingTable.ColumnModel.GetCellRenderer(this.EditingCellPos.Column);
            int           buttonWidth = ((NumberCellRenderer)renderer).ButtonWidth;

            this.TextBox.Size = new Size(cellRect.Width - 1 - buttonWidth, cellRect.Height - 1);

            // calc the location of the textbox
            this.TextBox.Location = cellRect.Location;
            this.buttonBounds     = new Rectangle(this.TextBox.Left + 1, this.TextBox.Top, buttonWidth, this.TextBox.Height);

            if (((NumberColumn)this.EditingTable.ColumnModel.Columns[this.EditingCellPos.Column]).UpDownAlign == LeftRightAlignment.Left)
            {
                this.TextBox.Location      = new Point(cellRect.Left + buttonWidth, cellRect.Top);
                this.buttonBounds.Location = new Point(cellRect.Left, cellRect.Top);
            }
        }
Exemplo n.º 8
0
 public GridColumn(
     string name,
     string label,
     int order,
     ICellRenderer <T> cellRenderer,
     CellAlignment cellAlignment = CellAlignment.Left,
     FieldInfo fieldInfo         = null,
     PropertyInfo propertyInfo   = null,
     bool removed = false)
 {
     Name          = name;
     Label         = Utils.SplitCamelCase(name);
     Order         = order;
     CellRenderer  = cellRenderer;
     CellAlignment = cellAlignment;
     FieldInfo     = fieldInfo;
     PropertyInfo  = propertyInfo;
     Removed       = removed;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initialise default values
        /// </summary>
        private void Init()
        {
            this.text         = null;
            this.width        = Column.DefaultWidth;
            this.columnState  = ColumnState.Normal;
            this.alignment    = ColumnAlignment.Left;
            this.image        = null;
            this.imageOnRight = false;
            this.columnModel  = null;
            this.x            = 0;
            this.tooltipText  = null;
            this.format       = "";
            this.sortOrder    = SortOrder.None;
            this.renderer     = null;
            this.editor       = null;
            this.comparer     = null;

            this.state = (byte)(STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialise default values
        /// </summary>
        private void Init()
        {
            this.text         = null;
            this.width        = Column.DefaultWidth;
            this.columnState  = ColumnState.Normal;
            this.alignment    = ColumnAlignment.Left;
            this.image        = null;
            this.imageOnRight = false;
            this.columnModel  = null;
            this.x            = 0;
            this.tooltipText  = null;
            this.format       = "";
            this.sortOrder    = SortOrder.None;
            this.renderer     = null;
            this.editor       = null;
            this.comparer     = null;

            // Mateusz [PEYN] Adamus ([email protected])
            // Added STATE_RESIZABLE to column's initialization
            this.state = (byte)(STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE | STATE_RESIZABLE);
        }
Exemplo n.º 11
0
 public static bool HandleMouseUp(this ICellRenderer cell, NSEvent theEvent)
 {
     if (cell.Backend.GetIsEventEnabled(WidgetEvent.ButtonReleased))
     {
         CGPoint p = cell.CellView.ConvertPointFromEvent(theEvent);
         if (cell.CellView.Bounds.Contains(p))
         {
             cell.Backend.Load(cell);
             cell.CellContainer.SetCurrentEventRow();
             ButtonEventArgs args = new ButtonEventArgs {
                 X             = p.X,
                 Y             = p.Y,
                 Button        = theEvent.GetPointerButton(),
                 MultiplePress = (int)theEvent.ClickCount
             };
             cell.Backend.Context.InvokeUserCode(() => cell.Backend.EventSink.OnButtonReleased(args));
             return(args.Handled);
         }
     }
     return(false);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Initialise default values
        /// </summary>
        private void Init()
        {
            this.text = null;
            this.width = Column.DefaultWidth;
            this.columnState = ColumnState.Normal;
            this.alignment = ColumnAlignment.Left;
            this.image = null;
            this.imageOnRight = false;
            this.columnModel = null;
            this.x = 0;
            this.tooltipText = null;
            this.format = "";
            this.sortOrder = SortOrder.None;
            this.renderer = null;
            this.editor = null;
            this.comparer = null;

            this.state = (byte) (STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE);
        }
Exemplo n.º 13
0
        public static void ApplyAcessibilityProperties(this ICellRenderer cell)
        {
            var frontend = cell.Backend.Frontend;

            if (frontend.AccessibleFields == null)
            {
                return;
            }

            ICellDataSource source = cell.CellContainer;
            var             label  = GetValue(source, frontend.AccessibleFields.Label);

            if (label != null)
            {
                cell.AccessibilityLabel = (string)label;
            }
            var identifier = GetValue(source, frontend.AccessibleFields.Identifier);

            if (identifier != null)
            {
                cell.AccessibilityIdentifier = (string)identifier;
            }
            var description = GetValue(source, frontend.AccessibleFields.Description);

            if (description != null)
            {
                cell.AccessibilityHelp = (string)description;
            }
            var title = GetValue(source, frontend.AccessibleFields.Title);

            if (title != null)
            {
                cell.AccessibilityTitle = (string)title;
            }
            var isAccessible = GetValue(source, frontend.AccessibleFields.IsAccessible);

            if (isAccessible != null)
            {
                cell.AccessibilityElement = (bool)isAccessible;
            }
            var value = GetValue(source, frontend.AccessibleFields.Value);

            if (value != null)
            {
                cell.AccessibilityValue = new NSString((string)value);
            }
            var uri = GetValue(source, frontend.AccessibleFields.Uri);

            if (uri != null)
            {
                cell.AccessibilityUrl = new NSUrl(((Uri)uri).AbsoluteUri);
            }
            var bounds = GetValue(source, frontend.AccessibleFields.Bounds);

            if (bounds != null)
            {
                cell.AccessibilityFrame = ((Rectangle)bounds).ToCGRect();
            }

            var role = GetValue(source, frontend.AccessibleFields.Role);

            if (role != null)
            {
                if ((Role)role == Role.Filler)
                {
                    cell.AccessibilityElement = false;
                }
                else
                {
                    cell.AccessibilityElement = true;
                    cell.AccessibilityRole    = ((Role)role).GetMacRole();
                    cell.AccessibilitySubrole = ((Role)role).GetMacSubrole();
                }
            }
            var roleDescription = GetValue(source, frontend.AccessibleFields.RoleDescription);

            if (roleDescription != null)
            {
                cell.AccessibilityRoleDescription = (string)roleDescription;
            }
        }
Exemplo n.º 14
0
 public void AddCell(ICellRenderer cell)
 {
     cell.CellContainer = this;
     cells.Add(cell);
     AddSubview((NSView)cell);
 }
Exemplo n.º 15
0
 public void AddCell(ICellRenderer cell)
 {
     cells.Add(cell);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Associates the specified ICellRenderer with the specified name
        /// </summary>
        /// <param name="name">The name to be associated with the specified ICellRenderer</param>
        /// <param name="renderer">The ICellRenderer to be added to the ColumnModel</param>
        public void SetCellRenderer(string name, ICellRenderer renderer)
        {
            if (name == null || renderer == null)
            {
                return;
            }

            name = name.ToUpper();

            if (this.cellRenderers.ContainsKey(name))
            {
                this.cellRenderers.Remove(name);

                this.cellRenderers[name] = renderer;
            }
            else
            {
                this.cellRenderers.Add(name, renderer);
            }
        }
Exemplo n.º 17
0
 public void AddCell(ICellRenderer cell)
 {
     cells.Add (cell);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Initialise default values
        /// </summary>
        private void Init()
        {
            this.text = null;
            this.width = Column.DefaultWidth;
            this.columnState = ColumnState.Normal;
            this.alignment = ColumnAlignment.Left;
            this.image = null;
            this.imageOnRight = false;
            this.columnModel = null;
            this.x = 0;
            this.tooltipText = null;
            this.format = "";
            this.sortOrder = SortOrder.None;
            this.renderer = null;
            this.editor = null;
            this.comparer = null;

            // Mateusz [PEYN] Adamus ([email protected])
            // Added STATE_RESIZABLE to column's initialization
            this.state = (byte) (STATE_ENABLED | STATE_EDITABLE | STATE_VISIBLE | STATE_SELECTABLE | STATE_SORTABLE | STATE_RESIZABLE );
        }
Exemplo n.º 19
0
 public void AddCell(ICellRenderer cell)
 {
     cell.CellContainer = this;
     cells.Add (cell);
 }
Exemplo n.º 20
0
 public void AddCell(ICellRenderer cell)
 {
     cell.CellContainer = this;
     cells.Add(cell);
 }
Exemplo n.º 21
0
 internal void Load(ICellRenderer cell)
 {
     CurrentCellView = (NSView)cell;
     CurrentPosition = cell.CellContainer.TablePosition;
     EventSink       = Frontend.Load(cell.CellContainer);
 }