{
private RightToLeft right_to_left = RightToLeft.Inherit;
private Form form = null;
- internal MenuTracker tracker = null;
public MainMenu () : base (null)
{
}
+#if NET_2_0
+ public MainMenu (IContainer container) : this ()
+ {
+ container.Add (this);
+ }
+#endif
+
#region Public Properties
[Localizable(true)]
+#if NET_2_0
+ [AmbientValue (RightToLeft.Inherit)]
+#endif
public virtual RightToLeft RightToLeft {
get { return right_to_left;}
set { right_to_left = value; }
return new_menu;
}
+ protected override IntPtr CreateMenuHandle ()
+ {
+ return IntPtr.Zero;
+ }
+
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
#region Private Methods
- internal void Draw ()
- {
+ internal void Draw () {
Draw (Rect);
}
- internal void Draw (Rectangle rect)
+ internal void Draw (Rectangle clip_rect) {
+ PaintEventArgs pe;
+
+ if (Wnd.IsHandleCreated) {
+ pe = XplatUI.PaintEventStart(Wnd.window.Handle, false);
+ pe.Graphics.Clip = new Region (clip_rect);
+ Draw (pe, Rect);
+ XplatUI.PaintEventEnd(Wnd.window.Handle, false);
+ }
+ }
+
+ internal void Draw (PaintEventArgs pe)
{
- Graphics g;
+ Draw (pe, Rect);
+ }
- if (Wnd.window.Handle == IntPtr.Zero)
+ internal void Draw (PaintEventArgs pe, Rectangle rect)
+ {
+ if (!Wnd.IsHandleCreated)
return;
X = rect.X;
Y = rect.Y;
Height = Rect.Height;
- g = XplatUI.GetMenuDC(Wnd.window.Handle, IntPtr.Zero);
- ThemeEngine.Current.DrawMenuBar (g, this, rect);
- XplatUI.ReleaseMenuDC(Wnd.window.Handle, g);
+ ThemeEngine.Current.DrawMenuBar (pe.Graphics, this, rect);
+
+ PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
+ if (eh != null)
+ eh (this, pe);
+ }
+
+ internal override void InvalidateItem (MenuItem item)
+ {
+ Draw (item.bounds);
}
internal void SetForm (Form form)
if (form == null)
return;
- Draw ();
+ Rectangle clip = Rect;
+ Height = 0; /* need this so the theme code will re-layout the menu items
+ (why is the theme code doing the layout? argh) */
+ Draw (clip);
}
/* Mouse events from the form */
internal void OnMouseDown (object window, MouseEventArgs args)
{
- tracker.OnClick (args);
+ tracker.OnMouseDown (args);
}
internal void OnMouseMove (object window, MouseEventArgs e)
MouseEventArgs args = new MouseEventArgs (e.Button, e.Clicks, Control.MousePosition.X, Control.MousePosition.Y, e.Delta);
tracker.OnMotion (args);
}
-
+
+ static object PaintEvent = new object ();
+
+ internal event PaintEventHandler Paint {
+ add { Events.AddHandler (PaintEvent, value); }
+ remove { Events.RemoveHandler (PaintEvent, value); }
+ }
+
#endregion Private Methods
}
}