/// <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); // get the button renderer data ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // make sure the button is in its normal state if (rendererData.ButtonState != PushButtonStates.Normal) { rendererData.ButtonState = PushButtonStates.Normal; 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 (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); if (e.Cell.CheckState == CheckState.Checked) { if (rendererData.CheckState != CheckBoxStates.CheckedNormal) { rendererData.CheckState = CheckBoxStates.CheckedNormal; e.Table.Invalidate(e.CellRect); } } else if (e.Cell.CheckState == CheckState.Indeterminate) { if (rendererData.CheckState != CheckBoxStates.MixedNormal) { rendererData.CheckState = CheckBoxStates.MixedNormal; e.Table.Invalidate(e.CellRect); } } else //if (e.Cell.CheckState == CheckState.Unchecked) { if (rendererData.CheckState != CheckBoxStates.UncheckedNormal) { rendererData.CheckState = CheckBoxStates.UncheckedNormal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the MouseDown event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnMouseDown(CellMouseEventArgs e) { if (!e.Table.Focused) { if (!(e.Table.IsEditing && e.Table.EditingCell == e.CellPos && e.Table.EditingCellEditor is IEditorUsesRendererButtons)) { e.Table.Focus(); } } this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } }
private void ToggleState(CellMouseEventArgs e) { GroupRendererData data = this.GetGroupRendererData(e.Cell); // Toggle the group state data.Grouped = !data.Grouped; Row r = e.Table.TableModel.Rows[e.Row]; r.ExpandSubRows = !r.ExpandSubRows; e.Table.Invalidate(); }
/// <summary> /// Handler for the editors buttons MouseUp event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public void OnEditorButtonMouseUp(object sender, CellMouseEventArgs e) { this.StopTimer(); this.buttonID = 0; }
/// <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); } //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 = ComboBoxStates.Hot; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Handler for the editors drop down button MouseDown event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnEditorButtonMouseDown(object sender, CellMouseEventArgs e) { this.DroppedDown = !this.DroppedDown; }
/// <summary> /// Handler for the editors drop down button MouseUp event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnEditorButtonMouseUp(object sender, CellMouseEventArgs e) { }
/// <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.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); if (rendererData.UpButtonState != UpDownStates.Normal) { rendererData.UpButtonState = UpDownStates.Normal; e.Table.Invalidate(e.CellRect); } else if (rendererData.DownButtonState != UpDownStates.Normal) { rendererData.DownButtonState = UpDownStates.Normal; 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.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); rendererData.ClickPoint = new Point(-1, -1); if (this.GetUpButtonBounds().Contains(e.X, e.Y)) { rendererData.UpButtonState = UpDownStates.Hot; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } ((IEditorUsesRendererButtons) e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e); e.Table.Invalidate(e.CellRect); } else if (this.GetDownButtonBounds().Contains(e.X, e.Y)) { rendererData.DownButtonState = UpDownStates.Hot; if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } ((IEditorUsesRendererButtons) e.Table.EditingCellEditor).OnEditorButtonMouseUp(this, e); e.Table.Invalidate(e.CellRect); } } } }
/// <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.ShowUpDownButtons || this.TableUsingNumericCellEditor(e.Table, e.CellPos)) { if (e.Table.IsCellEditable(e.CellPos)) { // get the button renderer data NumberRendererData rendererData = this.GetNumberRendererData(e.Cell); rendererData.ClickPoint = new Point(e.X, e.Y); if (this.CalcButtonBounds().Contains(e.X, e.Y)) { if (!(e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is NumberCellEditor)) { throw new InvalidOperationException("Cannot edit Cell as NumberCellRenderer requires a NumberColumn that uses a NumberCellEditor"); } if (!e.Table.IsEditing) { e.Table.EditCell(e.CellPos); } if (this.GetUpButtonBounds().Contains(e.X, e.Y)) { rendererData.UpButtonState = UpDownStates.Pressed; ((IEditorUsesRendererButtons) e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e); e.Table.Invalidate(e.CellRect); } else if (this.GetDownButtonBounds().Contains(e.X, e.Y)) { rendererData.DownButtonState = UpDownStates.Pressed; ((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 virtual void OnMouseUp(CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } }
/// <summary> /// Raises the MouseEnter event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnMouseEnter(CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } bool tooltipActive = e.Table.ToolTip.Active; if (tooltipActive) { e.Table.ToolTip.Active = false; } e.Table.ResetMouseEventArgs(); e.Table.ToolTip.SetToolTip(e.Table, e.Cell.ToolTipText); if (tooltipActive) { e.Table.ToolTip.Active = true; } }
/// <summary> /// Raises the MouseMove event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseMove(CellMouseEventArgs e) { base.OnMouseMove(e); // get the button renderer data ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); Rectangle buttonRect = this.CalcButtonBounds(); // check if the left mouse button is pressed if (e.Button == MouseButtons.Left) { // check if the mouse press originated in the button area if (buttonRect.Contains(rendererData.ClickPoint)) { // check if the mouse is currently in the button if (buttonRect.Contains(e.X, e.Y)) { // make sure the button is pressed if (rendererData.ButtonState != PushButtonStates.Pressed) { rendererData.ButtonState = PushButtonStates.Pressed; e.Table.Invalidate(e.CellRect); } } else { // the mouse isn't inside the button so make sure it is "hot" if (rendererData.ButtonState != PushButtonStates.Hot) { rendererData.ButtonState = PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } } } else { // check if the mouse is currently in the button if (buttonRect.Contains(e.X, e.Y)) { // the mouse is inside the button so make sure it is "hot" if (rendererData.ButtonState != PushButtonStates.Hot) { rendererData.ButtonState = PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } else { // not inside the button so make sure it is in its normal state if (rendererData.ButtonState != PushButtonStates.Normal) { rendererData.ButtonState = PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the CellDoubleClick event /// </summary> /// <param name="e">A CellEventArgs that contains the event data</param> protected virtual void OnCellDoubleClick(CellMouseEventArgs e) { if (!this.IsCellEnabled(e.CellPos)) { return; } if (this.CanRaiseEvents) { ICellRenderer renderer = this.ColumnModel.GetCellRenderer(this.LastMouseCell.Column); if (renderer != null) { renderer.OnDoubleClick(e); } if (CellDoubleClick != null) { CellDoubleClick(e.Cell, e); } } }
/// <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); // get the button renderer data ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // check for the left mouse button if (e.Button == MouseButtons.Left) { Rectangle buttonRect = this.CalcButtonBounds(); // if the mouse pointer is over the button, make sure // the button is "hot" if (buttonRect.Contains(e.X, e.Y)) { rendererData.ButtonState = PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); // check if the click started inside the button. if // it did, Raise the tables CellButtonClicked event if (buttonRect.Contains(rendererData.ClickPoint)) { e.Table.OnCellButtonClicked(new CellButtonEventArgs(e.Cell, e.Column, e.Row)); } } else { // the mouse was released somewhere outside of the button, // so make set the button back to its normal state if (rendererData.ButtonState != PushButtonStates.Normal) { rendererData.ButtonState = PushButtonStates.Normal; e.Table.Invalidate(e.CellRect); } } } // reset the click point rendererData.ClickPoint = Point.Empty; }
/// <summary> /// Raises the CellHover event /// </summary> /// <param name="e">A CellEventArgs that contains the event data</param> protected virtual void OnCellMouseHover(CellMouseEventArgs e) { if (this.CanRaiseEvents) { if (CellMouseHover != null) { CellMouseHover(e.Cell, e); } } }
/// <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 != ComboBoxStates.Normal) { rendererData.ButtonState = ComboBoxStates.Normal; e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the CellMouseUp event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> protected virtual void OnCellMouseUp(CellMouseEventArgs e) { if (this.CanRaiseEvents) { ICellRenderer renderer = this.ColumnModel.GetCellRenderer(e.Column); if (renderer != null) { renderer.OnMouseUp(e); } if (CellMouseUp != null) { CellMouseUp(e.Cell, e); } } }
/// <summary> /// Fires the DoubleClick event. /// </summary> /// <param name="e"></param> public override void OnDoubleClick(CellMouseEventArgs e) { base.OnDoubleClick (e); if (!this.toggleOnSingleClick) ToggleState(e); }
/// <summary> /// Raises a MouseUp event for the Cell at the specified cell position /// </summary> /// <param name="cellPos">The position of the Cell</param> /// <param name="e">A MouseEventArgs that contains the event data</param> protected void RaiseCellMouseUp(CellPos cellPos, MouseEventArgs e) { if (!this.IsValidCell(cellPos)) { return; } if (!this.TableModel[cellPos].Enabled) { return; } if (this.ColumnModel.GetCellRenderer(cellPos.Column) != null) { Cell cell = null; if (cellPos.Column < this.TableModel.Rows[cellPos.Row].Cells.Count) { cell = this.TableModel.Rows[cellPos.Row].Cells[cellPos.Column]; } CellMouseEventArgs mcea = new CellMouseEventArgs(cell, this, cellPos.Row, cellPos.Column, this.CellRect(cellPos.Row, cellPos.Column), e); this.OnCellMouseUp(mcea); } }
/// <summary> /// Handler for the editors buttons MouseDown event /// </summary> /// <param name="sender">The object that raised the event</param> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public void OnEditorButtonMouseDown(object sender, CellMouseEventArgs e) { this.ParseEditText(); if (e.Y < this.buttonBounds.Top + (this.buttonBounds.Height / 2)) { this.buttonID = UpButtonID; this.UpButton(); } else { this.buttonID = DownButtonID; this.DownButton(); } this.StartTimer(); }
/// <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); // get the button renderer data ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // check if the left mouse button is pressed if (e.Button == MouseButtons.Left) { // record where the click started rendererData.ClickPoint = new Point(e.X, e.Y); // if the click was inside the button, set the button state to pressed if (this.CalcButtonBounds().Contains(rendererData.ClickPoint)) { rendererData.ButtonState = PushButtonStates.Pressed; e.Table.Invalidate(e.CellRect); } } }
/// <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 (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); if (this.CalcCheckRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment).Contains(e.X, e.Y)) { // if (e.Cell.CheckState == CheckState.Checked) { rendererData.CheckState = CheckBoxStates.CheckedPressed; } else if (e.Cell.CheckState == CheckState.Indeterminate) { rendererData.CheckState = CheckBoxStates.MixedPressed; } else //if (e.Cell.CheckState == CheckState.Unchecked) { rendererData.CheckState = CheckBoxStates.UncheckedPressed; } e.Table.Invalidate(e.CellRect); } } }
/// <summary> /// Raises the MouseEnter event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public override void OnMouseEnter(CellMouseEventArgs e) { base.OnMouseEnter(e); // get the button renderer data ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); // if the mouse is inside the button, make sure it is "hot" if (this.CalcButtonBounds().Contains(e.X, e.Y)) { if (rendererData.ButtonState != PushButtonStates.Hot) { rendererData.ButtonState = PushButtonStates.Hot; e.Table.Invalidate(e.CellRect); } } // the mouse isn't inside the button, so it is in its normal state else { if (rendererData.ButtonState != PushButtonStates.Normal) { rendererData.ButtonState = PushButtonStates.Normal; 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 (e.Table.IsCellEditable(e.CellPos)) { // get the renderer data CheckBoxRendererData rendererData = this.GetCheckBoxRendererData(e.Cell); if (this.CalcCheckRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment).Contains(e.X, e.Y)) { if (e.Button == MouseButtons.Left && e.Table.LastMouseDownCell.Row == e.Row && e.Table.LastMouseDownCell.Column == e.Column) { // if (e.Cell.CheckState == CheckState.Checked) { if (!e.Cell.ThreeState || !(e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn) || ((CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]).CheckStyle == CheckBoxColumnStyle.RadioButton) { rendererData.CheckState = CheckBoxStates.UncheckedHot; e.Cell.CheckState = CheckState.Unchecked; } else { rendererData.CheckState = CheckBoxStates.MixedHot; e.Cell.CheckState = CheckState.Indeterminate; } } else if (e.Cell.CheckState == CheckState.Indeterminate) { rendererData.CheckState = CheckBoxStates.UncheckedHot; e.Cell.CheckState = CheckState.Unchecked; } else //if (e.Cell.CheckState == CheckState.Unchecked) { rendererData.CheckState = CheckBoxStates.CheckedHot; e.Cell.CheckState = CheckState.Checked; } e.Table.Invalidate(e.CellRect); } } } }
/// <summary> /// Raises the DoubleClick event /// </summary> /// <param name="e">A CellMouseEventArgs that contains the event data</param> public virtual void OnDoubleClick(CellMouseEventArgs e) { this.Bounds = e.CellRect; if (e.Cell == null) { this.Padding = CellPadding.Empty; } else { this.Padding = e.Cell.Padding; } if (e.Table.EditStartAction == EditStartAction.DoubleClick && e.Table.IsCellEditable(e.CellPos)) { e.Table.EditCell(e.CellPos); } }