Permalink
Browse files

Add basic menu bar

svn path=/trunk/mono-curses/; revision=144247
  • Loading branch information...
1 parent 00e84d4 commit d11f834d08577ba5c1c7e3d72caa80efe682c500 @migueldeicaza migueldeicaza committed Oct 16, 2009
Showing with 226 additions and 0 deletions.
  1. +88 −0 docs/Mono.Terminal/CheckBox.xml
  2. +53 −0 docs/Mono.Terminal/Menu.xml
  3. +35 −0 docs/Mono.Terminal/MenuBar.xml
  4. +2 −0 docs/index.xml
  5. +48 −0 gui.cs
@@ -0,0 +1,88 @@
+<Type Name="CheckBox" FullName="Mono.Terminal.CheckBox">
+ <TypeSignature Language="C#" Value="public class CheckBox : Mono.Terminal.Widget" />
+ <AssemblyInfo>
+ <AssemblyName>mono-curses</AssemblyName>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>Mono.Terminal.Widget</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+
+
+
+
+
+
+
+
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public CheckBox (int x, int y, string s);" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters><Parameter Name="x" Type="System.Int32" /><Parameter Name="y" Type="System.Int32" /><Parameter Name="s" Type="System.String" /></Parameters>
+ <Docs><param name="x">To be added.</param><param name="y">To be added.</param><param name="s">To be added.</param><summary>
+ Public constructor, creates a CheckButton based on
+ the given text at the given position.
+ </summary><remarks>
+ The size of CheckButton is computed based on the
+ text length. This CheckButton is not toggled.
+ </remarks></Docs>
+ </Member><Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public CheckBox (int x, int y, string s, bool is_checked);" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters><Parameter Name="x" Type="System.Int32" /><Parameter Name="y" Type="System.Int32" /><Parameter Name="s" Type="System.String" /><Parameter Name="is_checked" Type="System.Boolean" /></Parameters>
+ <Docs><param name="x">To be added.</param><param name="y">To be added.</param><param name="s">To be added.</param><param name="is_checked">To be added.</param><summary>
+ Public constructor, creates a CheckButton based on
+ the given text at the given position and a state.
+ </summary><remarks>
+ The size of CheckButton is computed based on the
+ text length.
+ </remarks></Docs>
+ </Member><Member MemberName="Checked">
+ <MemberSignature Language="C#" Value="public bool Checked { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>System.Boolean</ReturnType></ReturnValue>
+ <Docs><summary>
+ The state of the checkbox.
+ </summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Text">
+ <MemberSignature Language="C#" Value="public string Text { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>System.String</ReturnType></ReturnValue>
+ <Docs><summary>
+ The text displayed by this widget.
+ </summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Toggled">
+ <MemberSignature Language="C#" Value="public event EventHandler Toggled;" />
+ <MemberType>Event</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>System.EventHandler</ReturnType></ReturnValue>
+ <Docs><summary>
+ Toggled event, raised when the CheckButton is toggled.
+ </summary><remarks>
+ Client code can hook up to this event, it is
+ raised when the checkbutton is activated either with
+ the mouse or the keyboard.
+ </remarks></Docs>
+ </Member>
+ </Members>
+</Type>
@@ -0,0 +1,53 @@
+<Type Name="Menu" FullName="Mono.Terminal.Menu">
+ <TypeSignature Language="C#" Value="public class Menu" />
+ <AssemblyInfo>
+ <AssemblyName>mono-curses</AssemblyName>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>System.Object</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+
+
+
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public Menu (string title, string help, Mono.Terminal.Menu[] children);" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters><Parameter Name="title" Type="System.String" /><Parameter Name="help" Type="System.String" /><Parameter Name="children" Type="Mono.Terminal.Menu[]" /></Parameters>
+ <Docs><param name="title">To be added.</param><param name="help">To be added.</param><param name="children">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Children">
+ <MemberSignature Language="C#" Value="public Mono.Terminal.Menu[] Children { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>Mono.Terminal.Menu[]</ReturnType></ReturnValue>
+ <Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Help">
+ <MemberSignature Language="C#" Value="public string Help { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>System.String</ReturnType></ReturnValue>
+ <Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Title">
+ <MemberSignature Language="C#" Value="public string Title { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>System.String</ReturnType></ReturnValue>
+ <Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member>
+ </Members>
+</Type>
@@ -0,0 +1,35 @@
+<Type Name="MenuBar" FullName="Mono.Terminal.MenuBar">
+ <TypeSignature Language="C#" Value="public class MenuBar : Mono.Terminal.Widget" />
+ <AssemblyInfo>
+ <AssemblyName>mono-curses</AssemblyName>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Base>
+ <BaseTypeName>Mono.Terminal.Widget</BaseTypeName>
+ </Base>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public MenuBar (Mono.Terminal.Menu[] menus);" />
+ <MemberType>Constructor</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Parameters><Parameter Name="menus" Type="Mono.Terminal.Menu[]" /></Parameters>
+ <Docs><param name="menus">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks></Docs>
+ </Member><Member MemberName="Menus">
+ <MemberSignature Language="C#" Value="public Mono.Terminal.Menu[] Menus { set; get; }" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue><ReturnType>Mono.Terminal.Menu[]</ReturnType></ReturnValue>
+ <Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs>
+ </Member>
+ </Members>
+</Type>
View
@@ -41,6 +41,8 @@
<Type Name="IListProvider" Kind="Interface" />
<Type Name="Label" Kind="Class" />
<Type Name="ListView" Kind="Class" />
+ <Type Name="Menu" />
+ <Type Name="MenuBar" />
<Type Name="Screen" Kind="Class" />
<Type Name="TrimLabel" Kind="Class" />
<Type Name="Widget" Kind="Class" />
View
48 gui.cs
@@ -615,6 +615,9 @@ public Entry (int x, int y, int w, string s) : base (x, y, w, 1)
/// </remarks>
public bool Secret { get; set; }
+ /// <summary>
+ /// Sets the cursor position.
+ /// </summary>
public override void PositionCursor ()
{
Move (y, x+point-first);
@@ -1862,6 +1865,50 @@ public override void DoSizeChanged ()
LayoutButtons ();
}
}
+
+ public class Menu {
+ public Menu (string title, string help, Menu [] children)
+ {
+ Title = title;
+ Help = help;
+ Children = children;
+ }
+ public string Title { get; set; }
+ public string Help { get; set; }
+ public Menu [] Children { get; set; }
+ }
+
+ public class MenuBar : Widget {
+ public Menu [] Menus { get; set; }
+ bool active;
+
+ public MenuBar (Menu [] menus) : base (0, 0, Application.Cols, 1)
+ {
+ Menus = menus;
+ }
+
+ public override void Redraw ()
+ {
+ Move (y, 0);
+ Curses.attrset (Application.ColorFocus);
+ for (int i = 0; i < Application.Cols; i++)
+ Curses.addch (' ');
+
+ Move (y, 1);
+ foreach (var menu in Menus){
+ if (active){
+ } else {
+ }
+ Curses.addch (' ');
+ Curses.addstr (menu.Title);
+ Curses.addstr (" ");
+ if (active){
+ } else {
+ }
+ Curses.addch (' ');
+ }
+ }
+ }
/// <summary>
/// gui.cs Application driver.
@@ -2008,6 +2055,7 @@ public static void Init (bool disable_color)
use_color = Curses.has_colors ();
Curses.start_color ();
+ Curses.use_default_colors ();
if (use_color){
ColorNormal = MakeColor (Curses.COLOR_WHITE, Curses.COLOR_BLUE);
ColorFocus = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_CYAN);

0 comments on commit d11f834

Please sign in to comment.