* XplatUIX11.cs: Removed unused hwnd var in SetBorderStyle.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / MdiWindowManager.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Authors:
23 //      Jackson Harper (jackson@ximian.com)
24 //
25 //
26
27
28 using System;
29 using System.Drawing;
30 using System.Drawing.Drawing2D;
31 using System.Runtime.InteropServices;
32
33 namespace System.Windows.Forms {
34
35         internal class MdiWindowManager : InternalWindowManager {
36
37                 private MainMenu merged_menu;
38                 private MainMenu maximized_menu;
39                 private MenuItem icon_menu;
40                 private ContextMenu icon_popup_menu;
41                 private FormWindowState prev_window_state;
42                 internal bool was_minimized;
43                 
44                 private PaintEventHandler draw_maximized_buttons;
45                 internal EventHandler form_closed_handler;
46                 
47                 private MdiClient mdi_container;
48                 private Rectangle prev_virtual_position;
49                 private Rectangle prev_bounds;
50
51                 private Rectangle iconic_bounds;
52
53                 private Point icon_clicked;
54                 private DateTime icon_clicked_time;
55                 private bool icon_dont_show_popup;
56                 
57                 internal Rectangle IconicBounds {
58                         get {
59                                 if (iconic_bounds == Rectangle.Empty)
60                                         return Rectangle.Empty;
61                                 Rectangle result = iconic_bounds;
62                                 result.Y = mdi_container.ClientRectangle.Bottom - iconic_bounds.Y;
63                                 return result;
64                         }
65                         set {
66                                 iconic_bounds = value;
67                                 iconic_bounds.Y = mdi_container.ClientRectangle.Bottom - iconic_bounds.Y;
68                         }
69                 }
70                 
71                 public MdiWindowManager (Form form, MdiClient mdi_container) : base (form)
72                 {
73                         this.mdi_container = mdi_container;
74                         prev_bounds = form.Bounds;
75                         prev_window_state = form.window_state;
76                         form_closed_handler = new EventHandler (FormClosed);
77                         form.Closed += form_closed_handler;
78                         form.TextChanged += new EventHandler (FormTextChangedHandler);
79                         form.SizeChanged += new EventHandler (FormSizeChangedHandler);
80                         form.LocationChanged += new EventHandler (FormLocationChangedHandler);
81                         form.VisibleChanged += new EventHandler (FormVisibleChangedHandler);
82                         draw_maximized_buttons = new PaintEventHandler (DrawMaximizedButtons);
83                         CreateIconMenus ();
84                 }
85
86                 private void FormVisibleChangedHandler (object sender, EventArgs e)
87                 {
88                         if (mdi_container == null)
89                                 return;
90                                 
91                         if (form.Visible) {
92                                 mdi_container.ActivateChild (form);
93                         } else if (mdi_container.Controls.Count > 1) {
94                                 mdi_container.ActivateActiveMdiChild ();
95                         }
96                 }
97
98                 private void FormTextChangedHandler (object sender, EventArgs e)
99                 {
100                         mdi_container.SetParentText (false);
101
102 #if NET_2_0
103                         if (form.MdiParent.MainMenuStrip != null)
104                                 form.MdiParent.MainMenuStrip.RefreshMdiItems ();
105 #endif
106                 }
107
108                 private void FormLocationChangedHandler (object sender, EventArgs e)
109                 {
110                         if (form.window_state == FormWindowState.Minimized)
111                                 IconicBounds = form.Bounds;
112                         XplatUI.RequestNCRecalc (mdi_container.Handle);
113                         form.MdiParent.MdiContainer.SizeScrollBars ();
114                 }
115
116                 private void FormSizeChangedHandler (object sender, EventArgs e)
117                 {
118                         XplatUI.RequestNCRecalc (form.MdiParent.MdiContainer.Handle);
119                         XplatUI.RequestNCRecalc (form.Handle);
120                         form.MdiParent.MdiContainer.SizeScrollBars ();
121                 }
122         
123                 public MainMenu MergedMenu {
124                         get {
125                                 if (merged_menu == null)
126                                         merged_menu = CreateMergedMenu ();
127                                 return merged_menu;
128                         }
129                 }
130
131                 private MainMenu CreateMergedMenu ()
132                 {
133                         Form parent = (Form) mdi_container.Parent;
134                         MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
135                         if (form.WindowState == FormWindowState.Maximized) {
136                                 
137                         }
138                         clone.MergeMenu (form.Menu);
139                         clone.MenuChanged += new EventHandler (MenuChangedHandler);
140                         clone.SetForm (parent);
141                         return clone;
142                 }
143
144                 public MainMenu MaximizedMenu {
145                         get {
146                                 if (maximized_menu == null)
147                                         maximized_menu = CreateMaximizedMenu ();
148                                 return maximized_menu;
149                         }
150                 }
151
152                 private MainMenu CreateMaximizedMenu ()
153                 {
154                         Form parent = (Form) mdi_container.Parent;
155                         MainMenu res = new MainMenu ();
156
157                         res.MenuItems.Add (icon_menu);
158
159                         if (parent.Menu != null) {
160                                 MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
161                                 res.MergeMenu (clone);
162                         }
163                         
164                         if (form.Menu != null) {
165                                 MainMenu clone = (MainMenu) form.Menu.CloneMenu ();
166                                 res.MergeMenu (clone);
167                         }
168                         
169                         if (res.MenuItems.Count == 0)
170                                 res.MenuItems.Add (new MenuItem ()); // Dummy item to get the menu height correct
171                         
172                         res.SetForm (parent);
173                         return res;
174                 }
175
176                 private void CreateIconMenus ()
177                 {
178                         icon_menu = new MenuItem ();
179                         icon_popup_menu = new ContextMenu ();
180
181                         icon_menu.OwnerDraw = true;
182                         icon_menu.MeasureItem += new MeasureItemEventHandler (MeasureIconMenuItem);
183                         icon_menu.DrawItem += new DrawItemEventHandler (DrawIconMenuItem);
184                         icon_menu.Click += new EventHandler (ClickIconMenuItem);
185
186                         MenuItem restore = new MenuItem ("Restore", new EventHandler (RestoreItemHandler));
187                         MenuItem move = new MenuItem ("Move", new EventHandler (MoveItemHandler));
188                         MenuItem size = new MenuItem ("Size", new EventHandler (SizeItemHandler));
189                         MenuItem minimize = new MenuItem ("Minimize", new EventHandler (MinimizeItemHandler));
190                         MenuItem maximize = new MenuItem ("Maximize", new EventHandler (MaximizeItemHandler));
191                         MenuItem close = new MenuItem ("Close", new EventHandler (CloseItemHandler));
192                         MenuItem next = new MenuItem ("Next", new EventHandler (NextItemHandler));
193
194                         icon_menu.MenuItems.AddRange (new MenuItem [] { restore, move, size, minimize,
195                                                                         maximize, close, next });
196                         icon_popup_menu.MenuItems.AddRange (new MenuItem [] { restore, move, size, minimize,
197                                                                         maximize, close, next });
198                 }
199
200                 private void ClickIconMenuItem(object sender, EventArgs e)
201                 {
202                         if ((DateTime.Now - icon_clicked_time).TotalMilliseconds < 500) {
203                                 form.Close ();
204                                 return;
205                         }
206                         icon_clicked_time = DateTime.Now;
207                         Point pnt = Point.Empty;
208                         pnt = form.MdiParent.PointToScreen (pnt);
209                         pnt = form.PointToClient (pnt);
210                         ShowPopup (pnt);
211                 }
212                 
213                 private void ShowPopup (Point pnt)
214                 {
215                         icon_popup_menu.MenuItems[0].Enabled = form.window_state != FormWindowState.Normal;    // restore
216                         icon_popup_menu.MenuItems[1].Enabled = form.window_state != FormWindowState.Maximized; // move
217                         icon_popup_menu.MenuItems[2].Enabled = form.window_state != FormWindowState.Maximized; // size
218                         icon_popup_menu.MenuItems[3].Enabled = form.window_state != FormWindowState.Minimized; // minimize
219                         icon_popup_menu.MenuItems[4].Enabled = form.window_state != FormWindowState.Maximized; // maximize
220                         icon_popup_menu.MenuItems[5].Enabled = true;  // close
221                         icon_popup_menu.MenuItems[6].Enabled = true;  // next
222                         
223                         icon_popup_menu.Show(form, pnt);
224                 }
225                 
226                 private void RestoreItemHandler (object sender, EventArgs e)
227                 {
228                         form.WindowState = FormWindowState.Normal;
229                 }
230
231                 private void MoveItemHandler (object sender, EventArgs e)
232                 {
233                         int x = 0;
234                         int y = 0;
235
236                         PointToScreen (ref x, ref y);
237                         Cursor.Position = new Point (x, y);
238                         form.Cursor = Cursors.Cross;
239                         state = State.Moving;
240                         form.Capture = true;
241                 }
242
243                 private void SizeItemHandler (object sender, EventArgs e)
244                 {
245                         int x = 0;
246                         int y = 0;
247
248                         PointToScreen (ref x, ref y);
249                         Cursor.Position = new Point (x, y);
250                         form.Cursor = Cursors.Cross;
251                         state = State.Sizing;
252                         form.Capture = true;
253                 }               
254
255                 private void MinimizeItemHandler (object sender, EventArgs e)
256                 {
257                         form.WindowState = FormWindowState.Minimized;
258                 }
259
260                 private void MaximizeItemHandler (object sender, EventArgs e)
261                 {
262                         if (form.WindowState != FormWindowState.Maximized)
263                                 form.WindowState = FormWindowState.Maximized;
264                 }
265
266                 private void CloseItemHandler (object sender, EventArgs e)
267                 {
268                         form.Close ();
269                 }
270
271                 private void NextItemHandler (object sender, EventArgs e)
272                 {
273                         mdi_container.ActivateNextChild ();
274                 }
275
276                 private void DrawIconMenuItem (object sender, DrawItemEventArgs de)
277                 {
278                         de.Graphics.DrawIcon (form.Icon, new Rectangle (de.Bounds.X + 2, de.Bounds.Y + 2,
279                                                               de.Bounds.Height - 4, de.Bounds.Height - 4));
280                 }
281
282                 private void MeasureIconMenuItem (object sender, MeasureItemEventArgs me)
283                 {
284                         int size = SystemInformation.MenuHeight;
285                         me.ItemHeight = size;
286                         me.ItemWidth = size + 2; // some padding
287                 }
288
289                 private void MenuChangedHandler (object sender, EventArgs e)
290                 {
291                         CreateMergedMenu ();
292                 }
293
294                 public override void PointToClient (ref int x, ref int y)
295                 {
296                         XplatUI.ScreenToClient (mdi_container.Handle, ref x, ref y);
297                 }
298
299                 public override void PointToScreen (ref int x, ref int y)
300                 {
301                         XplatUI.ClientToScreen (mdi_container.Handle, ref x, ref y);
302                 }
303
304                 public override void SetWindowState (FormWindowState old_state, FormWindowState window_state)
305                 {
306                         if (this.mdi_container.SetWindowStates (this))
307                                 return;
308                         
309                         if (prev_window_state == window_state)
310                                 return;
311                         
312                         if (prev_window_state == FormWindowState.Normal)
313                                 prev_bounds = form.Bounds;
314                         
315                         switch (window_state) {
316                         case FormWindowState.Minimized:
317                                 CreateButtons ();
318                                 maximize_button.Caption = CaptionButton.Maximize;
319                                 minimize_button.Caption = CaptionButton.Restore;
320                                 prev_window_state = FormWindowState.Minimized;
321                                 mdi_container.ArrangeIconicWindows (false);
322                                 MaximizedMenu.Paint -= draw_maximized_buttons;
323                                 break;
324                         case FormWindowState.Maximized:
325                                 if (mdi_container.ActiveMdiChild != form)
326                                         mdi_container.ActivateChild (form);
327                                 CreateButtons ();
328                                 maximize_button.Caption = CaptionButton.Restore;
329                                 minimize_button.Caption = CaptionButton.Minimize;
330                                 prev_window_state = FormWindowState.Maximized;
331                                 SizeMaximized ();
332                                 MaximizedMenu.Paint += draw_maximized_buttons;
333                                 break;
334                         case FormWindowState.Normal:
335                                 CreateButtons ();
336                                 maximize_button.Caption = CaptionButton.Maximize;
337                                 minimize_button.Caption = CaptionButton.Minimize;
338                                 form.Bounds = prev_bounds;
339                                 prev_window_state =FormWindowState.Normal;
340
341                                 MaximizedMenu.Paint -= draw_maximized_buttons;
342                                 break;
343                         }
344
345                         form.ResetCursor ();
346                         XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
347                         XplatUI.RequestNCRecalc (form.Handle);
348                         mdi_container.SizeScrollBars ();
349                 }
350
351                 internal void SizeMaximized ()
352                 {
353                         Rectangle pb = mdi_container.ClientRectangle;
354                         int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
355                         form.Bounds = new Rectangle (pb.Left - bw,
356                                         pb.Top - TitleBarHeight - bw,
357                                         pb.Width + bw * 2,
358                                         pb.Height + TitleBarHeight + bw * 2);
359                 }
360
361                 private void FormClosed (object sender, EventArgs e)
362                 {
363                         mdi_container.CloseChildForm (form);
364
365 #if NET_2_0
366                         if (form.MdiParent.MainMenuStrip != null)
367                                 form.MdiParent.MainMenuStrip.RefreshMdiItems ();
368 #endif
369                 }
370
371                 public override void DrawMaximizedButtons (object sender, PaintEventArgs pe)
372                 {
373                         Size bs = ThemeEngine.Current.ManagedWindowButtonSize (this);
374                         Point pnt =  XplatUI.GetMenuOrigin (mdi_container.ParentForm.Handle);
375                         int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
376                         
377                         close_button.Rectangle = new Rectangle (mdi_container.ParentForm.Size.Width - 1 - bw - bs.Width - 2,
378                                         pnt.Y + 2, bs.Width, bs.Height);
379
380                         maximize_button.Rectangle = new Rectangle (close_button.Rectangle.Left - 2 - bs.Width,
381                                         pnt.Y + 2, bs.Width, bs.Height);
382                                 
383                         minimize_button.Rectangle = new Rectangle (maximize_button.Rectangle.Left - bs.Width,
384                                         pnt.Y + 2, bs.Width, bs.Height);
385
386                         DrawTitleButton (pe.Graphics, minimize_button, pe.ClipRectangle);
387                         DrawTitleButton (pe.Graphics, maximize_button, pe.ClipRectangle);
388                         DrawTitleButton (pe.Graphics, close_button, pe.ClipRectangle);
389
390                         minimize_button.Rectangle.Y -= pnt.Y;
391                         maximize_button.Rectangle.Y -= pnt.Y;
392                         close_button.Rectangle.Y -= pnt.Y;
393                 }
394                 
395                 private bool IconRectangleContains (int x, int y)
396                 {
397                         if (form.Icon == null)
398                                 return false;
399
400                         int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
401                         Rectangle icon = new Rectangle (bw + 3, bw + 2, IconWidth, IconWidth);
402                         return icon.Contains (x, y);
403                 }
404
405                 public bool HandleMenuMouseDown (MainMenu menu, int x, int y)
406                 {
407                         Point pt = MenuTracker.ScreenToMenu (menu, new Point (x, y));
408
409                         HandleTitleBarDown (pt.X, pt.Y);
410                         return AnyPushedTitleButtons;
411                 }
412
413                 public void HandleMenuMouseUp (MainMenu menu, int x, int y)
414                 {
415                         Point pt = MenuTracker.ScreenToMenu (menu, new Point (x, y));
416
417                         HandleTitleBarUp (pt.X, pt.Y);
418                 }
419
420                 public void HandleMenuMouseLeave (MainMenu menu, int x, int y)
421                 {
422                         Point pt = MenuTracker.ScreenToMenu (menu, new Point (x, y));
423                         HandleTitleBarLeave (pt.X, pt.Y);
424
425                 }
426
427                 public void HandleMenuMouseMove (MainMenu menu, int x, int y)
428                 {
429                         Point pt = MenuTracker.ScreenToMenu (menu, new Point (x, y));
430
431                         HandleTitleBarMouseMove (pt.X, pt.Y);
432
433                 }
434
435                 protected override void HandleTitleBarLeave (int x, int y)
436                 {
437                         base.HandleTitleBarLeave (x, y);
438
439                         if (IsMaximized)
440                                 XplatUI.InvalidateNC (form.MdiParent.Handle);
441                 }
442                 
443                 protected override void HandleTitleBarUp (int x, int y)
444                 {                       
445                         if (IconRectangleContains (x, y)) {
446                                 if (!icon_dont_show_popup) {
447                                         if (IsMaximized)
448                                                 ClickIconMenuItem (null, null);
449                                         else
450                                                 ShowPopup (Point.Empty);
451                                 } else {
452                                         icon_dont_show_popup = false;
453                                 }
454                                 return;
455                         }
456                         
457                         base.HandleTitleBarUp (x, y);
458
459                         if (IsMaximized)
460                                 XplatUI.InvalidateNC (mdi_container.Parent.Handle);
461                 }
462
463                 protected override void HandleTitleBarDoubleClick (int x, int y)
464                 {
465                         if (IconRectangleContains (x, y)) {
466                                 form.Close ();
467                         } else {
468                                 form.WindowState = FormWindowState.Maximized;
469                         }
470                         base.HandleTitleBarDoubleClick (x, y);
471                 }
472                 
473                 protected override void HandleTitleBarDown (int x, int y)
474                 {                       
475                         if (IconRectangleContains (x, y)) {
476                                 if ((DateTime.Now - icon_clicked_time).TotalMilliseconds < 500 && icon_clicked.X == x && icon_clicked.Y == y) {
477                                         form.Close ();
478                                 } else {
479                                         icon_clicked_time = DateTime.Now;
480                                         icon_clicked.X = x;
481                                         icon_clicked.Y = y;
482                                 }
483                                 
484                                 return;
485                         }
486
487                         base.HandleTitleBarDown (x, y);
488                         
489                         
490                         if (IsMaximized) {
491                                 XplatUI.InvalidateNC (mdi_container.Parent.Handle);
492                         }
493                 }
494
495                 protected override bool HandleLButtonDblClick (ref Message m)
496                 {
497
498                         int x = Control.LowOrder ((int)m.LParam.ToInt32 ());
499                         int y = Control.HighOrder ((int)m.LParam.ToInt32 ());
500
501                         // Correct since we are in NC land.
502                         NCClientToNC (ref x, ref y);
503
504                         if (IconRectangleContains (x, y)) {
505                                 icon_popup_menu.Wnd.Hide ();
506                                 form.Close ();
507                                 return true;
508                         }
509                         
510                         return base.HandleLButtonDblClick (ref m);
511                 }
512
513                 protected override bool HandleLButtonDown (ref Message m)
514                 {
515
516                         int x = Control.LowOrder ((int)m.LParam.ToInt32 ());
517                         int y = Control.HighOrder ((int)m.LParam.ToInt32 ());
518
519                         // Correct y since we are in NC land.
520                         NCClientToNC(ref x, ref y);
521
522                         if (IconRectangleContains (x, y)){
523                                 if ((DateTime.Now - icon_clicked_time).TotalMilliseconds < 500) {
524                                         if (icon_popup_menu != null && icon_popup_menu.Wnd != null) {
525                                                 icon_popup_menu.Wnd.Hide ();
526                                         }
527                                         form.Close ();
528                                         return true;
529                                 } else if (form.Capture) {
530                                         icon_dont_show_popup = true;
531                                 }
532                         }
533                         return base.HandleLButtonDown (ref m);
534                 }
535
536                 protected override bool HandleNCLButtonDown (ref Message m)
537                 {
538                         return base.HandleNCLButtonDown (ref m);
539                 }
540                 
541                 protected override bool ShouldRemoveWindowManager (FormBorderStyle style)
542                 {
543                         return false;
544                 }
545
546                 protected override void HandleWindowMove (Message m)
547                 {
548                         Point move = MouseMove (m);
549                         
550                         if (move.X == 0 && move.Y == 0)
551                                 return;
552                         
553                         int x = virtual_position.X + move.X;
554                         int y = virtual_position.Y + move.Y;
555                 
556                         Rectangle client = mdi_container.ClientRectangle;
557                         if (mdi_container.VerticalScrollbarVisible)
558                                 client.Width -= SystemInformation.VerticalScrollBarWidth;
559                         if (mdi_container.HorizontalScrollbarVisible)
560                                 client.Height -= SystemInformation.HorizontalScrollBarHeight;
561                         if (!client.Contains (new Point(x + clicked_point.X, y + clicked_point.Y)))
562                                 return;
563
564                         UpdateVP (x, y, form.Width, form.Height);
565                         start = Cursor.Position;
566                 }
567
568                 protected override bool HandleNCMouseMove (ref Message m)
569                 {
570                         XplatUI.RequestAdditionalWM_NCMessages (form.Handle, true, true);
571                         return base.HandleNCMouseMove (ref m);
572                 }
573
574                 protected override void HandleNCCalcSize (ref Message m)
575                 {
576                         XplatUIWin32.NCCALCSIZE_PARAMS ncp;
577
578                         if (m.WParam == (IntPtr)1) {
579                                 ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure (m.LParam,
580                                                 typeof (XplatUIWin32.NCCALCSIZE_PARAMS));
581
582                                 int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
583                                 if (!IsMaximized)
584                                         bw++;
585
586                                 if (HasBorders) {
587                                         ncp.rgrc1.top += TitleBarHeight + bw;
588                                         if (!IsMaximized) {
589                                                 //ncp.rgrc1.top -= 1;
590                                                 ncp.rgrc1.left += bw - 2;
591                                                 ncp.rgrc1.bottom -= bw - 2;
592                                                 ncp.rgrc1.right -= bw;
593                                         } else {
594                                                 ncp.rgrc1.left += 1;
595                                                 ncp.rgrc1.bottom -= 2;
596                                                 ncp.rgrc1.right -= 3;
597                                         }
598                                 }
599
600                                 if (ncp.rgrc1.bottom < ncp.rgrc1.top)
601                                         ncp.rgrc1.bottom = ncp.rgrc1.top + 1;
602
603                                 Marshal.StructureToPtr (ncp, m.LParam, true);
604                         }
605                 }
606
607                 protected override void DrawVirtualPosition (Rectangle virtual_position)
608                 {
609                         ClearVirtualPosition ();
610
611                         if (form.Parent != null)
612                                 XplatUI.DrawReversibleRectangle (form.Parent.Handle, virtual_position, 2);
613                         prev_virtual_position = virtual_position;
614                 }
615
616                 protected override void ClearVirtualPosition ()
617                 {
618                         if (prev_virtual_position != Rectangle.Empty && form.Parent != null)
619                                 XplatUI.DrawReversibleRectangle (form.Parent.Handle,
620                                                 prev_virtual_position, 2);
621                         prev_virtual_position = Rectangle.Empty;
622                 }
623
624                 protected override void OnWindowFinishedMoving ()
625                 {
626                         form.Refresh ();
627                 }
628
629                 public override bool IsActive ()
630                 {
631                         return mdi_container.ActiveMdiChild == form;
632                 }
633
634                 protected override void Activate ()
635                 {
636                         if (mdi_container.ActiveMdiChild != form) {
637                                 mdi_container.ActivateChild (form);
638                                 mdi_container.SetWindowStates (this);
639                         }
640                         base.Activate ();
641                 }       
642         }
643 }
644