[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Button.cs, 1.4, 1.5 C
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Button.cs, 1.4, 1.5 CheckBox.cs, 1.9, 1.10 RadioButton.cs, 1.5, 1.6 |
Date: |
Fri, 21 Nov 2003 23:44:40 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv6307/System.Windows.Forms
Modified Files:
Button.cs CheckBox.cs RadioButton.cs
Log Message:
Fix some logic errors in the button classes.
Index: Button.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Button.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Button.cs 14 Jun 2003 00:36:44 -0000 1.4
--- Button.cs 21 Nov 2003 23:44:37 -0000 1.5
***************
*** 96,104 ****
protected override void OnMouseUp(MouseEventArgs e)
{
! bool clicked = (entered && pressed);
! base.OnMouseUp(e);
! if(clicked)
{
! OnClick(EventArgs.Empty);
}
}
--- 96,111 ----
protected override void OnMouseUp(MouseEventArgs e)
{
! if(button == e.Button)
{
! bool clicked = (entered && pressed);
! base.OnMouseUp(e);
! if(clicked)
! {
! OnClick(EventArgs.Empty);
! }
! }
! else
! {
! base.OnMouseUp(e);
}
}
Index: CheckBox.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/CheckBox.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** CheckBox.cs 21 Nov 2003 07:04:28 -0000 1.9
--- CheckBox.cs 21 Nov 2003 23:44:37 -0000 1.10
***************
*** 527,535 ****
protected override void OnMouseUp(MouseEventArgs mevent)
{
! bool clicked = (entered && pressed);
! base.OnMouseUp(mevent);
! if(clicked)
{
! OnClick(EventArgs.Empty);
}
}
--- 527,542 ----
protected override void OnMouseUp(MouseEventArgs mevent)
{
! if(button == mevent.Button)
{
! bool clicked = (entered && pressed);
! base.OnMouseUp(mevent);
! if(clicked)
! {
! OnClick(EventArgs.Empty);
! }
! }
! else
! {
! base.OnMouseUp(mevent);
}
}
Index: RadioButton.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/RadioButton.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RadioButton.cs 21 Nov 2003 12:05:12 -0000 1.5
--- RadioButton.cs 21 Nov 2003 23:44:37 -0000 1.6
***************
*** 45,49 ****
private int checkY;
! private static readonly int checkSize = 13;
// Constructor.
--- 45,49 ----
private int checkY;
! private const int checkSize = 13;
// Constructor.
***************
*** 60,67 ****
}
-
-
-
-
#if !CONFIG_COMPACT_FORMS
// Get or set the appearance of this radio button control.
--- 60,63 ----
***************
*** 131,146 ****
#endif
// Get or set the checked state as a simple boolean value.
public bool Checked
{
! get { return isChecked; }
set
{
! if (isChecked != value)
{
! isChecked = value;
! Redraw();
!
OnCheckedChanged(EventArgs.Empty);
}
}
}
--- 127,199 ----
#endif
+ // Disable other radio buttons in the same group as this one.
+ private void DisableOthersInGroup()
+ {
+ // Nothing to do if we aren't an "auto check"
button.
+ if(!autoCheck)
+ {
+ return;
+ }
+
+ // Remove tab stop indications from all other
buttons.
+ if(Parent != null)
+ {
+ foreach(Control child1 in
Parent.Controls)
+ {
+ RadioButton rb1 = (child1 as
RadioButton);
+ if(rb1 != null && rb1 != this)
+ {
+ if(rb1.autoCheck)
+ {
+ rb1.TabStop =
false;
+ }
+ }
+ }
+ }
+
+ // Set the tab stop indication on this button.
+ TabStop = isChecked;
+
+ // Reset all other buttons in the group.
+ if(isChecked && Parent != null)
+ {
+ foreach(Control child2 in
Parent.Controls)
+ {
+ RadioButton rb2 = (child2 as
RadioButton);
+ if(rb2 != null && rb2 != this)
+ {
+ if(rb2.autoCheck)
+ {
+ rb2.Checked =
false;
+ }
+ }
+ }
+ }
+ }
+
// Get or set the checked state as a simple boolean value.
public bool Checked
{
! get
! {
! return isChecked;
! }
set
{
! // Bail out if the value doesn't change.
! if(isChecked == value)
{
! return;
}
+
+ // Record the value and redraw this
radio button.
+ isChecked = value;
+ Redraw();
+
+ // Disable the other radio buttons in
the group.
+ DisableOthersInGroup();
+
+ // Notify event listeners of the change.
+ OnCheckedChanged(EventArgs.Empty);
}
}
***************
*** 163,167 ****
override Size DefaultSize
{
! get { return new Size(104, 24); }
}
--- 216,236 ----
override Size DefaultSize
{
! get
! {
! return new Size(104, 24);
! }
! }
!
! // Get or set the tab stop indication.
! public new bool TabStop
! {
! get
! {
! return base.TabStop;
! }
! set
! {
! base.TabStop = value;
! }
}
***************
*** 178,184 ****
}
-
-
-
// Calculate the current state of the button for its visual appearance.
internal override ButtonState CalculateState()
--- 247,250 ----
***************
*** 407,423 ****
protected override void OnClick(EventArgs e)
{
! if (!isChecked && autoCheck && Enabled)
{
- if (Parent != null)
- {
- foreach (Control c in
Parent.Controls)
- {
- RadioButton rb = c as
RadioButton;
- if ((rb != null) && (rb
!= this))
- {
- rb.Checked =
false;
- }
- }
- }
Checked = true;
}
--- 473,478 ----
protected override void OnClick(EventArgs e)
{
! if(autoCheck)
{
Checked = true;
}
***************
*** 425,455 ****
}
! // Raises the HandleCreated event.
! protected override void OnHandleCreated(EventArgs e)
! {
! base.OnHandleCreated(e);
! }
!
! protected override void OnMouseDown(MouseEventArgs e)
! {
! pressed = true;
! Redraw();
! base.OnMouseDown(e);
! }
!
! // Override MouseEnter event from ButtonBase
! protected override void OnMouseEnter(EventArgs e)
{
! entered = true;
! Redraw();
! base.OnMouseEnter(e);
}
! // Override MouseLeave event from ButtonBase
! protected override void OnMouseLeave(EventArgs e)
{
! entered = false;
! Redraw();
! base.OnMouseLeave(e);
}
--- 480,497 ----
}
! // Process a focus enter event.
! protected override void OnEnter(EventArgs e)
{
! if(MouseButtons == MouseButtons.None)
! {
! OnClick(e);
! }
! base.OnEnter(e);
}
! // Raises the HandleCreated event.
! protected override void OnHandleCreated(EventArgs e)
{
! base.OnHandleCreated(e);
}
***************
*** 457,465 ****
protected override void OnMouseUp(MouseEventArgs e)
{
! bool clicked = (entered && pressed);
! pressed = false;
! if(clicked)
{
! OnClick(EventArgs.Empty);
}
base.OnMouseUp(e);
--- 499,510 ----
protected override void OnMouseUp(MouseEventArgs e)
{
! if(button == e.Button)
{
! bool clicked = (entered && pressed);
! pressed = false;
! if(clicked)
! {
! OnClick(EventArgs.Empty);
! }
}
base.OnMouseUp(e);
***************
*** 475,481 ****
protected override bool ProcessMnemonic(char charCode)
{
return false;
}
-
// Convert this object into a string.
--- 520,541 ----
protected override bool ProcessMnemonic(char charCode)
{
+ if(IsMnemonic(charCode, Text))
+ {
+ if(CanSelect)
+ {
+ if(Focused)
+ {
+
OnClick(EventArgs.Empty);
+ return true;
+ }
+ else
+ {
+ // Bring the focus
here, which will activate us.
+ Focus();
+ }
+ }
+ }
return false;
}
// Convert this object into a string.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Button.cs, 1.4, 1.5 CheckBox.cs, 1.9, 1.10 RadioButton.cs, 1.5, 1.6,
Rhys Weatherley <address@hidden> <=