Permalink
Browse files

Add new dialog colors for errors

Add string.format overload for buttons
add cold-key processing for buttons to catch the key letter
  • Loading branch information...
1 parent 7b6bd70 commit 8c1833b434adfbb57664fc8c521db2823c43bc1b @migueldeicaza migueldeicaza committed Jan 6, 2011
Showing with 116 additions and 14 deletions.
  1. +48 −0 docs/Mono.Terminal/Application.xml
  2. +27 −0 docs/Mono.Terminal/Label.xml
  3. +41 −14 gui.cs
View
48 docs/Mono.Terminal/Application.xml
@@ -144,6 +144,54 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="ColorErrorFocus">
+ <MemberSignature Language="C#" Value="public static int ColorErrorFocus;" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Color used for focused widgets on an error dialog.
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="ColorErrorHot">
+ <MemberSignature Language="C#" Value="public static int ColorErrorHot;" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Color used for hotkeys in error dialogs
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="ColorErrorHotFocus">
+ <MemberSignature Language="C#" Value="public static int ColorErrorHotFocus;" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>
+ Color used for hotkeys in a focused widget in an error dialog
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="ColorFocus">
<MemberSignature Language="C#" Value="public static int ColorFocus;" />
<MemberSignature Language="ILAsm" Value=".field public static int32 ColorFocus" />
View
27 docs/Mono.Terminal/Label.xml
@@ -41,6 +41,33 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName=".ctor">
+ <MemberSignature Language="C#" Value="public Label (int x, int y, string s, object[] args);" />
+ <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="args" Type="System.Object[]">
+ <Attributes>
+ <Attribute>
+ <AttributeName>System.ParamArray</AttributeName>
+ </Attribute>
+ </Attributes>
+ </Parameter>
+ </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="args">To be added.</param>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Color">
<MemberSignature Language="C#" Value="public int Color;" />
<MemberSignature Language="ILAsm" Value=".field public int32 Color" />
View
55 gui.cs
@@ -524,6 +524,11 @@ public Label (int x, int y, string s) : base (x, y, s.Length, 1)
{
text = s;
}
+
+ public Label (int x, int y, string s, params object [] args) : base (x, y, String.Format (s, args).Length, 1)
+ {
+ text = String.Format (s, args);
+ }
public override void Redraw ()
{
@@ -993,7 +998,7 @@ public class Button : Widget {
}
}
}
-
+
/// <summary>
/// Public constructor, creates a button based on
/// the given text at the given position.
@@ -1030,18 +1035,22 @@ public override void PositionCursor ()
Move (y, x + hot_pos);
}
+ bool CheckKey (int key)
+ {
+ if (Char.ToUpper ((char)key) == hot_key){
+ Container.SetFocus (this);
+ if (Clicked != null)
+ Clicked (this, EventArgs.Empty);
+ return true;
+ }
+ return false;
+ }
+
public override bool ProcessHotKey (int key)
{
int k = Curses.IsAlt (key);
- if (k != 0){
- if (Char.ToUpper ((char)k) == hot_key){
- Container.SetFocus (this);
- if (Clicked != null)
- Clicked (this, EventArgs.Empty);
- return true;
- }
- return false;
- }
+ if (k != 0)
+ return CheckKey (k);
return false;
}
@@ -1053,8 +1062,7 @@ public override bool ProcessColdKey (int key)
Clicked (this, EventArgs.Empty);
return true;
}
-
- return false;
+ return CheckKey (key);
}
public override bool ProcessKey (int c)
@@ -1973,8 +1981,9 @@ public Dialog (int w, int h, string title)
public void ErrorColors ()
{
ContainerColorNormal = Application.ColorError;
- ContainerColorFocus = Application.ColorError;
- ContainerColorHotFocus = Application.ColorError;
+ ContainerColorFocus = Application.ColorErrorFocus;
+ ContainerColorHotFocus = Application.ColorErrorHotFocus;
+ ContainerColorHotNormal = Application.ColorErrorHot;
}
public override void Prepare ()
@@ -2376,6 +2385,21 @@ public class Application {
public static int ColorError;
/// <summary>
+ /// Color used for focused widgets on an error dialog.
+ /// </summary>
+ public static int ColorErrorFocus;
+
+ /// <summary>
+ /// Color used for hotkeys in error dialogs
+ /// </summary>
+ public static int ColorErrorHot;
+
+ /// <summary>
+ /// Color used for hotkeys in a focused widget in an error dialog
+ /// </summary>
+ public static int ColorErrorHotFocus;
+
+ /// <summary>
/// The basic color of the terminal.
/// </summary>
public static int ColorBasic;
@@ -2507,6 +2531,9 @@ public static void Init (bool disable_color)
ColorDialogHotFocus = MakeColor (Curses.COLOR_BLUE, Curses.COLOR_CYAN);
ColorError = Curses.A_BOLD | MakeColor (Curses.COLOR_WHITE, Curses.COLOR_RED);
+ ColorErrorFocus = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_WHITE);
+ ColorErrorHot = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_RED);
+ ColorErrorHotFocus = ColorErrorHot;
} else {
ColorNormal = Curses.A_NORMAL;
ColorFocus = Curses.A_REVERSE;

0 comments on commit 8c1833b

Please sign in to comment.