Author: jba
Date: 2005-04-29 03:31:47 -0400 (Fri, 29 Apr 2005)
New Revision: 43773
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
Log:
MonthCalendar.cs, DateTimePicker.cs: Made monthcalendar dropdown
behave like combobox and comboboxlist (still not sure if this is
correct though).
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-04-29 06:29:56 UTC (rev 43772)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-04-29 07:31:47 UTC (rev 43773)
@@ -1,3 +1,9 @@
+2005-04-29 John BouAntoun <[EMAIL PROTECTED]>
+
+ * MonthCalendar.cs, DateTimePicker.cs: Made monthcalendar dropdwon
+ behave like combobox and comboboxlist (still not sure if this is
+ correct though).
+
2005-04-28 Jackson Harper <[EMAIL PROTECTED]>
* ThemeWin32Classic.cs: Don't fill the middle of progress
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
2005-04-29 06:29:56 UTC (rev 43772)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DateTimePicker.cs
2005-04-29 07:31:47 UTC (rev 43773)
@@ -45,7 +45,6 @@
#region Public variables
// this class has to have the specified hour, minute and
second, as it says in msdn
- //public static readonly DateTime MaxDateTime = DateTime.Parse
("31 December 9998");//, 23:59:59");
public static readonly DateTime MaxDateTime = new DateTime
(9998, 12, 31, 23, 59, 59);
public static readonly DateTime MinDateTime = new DateTime
(1753, 1, 1);
@@ -110,10 +109,11 @@
month_calendar.DateSelected += new
DateRangeEventHandler (MonthCalendarDateSelectedHandler);
KeyPress += new KeyPressEventHandler (KeyPressHandler);
- LostFocus += new EventHandler (LostFocusHandler);
+// LostFocus += new EventHandler (LostFocusHandler);
MouseDown += new MouseEventHandler (MouseDownHandler);
Paint += new PaintEventHandler (PaintHandler);
+ SetStyle (ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);
}
#endregion
@@ -224,8 +224,7 @@
if (custom_format != value) {
custom_format = value;
if (this.Format ==
DateTimePickerFormat.Custom) {
- // invalidate the value inside
this control
- this.Invalidate
(date_area_rect);
+ // TODO: change the text value
of the dtp
}
}
}
@@ -240,7 +239,7 @@
public LeftRightAlignment DropDownAlign {
set {
if (drop_down_align != value) {
- drop_down_align = value;
+ drop_down_align = value;
}
}
get {
@@ -367,10 +366,12 @@
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Text {
set {
+ // TODO: if the format is a custom format we
need to do a custom parse here
DateTime parsed_value = DateTime.Parse (value);
if (date_value != parsed_value) {
Value = parsed_value;
- }
+ }
+ text = FormatValue ();
}
get {
return text;
@@ -591,7 +592,7 @@
location.X = parent_control_rect.Right -
child_size.Width;
}
- Point screen_location = PointToScreen (location);
+ Point screen_location = PointToScreen (location);
// TODO: enable this part when screen comes into the classes
/*
Rectangle working_area =
Screen.FromControl(this).WorkingArea;
@@ -629,9 +630,9 @@
align_area,
month_calendar.Size,
(this.DropDownAlign ==
LeftRightAlignment.Left));
-
month_calendar.Show ();
month_calendar.Focus ();
+ month_calendar.Capture = true;
// fire any registered events
if (this.DropDown != null) {
@@ -644,6 +645,7 @@
{
this.is_drop_down_visible = false;
Invalidate (drop_down_arrow_rect);
+ month_calendar.Capture = false;
if (month_calendar.Visible) {
month_calendar.Hide ();
}
@@ -658,21 +660,20 @@
e.Handled = true;
}
- // if we lose focus and the drop down is up, then close it
- private void LostFocusHandler (object sender, EventArgs e)
- {
- if (is_drop_down_visible && !month_calendar.Focused) {
- this.HideMonthCalendar ();
- }
- }
+// // if we lose focus and the drop down is up, then close it
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (is_drop_down_visible && !month_calendar.Focused) {
+// this.HideMonthCalendar ();
+// }
+// }
// fired when a user clicks on the month calendar to select a
date
private void MonthCalendarDateSelectedHandler (object sender,
DateRangeEventArgs e)
{
this.Value = e.Start.Date.Add (this.Value.TimeOfDay);
this.HideMonthCalendar ();
- this.Focus ();
-
System.Console.WriteLine("MonthCalendarDateSelectedHandler");
+ this.Focus ();
}
// to check if the mouse has come down on this control
@@ -688,8 +689,7 @@
DropDownMonthCalendar ();
} else {
// mouse down on this control anywhere else
collapses it
- if (is_drop_down_visible) {
- System.Console.WriteLine("hiding cause of mouse
down");
+ if (is_drop_down_visible) {
HideMonthCalendar ();
}
}
@@ -716,7 +716,7 @@
ret_value =
date_value.ToShortDateString ();
break;
case DateTimePickerFormat.Time:
- ret_value =
date_value.ToShortDateString ();
+ ret_value = date_value.ToLongTimeString
();
break;
default:
ret_value = date_value.ToLongDateString
();
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
2005-04-29 06:29:56 UTC (rev 43772)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MonthCalendar.cs
2005-04-29 07:31:47 UTC (rev 43773)
@@ -25,7 +25,6 @@
// REMAINING TODO:
// - get the date_cell_size and title_size to be pixel perfect match of SWF
// - show the year spin control
-// - remove comments around the "if (this.Capture) {" in the TimerHandler
method
using System;
using System.Collections;
@@ -165,7 +164,7 @@
SetUpContextMenu ();
// event handlers
- LostFocus += new EventHandler (LostFocusHandler);
+// LostFocus += new EventHandler (LostFocusHandler);
timer.Tick += new EventHandler (TimerHandler);
MouseMove += new MouseEventHandler (MouseMoveHandler);
MouseDown += new MouseEventHandler (MouseDownHandler);
@@ -1400,9 +1399,7 @@
// raised on the timer, for mouse hold clicks
private void TimerHandler (object sender, EventArgs e) {
-// NOTE: i have diabled the if this.Capture because it doesn't work
-// when this.Capture works then need to renable the if in this section
-// // now find out which area was click
+ // now find out which area was click
if (this.Capture) {
HitTestInfo hti = this.HitTest
(this.PointToClient (MousePosition));
// see if it was clicked on the prev or next
mouse
@@ -1487,15 +1484,15 @@
this.is_date_clicked = false;
}
- // need when in windowed mode
- private void LostFocusHandler (object sender, EventArgs e)
- {
- if (this.owner != null) {
- if (this.Visible) {
- this.owner.HideMonthCalendar ();
- }
- }
- }
+// // need when in windowed mode
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (this.owner != null) {
+// if (this.Visible) {
+// this.owner.HideMonthCalendar ();
+// }
+// }
+// }
// occurs when mouse moves around control, used for selection
private void MouseMoveHandler (object sender, MouseEventArgs e)
{
@@ -1533,8 +1530,18 @@
timer.Stop ();
timer.Enabled = false;
}
+
+ Point point = new Point (e.X, e.Y);
+ // figure out if we are in drop down mode and a click
happened outside us
+ if (this.owner != null) {
+ if (!this.ClientRectangle.Contains (point)) {
+ this.owner.HideMonthCalendar ();
+ return;
+ }
+ }
+
//establish where was hit
- HitTestInfo hti = this.HitTest(e.X, e.Y);
+ HitTestInfo hti = this.HitTest(point);
switch (hti.HitArea) {
case HitArea.PrevMonthButton:
case HitArea.NextMonthButton:
@@ -1572,7 +1579,7 @@
default:
this.is_previous_clicked = false;
this.is_next_clicked = false;
- this.is_date_clicked = false;
+ this.is_date_clicked = false;
break;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches