[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.11,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.11, 1.12 CheckBox.cs, 1.7, 1.8 Control.cs, 1.42, 1.43 EventId.cs, 1.10, 1.11 RadioButton.cs, 1.3, 1.4 |
Date: |
Fri, 21 Nov 2003 06:47:37 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv15371/System.Windows.Forms
Modified Files:
ButtonBase.cs CheckBox.cs Control.cs EventId.cs RadioButton.cs
Log Message:
Implement glyph-based drawing of checkboxes; fix some drawing/logic bugs
in "CheckBox" and "ButtonBase".
Index: EventId.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/EventId.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** EventId.cs 16 Nov 2003 15:06:53 -0000 1.10
--- EventId.cs 21 Nov 2003 06:47:35 -0000 1.11
***************
*** 89,92 ****
--- 89,94 ----
// "CheckBox" events.
+ AppearanceChanged,
+ CheckedChanged,
CheckStateChanged,
Index: Control.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Control.cs,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** Control.cs 16 Nov 2003 15:04:08 -0000 1.42
--- Control.cs 21 Nov 2003 06:47:35 -0000 1.43
***************
*** 386,396 ****
}
}
- [TODO]
public bool CanSelect
{
get
{
! // TODO
! return false;
}
}
--- 386,394 ----
}
}
public bool CanSelect
{
get
{
! return
GetStyle(ControlStyles.Selectable);
}
}
Index: ButtonBase.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/ButtonBase.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ButtonBase.cs 2 Nov 2003 22:14:38 -0000 1.11
--- ButtonBase.cs 21 Nov 2003 06:47:35 -0000 1.12
***************
*** 390,394 ****
// Redraw the button after a state change.
! private void Redraw()
{
// Bail out if the button is not currently
visible.
--- 390,394 ----
// Redraw the button after a state change.
! internal void Redraw()
{
// Bail out if the button is not currently
visible.
***************
*** 449,456 ****
{
entered = true;
! if (flatStyle == FlatStyle.Popup)
! {
! Redraw();
! }
base.OnMouseEnter(e);
}
--- 449,453 ----
{
entered = true;
! Redraw();
base.OnMouseEnter(e);
}
***************
*** 458,467 ****
{
entered = false;
! if (flatStyle == FlatStyle.Popup || pressed)
! {
! pressed = false;
! button = MouseButtons.None;
! Redraw();
! }
base.OnMouseLeave(e);
}
--- 455,459 ----
{
entered = false;
! Redraw();
base.OnMouseLeave(e);
}
Index: CheckBox.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/CheckBox.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** CheckBox.cs 8 Oct 2003 15:29:22 -0000 1.7
--- CheckBox.cs 21 Nov 2003 06:47:35 -0000 1.8
***************
*** 24,27 ****
--- 24,28 ----
using System.Drawing;
using System.Drawing.Drawing2D;
+ using System.Drawing.Text;
using System.ComponentModel;
using System.Windows.Forms;
***************
*** 38,43 ****
private bool threeState;
private CheckState state;
! private Size defaultSize;
! private int checkSize = 13;
// Contructor.
--- 39,44 ----
private bool threeState;
private CheckState state;
! private const int normalCheckSize = 13;
! private const int flatCheckSize = 13;
// Contructor.
***************
*** 45,54 ****
{
Appearance = Appearance.Normal;
- defaultSize = new Size(104, 24);
- Size = defaultSize;
checkAlign = ContentAlignment.MiddleLeft;
TextAlign = ContentAlignment.MiddleLeft;
}
internal override void Draw(Graphics graphics)
{
--- 46,55 ----
{
Appearance = Appearance.Normal;
checkAlign = ContentAlignment.MiddleLeft;
TextAlign = ContentAlignment.MiddleLeft;
+ autoCheck = true;
}
+ // Draw the contents of this check box.
internal override void Draw(Graphics graphics)
{
***************
*** 61,64 ****
--- 62,75 ----
int checkX = 0;
int checkY = 0;
+
+ int checkSize;
+ if(FlatStyle == FlatStyle.Flat)
+ {
+ checkSize = flatCheckSize;
+ }
+ else
+ {
+ checkSize = normalCheckSize;
+ }
switch (checkAlign)
***************
*** 106,110 ****
checkState = ButtonState.Checked;
}
! ControlPaint.DrawCheckBox(graphics, checkX,
checkY, checkSize, checkSize, checkState);
}
--- 117,135 ----
checkState = ButtonState.Checked;
}
! if(pressed && entered)
! {
! checkState |= ButtonState.Pushed;
! }
! if(!Enabled)
! {
! checkState |= ButtonState.Inactive;
! }
! if(FlatStyle == FlatStyle.Flat)
! {
! checkState |= ButtonState.Flat;
! }
! ControlPaint.DrawCheckBox
! (graphics, checkX, checkY,
! checkSize, checkSize, checkState);
}
***************
*** 116,123 ****
--- 141,159 ----
int height = Height - 4;
+ int checkSize;
+ if(FlatStyle == FlatStyle.Flat)
+ {
+ checkSize = flatCheckSize;
+ }
+ else
+ {
+ checkSize = normalCheckSize;
+ }
+
SizeF textSize = graphics.MeasureString(Text,
Font);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Far;
+ format.HotkeyPrefix = HotkeyPrefix.Show;
switch (checkAlign)
***************
*** 194,204 ****
break;
}
- Brush brush = new SolidBrush(ForeColor);
Rectangle rect = new Rectangle(x, y, width,
height);
! graphics.DrawString(Text, Font, brush, rect,
format);
! brush.Dispose();
}
! // Gets or sets the value that determines the appearance of a check box
control.
public Appearance Appearance
{
--- 230,253 ----
break;
}
Rectangle rect = new Rectangle(x, y, width,
height);
! String text = Text;
! Font font = Font;
! if(text != null && text != String.Empty)
! {
! if(Enabled)
! {
! Brush brush = new
SolidBrush(ForeColor);
! graphics.DrawString(text, font,
brush, rect, format);
! brush.Dispose();
! }
! else
! {
! ControlPaint.DrawStringDisabled
! (graphics, text, font,
BackColor, rect, format);
! }
! }
}
! // Gets or sets the check box appearance.
public Appearance Appearance
{
***************
*** 209,213 ****
set
{
! appearance = value;
}
}
--- 258,267 ----
set
{
! if(appearance != value)
! {
! appearance = value;
! Redraw();
!
OnAppearanceChanged(EventArgs.Empty);
! }
}
}
***************
*** 222,233 ****
set
{
! if(autoCheck != value)
! {
! autoCheck = value;
! }
}
}
! // Gets or sets the horizontal and vertical alignment of a check box on
a check box control.
public ContentAlignment CheckAlign
{
--- 276,284 ----
set
{
! autoCheck = value;
}
}
! // Gets or set alignment of a check box on a check box control.
public ContentAlignment CheckAlign
{
***************
*** 238,243 ****
set
{
! checkAlign = value;
! Invalidate();
}
}
--- 289,297 ----
set
{
! if(checkAlign != value)
! {
! checkAlign = value;
! Invalidate();
! }
}
}
***************
*** 274,278 ****
--- 328,339 ----
if(state != value)
{
+ bool checkedBefore = (state !=
CheckState.Unchecked);
state = value;
+ bool checkedAfter = (state !=
CheckState.Unchecked);
+ Redraw();
+ if(checkedBefore !=
checkedAfter)
+ {
+
OnCheckedChanged(EventArgs.Empty);
+ }
OnCheckStateChanged(EventArgs.Empty);
}
***************
*** 283,297 ****
#if CONFIG_COMPONENT_MODEL
public override ISite Site
!
! {
! get
! {
! return base.Site;
! }
! set
! {
! base.Site = value;
! }
! }
#endif
--- 344,357 ----
#if CONFIG_COMPONENT_MODEL
public override ISite Site
! {
! get
! {
! return base.Site;
! }
! set
! {
! base.Site = value;
! }
! }
#endif
***************
*** 319,333 ****
set
{
! if(threeState != value)
! {
! threeState = value;
! }
}
}
// Occurs when the value of the Appearance property changes.
! public event EventHandler AppearanceChanged;
// Occurs when the value of the Checked property changes.
! public event EventHandler CheckedChanged;
// Event that is emitted when the check state changes.
--- 379,411 ----
set
{
! threeState = value;
}
}
+
// Occurs when the value of the Appearance property changes.
! public event EventHandler AppearanceChanged
! {
! add
! {
! AddHandler(EventId.AppearanceChanged,
value);
! }
! remove
! {
!
RemoveHandler(EventId.AppearanceChanged, value);
! }
! }
// Occurs when the value of the Checked property changes.
! public event EventHandler CheckedChanged
! {
! add
! {
! AddHandler(EventId.CheckedChanged,
value);
! }
! remove
! {
! RemoveHandler(EventId.CheckedChanged,
value);
! }
! }
// Event that is emitted when the check state changes.
***************
*** 343,346 ****
--- 421,425 ----
}
}
+
// Gets the required creation parameters when the control handle is
created.
protected override CreateParams CreateParams
***************
*** 351,362 ****
}
}
! // Gets the default Input Method Editor (IME) mode supported by this
control.
! protected override ImeMode DefaultImeMode
! {
! get
! {
! return base.DefaultImeMode;
! }
! }
// Gets the default size of the control.
protected override Size DefaultSize
--- 430,434 ----
}
}
!
// Gets the default size of the control.
protected override Size DefaultSize
***************
*** 364,371 ****
get
{
! return defaultSize;
}
}
protected override AccessibleObject CreateAccessibilityInstance()
{
--- 436,444 ----
get
{
! return new Size(104, 24);
}
}
+ // Create an accessibility object.
protected override AccessibleObject CreateAccessibilityInstance()
{
***************
*** 376,381 ****
protected virtual void OnAppearanceChanged(EventArgs e)
{
! if (AppearanceChanged != null)
! AppearanceChanged(this, e);
}
--- 449,458 ----
protected virtual void OnAppearanceChanged(EventArgs e)
{
! EventHandler handler;
! handler =
(EventHandler)(GetHandler(EventId.AppearanceChanged));
! if(handler != null)
! {
! handler(this, e);
! }
}
***************
*** 383,389 ****
protected virtual void OnCheckedChanged(EventArgs e)
{
! if (CheckedChanged != null)
! CheckedChanged(this, e);
!
}
--- 460,469 ----
protected virtual void OnCheckedChanged(EventArgs e)
{
! EventHandler handler;
! handler =
(EventHandler)(GetHandler(EventId.CheckedChanged));
! if(handler != null)
! {
! handler(this, e);
! }
}
***************
*** 402,405 ****
--- 482,509 ----
protected override void OnClick(EventArgs e)
{
+ if(autoCheck)
+ {
+ CheckState newState;
+ if(state == CheckState.Unchecked)
+ {
+ newState = CheckState.Checked;
+ }
+ else if(state == CheckState.Checked)
+ {
+ if(threeState)
+ {
+ newState =
CheckState.Indeterminate;
+ }
+ else
+ {
+ newState =
CheckState.Unchecked;
+ }
+ }
+ else
+ {
+ newState = CheckState.Unchecked;
+ }
+ CheckState = newState;
+ }
base.OnClick(e);
}
***************
*** 411,448 ****
}
- protected override void OnMouseDown(MouseEventArgs e)
- {
- if(button == MouseButtons.None)
- {
- button = e.Button;
- pressed = true;
- using (Graphics graphics =
CreateGraphics())
- DrawBox(graphics);
- }
- }
-
-
// Raises the MouseUp event.
protected override void OnMouseUp(MouseEventArgs mevent)
{
! if (state == CheckState.Unchecked)
! {
! state = CheckState.Checked;
! }
! else
! {
! state = CheckState.Unchecked;
! }
!
! this.OnCheckedChanged(mevent);
! this.OnCheckStateChanged(mevent);
! if(button == mevent.Button)
{
! button = MouseButtons.None;
! pressed = false;
}
- using (Graphics graphics = CreateGraphics())
- DrawBox(graphics);
-
}
--- 515,527 ----
}
// Raises the MouseUp event.
protected override void OnMouseUp(MouseEventArgs mevent)
{
! bool clicked = (entered && pressed);
! base.OnMouseUp(mevent);
! if(clicked)
{
! OnClick(EventArgs.Empty);
}
}
***************
*** 450,460 ****
protected override bool ProcessMnemonic(char charCode)
{
return false;
- }
-
- // Set the check box state - used by the toolkit in response to events.
- internal void SetCheckState(CheckState state)
- {
- this.state = state;
}
--- 529,541 ----
protected override bool ProcessMnemonic(char charCode)
{
+ if(IsMnemonic(charCode, Text))
+ {
+ if(CanSelect)
+ {
+ OnClick(EventArgs.Empty);
+ return true;
+ }
+ }
return false;
}
Index: RadioButton.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/RadioButton.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RadioButton.cs 4 Aug 2003 04:43:20 -0000 1.3
--- RadioButton.cs 21 Nov 2003 06:47:35 -0000 1.4
***************
*** 470,486 ****
}
- // Redraw the button after a state change.
- private void Redraw()
- {
- // Bail out if the button is not currently
visible.
- if (!Visible || !IsHandleCreated) { return; }
-
- // Redraw the button.
- using (Graphics graphics = CreateGraphics())
- {
- Draw(graphics);
- }
- }
public override string ToString()
{
--- 470,475 ----
}
+ // Convert this object into a string.
public override string ToString()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBase.cs, 1.11, 1.12 CheckBox.cs, 1.7, 1.8 Control.cs, 1.42, 1.43 EventId.cs, 1.10, 1.11 RadioButton.cs, 1.3, 1.4,
Rhys Weatherley <address@hidden> <=