diff --git a/Ribbons/ApplicationMenu.cs b/Ribbons/ApplicationMenu.cs
index bc0ee17..59f78b6 100644
--- a/Ribbons/ApplicationMenu.cs
+++ b/Ribbons/ApplicationMenu.cs
@@ -120,6 +120,21 @@ protected override void ForAll (bool include_internals, Callback callback)
Widget w = items[i];
if(w.Visible) callback (w);
}
+
+ if(optionsBtn != null && optionsBtnVisible)
+ {
+ callback (optionsBtn);
+ }
+
+ if(exitBtn != null && exitBtnVisible)
+ {
+ callback (exitBtn);
+ }
+
+ if(activeMenu != null && activeMenuVisible)
+ {
+ callback (activeMenu);
+ }
}
protected override void OnSizeRequested (ref Requisition requisition)
@@ -283,30 +298,42 @@ protected void Draw (Context cr)
}
- public class MenuItem : Widget
+ public class MenuItem : Bin
{
- private Image icon;
- private string label;
+ private Widget img;
+ private Label lbl;
private Widget menu;
[GLib.Signal("action")]
public event EventHandler Action;
- public Image Icon
+ /// Image to display.
+ public Widget Image
{
- get { return icon; }
set
{
- throw new NotImplementedException();
+ if(img == value) return;
+ if(img != null) UnbindWidget (img);
+ img = value;
+ if(img != null) BindWidget (img);
+ UpdateImageLabel ();
}
+ get { return img; }
}
-
+
+ /// Label to display.
public string Label
{
- get { return label; }
set
{
- throw new NotImplementedException();
+ if(lbl != null) UnbindWidget (lbl);
+ lbl = new Gtk.Label (value);
+ if(lbl != null) BindWidget (lbl);
+ UpdateImageLabel ();
+ }
+ get
+ {
+ return lbl == null ? null : lbl.Text;
}
}
@@ -315,9 +342,113 @@ public Widget Menu
get { return menu; }
set
{
- throw new NotImplementedException();
+ menu = value;
+ QueueResize ();
}
}
+
+ /// Constructor given a label to display.
+ /// Label to display.
+ public MenuItem (string Label) : this ()
+ {
+ this.Label = Label;
+ }
+
+ /// Constructor given an image to display.
+ /// Image to display
+ public MenuItem (Image Image) : this ()
+ {
+ this.Image = Image;
+ }
+
+ /// Constructor given a label and an image to display.
+ /// Image to display.
+ /// Label to display.
+ public MenuItem (Image Image, string Label) : this ()
+ {
+ this.Image = Image;
+ this.Label = Label;
+ }
+
+ /// Constructs a Button from a stock.
+ /// Name of the stock.
+ /// true if the image should be large, false otherwise.
+ public static MenuItem FromStockIcon (string Name, bool Large)
+ {
+ Image img = new Image (Name, Large ? IconSize.LargeToolbar : IconSize.SmallToolbar);
+ return btn = new MenuItem (img);
+ }
+
+ /// Constructs a Button from a stock.
+ /// Name of the stock.
+ /// Label to display.
+ /// true if the image should be large, false otherwise.
+ public static MenuItem FromStockIcon (string Name, string Label, bool Large)
+ {
+ Image img = new Image (Name, Large ? IconSize.LargeToolbar : IconSize.SmallToolbar);
+ return new MenuItem (img, Label);
+ }
+
+ /// Updates the child widget containing the label and/or image.
+ protected void UpdateImageLabel ()
+ {
+ if(Child != null)
+ {
+ Container con = Child as Container;
+ if(con != null)
+ {
+ con.Remove (img);
+ con.Remove (lbl);
+ }
+ Remove (Child);
+ }
+
+ if(lbl != null && img != null)
+ {
+ HBox box = new HBox (false, 0);
+ box.Add (img);
+ box.Add (lbl);
+ Child = box;
+ }
+ else if(lbl != null)
+ {
+ Child = lbl;
+ }
+ else if(img != null)
+ {
+ Child = img;
+ }
+ }
+
+ protected override void OnSizeRequested (ref Requisition requisition)
+ {
+ base.OnSizeRequested (ref requisition);
+ }
+
+ protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+ {
+ base.OnSizeAllocated (allocation);
+ }
+
+ protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ {
+ Context cr = Gdk.CairoHelper.Create (this.GdkWindow);
+
+ cr.Rectangle (evnt.Area.X, evnt.Area.Y, evnt.Area.Width, evnt.Area.Height);
+ cr.Clip ();
+ Draw (cr);
+
+ ((IDisposable)cr.Target).Dispose ();
+ ((IDisposable)cr).Dispose ();
+
+ return base.OnExposeEvent (evnt);
+ }
+
+ protected void Draw (Context cr)
+ {
+ Rectangle rect = new Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
+ theme.DrawApplicationMenuItem (cr, rect, this);
+ }
}
}
}
diff --git a/Ribbons/ChangeLog b/Ribbons/ChangeLog
index f1f2600..69973b5 100644
--- a/Ribbons/ChangeLog
+++ b/Ribbons/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-26 Laurent Debacker
+
+ * Theme.cs: Dummy renderer for App menu and app menu item
+ * ApplicationMenu.cs: More work on app menu item
+
2008-06-25 Laurent Debacker
* ApplicationButton.cs: Bugfixes for popup position, and misc other bug
diff --git a/Ribbons/Theme.cs b/Ribbons/Theme.cs
index 32af6c0..c4040b0 100644
--- a/Ribbons/Theme.cs
+++ b/Ribbons/Theme.cs
@@ -16,7 +16,14 @@ public enum ButtonState
internal void DrawApplicationMenu (Context cr, Rectangle r, ApplicationMenu w)
{
-
+ cr.Color = new Color (1, 0, 0);
+ cr.Fill ();
+ }
+
+ internal void DrawApplicationMenuItem (Context cr, Rectangle r, ApplicationMenu.MenuItem w)
+ {
+ cr.Color = new Color (0, 1, 0);
+ cr.Fill ();
}
/// Draws a group.