Author: rolf
Date: 2006-11-28 13:43:23 -0500 (Tue, 28 Nov 2006)
New Revision: 68600
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
Log:
2006-11-28 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* MenuItem.cs:
- When cloning a menu also clone MdiList and clone the
window menu items properly (as the forms and menuitems
are kept in an internal hashtable, these need updating
as well)
- Rewrote the window menu code, menu items are added in the
order the forms were added to their parent, and they are
updated every time the window menu is shown (before the
list was only generated once, in the current order of the
forms, and would never be updated). A checkmark is shown
next to the item corresponding to the active mdi child.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-28 18:42:19 UTC (rev 68599)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-28 18:43:23 UTC (rev 68600)
@@ -1,5 +1,19 @@
2006-11-28 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+ * MenuItem.cs:
+ - When cloning a menu also clone MdiList and clone the
+ window menu items properly (as the forms and menuitems
+ are kept in an internal hashtable, these need updating
+ as well)
+ - Rewrote the window menu code, menu items are added in the
+ order the forms were added to their parent, and they are
+ updated every time the window menu is shown (before the
+ list was only generated once, in the current order of the
+ forms, and would never be updated). A checkmark is shown
+ next to the item corresponding to the active mdi child.
+
+2006-11-28 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
* XplatUIStructs.cs:
- Added WM_NCMOUSEHOVER and WM_NCMOUSELEAVE.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
2006-11-28 18:42:19 UTC (rev 68599)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
2006-11-28 18:43:23 UTC (rev 68600)
@@ -53,7 +53,9 @@
private int index;
private bool mdilist;
private Hashtable mdilist_items;
+ private Hashtable mdilist_forms;
private MdiClient mdicontainer;
+ private bool is_window_menu_item;
private bool defaut_item;
private bool visible;
private bool ownerdraw;
@@ -408,6 +410,22 @@
{
base.CloneMenu (menuitem); // Copy subitems
+ // Window list
+ MdiList = menuitem.MdiList;
+ is_window_menu_item = menuitem.is_window_menu_item;
+ // Remove items corresponding to window menu items, and
add new items
+ // (Otherwise window menu items would show up twice,
since the PopulateWindowMenu doesn't
+ // now them)
+ bool populated = false;
+ for (int i = MenuItems.Count - 1; i >= 0; i--) {
+ if (MenuItems [i].is_window_menu_item) {
+ MenuItems.RemoveAt (i);
+ populated = true;
+ }
+ }
+ if (populated)
+ PopulateWindowMenu ();
+
// Properties
BarBreak = menuitem.BarBreak;
Break = menuitem.Break;
@@ -517,11 +535,19 @@
internal void PerformDrawItem (DrawItemEventArgs e)
{
- if (mdilist && mdilist_items == null) {
+ PopulateWindowMenu ();
+ OnDrawItem (e);
+ }
+
+ private void PopulateWindowMenu ()
+ {
+ if (mdilist) {
+ if (mdilist_items == null) {
+ mdilist_items = new Hashtable ();
+ mdilist_forms = new Hashtable ();
+ }
+
do {
- // Add the mdilist for the first time
- mdilist_items = new Hashtable ();
-
MainMenu main = GetMainMenu ();
if (main == null || main.GetForm () ==
null)
break;
@@ -531,17 +557,48 @@
if (mdicontainer == null)
break;
- foreach (Form mdichild in
mdicontainer.Controls) {
- MenuItem item = new MenuItem
(mdichild.Text);
- item.Click += new EventHandler
(MdiWindowClickHandler);
- MenuItems.AddNoEvents (item);
- mdilist_items [item] = mdichild;
+ // Remove closed forms
+ foreach (MenuItem item in
mdilist_items.Keys) {
+ Form mdichild = (Form)
mdilist_items [item];
+ if
(!mdicontainer.original_order.Contains (mdichild)) {
+ mdilist_items.Remove
(item);
+ mdilist_forms.Remove
(mdichild);
+ MenuItems.Remove (item);
+ }
}
-
+
+ // Add new forms and update state for
existing forms.
+ MenuItem previous = null;
+ for ( int i = 0; i <
mdicontainer.original_order.Count; i++) {
+ Form mdichild = (Form)
mdicontainer.original_order [i];
+ MenuItem item;
+ if (mdilist_forms.Contains
(mdichild)) {
+ item = (MenuItem)
mdilist_forms [mdichild];
+ } else {
+ item = new MenuItem ();
+
item.is_window_menu_item = true;
+ item.Click += new
EventHandler (MdiWindowClickHandler);
+ mdilist_items [item] =
mdichild;
+ mdilist_forms
[mdichild] = item;
+ MenuItems.AddNoEvents
(item);
+ }
+ item.Visible = mdichild.Visible;
+ item.Text = "&" + (i +
1).ToString () + " " + mdichild.Text;
+ item.Checked =
form.ActiveMdiChild == mdichild;
+ previous = item;
+ }
} while (false);
+ } else {
+ // Remove all forms
+ if (mdilist_items != null) {
+ foreach (MenuItem item in
mdilist_items.Values) {
+ MenuItems.Remove (item);
+ }
+
+ mdilist_forms.Clear ();
+ mdilist_items.Clear ();
+ }
}
-
- OnDrawItem (e);
}
internal void PerformMeasureItem (MeasureItemEventArgs e)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches