/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(CellMouseEventArgs e) { base.OnMouseDown(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { if (!(e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is DropDownCellEditor)) { throw new InvalidOperationException("Cannot edit Cell as DropDownCellRenderer requires a DropDownColumn that uses a DropDownCellEditor"); } rendererData.ButtonState = ComboBoxStates.Pressed; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Gets the DropDownRendererData specific data used by the Renderer from /// the specified Cell /// </summary> /// <param name="cell">The Cell to get the DropDownRendererData data for</param> /// <returns>The DropDownRendererData data for the specified Cell</returns> protected DropDownRendererData GetDropDownRendererData(Cell cell) { object rendererData = this.GetRendererData(cell); if (rendererData == null || !(rendererData is DropDownRendererData)) { rendererData = new DropDownRendererData(); this.SetRendererData(cell, rendererData); } return((DropDownRendererData)rendererData); }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseDown(CellMouseEventArgs e) { base.OnMouseDown(e); if (!this.ShowDropDownButton && (!e.Table.IsEditing || e.CellPos != e.Table.EditingCell)) { return; } if (!e.Table.IsCellEditable(e.CellPos)) { return; } // get the button renderer data DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (!this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { return; } var isDropDownCellEditor = e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is DropDownCellEditor; if (!isDropDownCellEditor) { // var msg = "Cannot edit Cell as DropDownCellRenderer requires a DropDownColumn " + // "that uses a DropDownCellEditor"; // throw new InvalidOperationException(msg); return; } rendererData.ButtonState = ComboBoxState.Pressed; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } //netus - fix from John Boyce on 2006-02-08 if (e.Table.IsEditing) { ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } }
/// <summary> /// Raises the MouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseUp(CellMouseEventArgs e) { base.OnMouseUp(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { rendererData.ButtonState = ComboBoxState.Hot; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseLeave event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseLeave(CellMouseEventArgs e) { base.OnMouseLeave(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (rendererData.ButtonState != ComboBoxState.Normal) { rendererData.ButtonState = ComboBoxState.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseMove event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseMove(XPTable.Events.CellMouseEventArgs e) { base.OnMouseMove(e); if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell); if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y)) { if (rendererData.ButtonState == ComboBoxState.Normal) { if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column) { rendererData.ButtonState = ComboBoxState.Pressed; } else { rendererData.ButtonState = ComboBoxState.Hot; } e.Table.Invalidate(e.CellRect); } } else { if (rendererData.ButtonState != ComboBoxState.Normal) { rendererData.ButtonState = ComboBoxState.Normal; e.Table.Invalidate(e.CellRect); } } } } }
/// <summary> /// Gets the DropDownRendererData specific data used by the Renderer from /// the specified Cell /// </summary> /// <param name="cell">The Cell to get the DropDownRendererData data for</param> /// <returns>The DropDownRendererData data for the specified Cell</returns> protected DropDownRendererData GetDropDownRendererData(Cell cell) { object rendererData = this.GetRendererData(cell); if (rendererData == null || !(rendererData is DropDownRendererData)) { rendererData = new DropDownRendererData(); this.SetRendererData(cell, rendererData); } return (DropDownRendererData)rendererData; }