Skip to content
Browse files

Styling UI

Buttons now use Arial Rounded MT Bold font, have custom background
colors.  Updating screenshots.  Fixing indentation in Symbol.Inspect.
Would prefer to do button styling in stetic file instead of
programmatically, haven't figured out how yet.  Shrinking window so
edge buttons aren't so huge.
  • Loading branch information...
1 parent 6803c99 commit bc6afe530adad7b7b0ed723e3ebe0390d416c9db @cheshire137 committed
View
2 .gitignore
@@ -12,3 +12,5 @@ obj
UpgradeLog.XML
_ReSharper.*
_UpgradeReport_Files
+
+.DS_Store
View
22 Calculator/NoSpaceExpression.cs
@@ -86,18 +86,16 @@ public static NoSpaceExpression Produce(IEnumerable<Symbol> symbols)
return new NoSpaceExpression(e1, io, e2);
}
}
-
- if (symbols.First() is OpenParenthesis &&
- symbols.Last() is ClosedParenthesis)
- {
- Expression e = Expression.Produce(symbols.Skip(1).SkipLast(1));
- if (e != null)
- {
- return new NoSpaceExpression(new OpenParenthesis(), e,
- new ClosedParenthesis());
- }
- }
-
+ if (symbols.First() is OpenParenthesis &&
+ symbols.Last() is ClosedParenthesis)
+ {
+ Expression e = Expression.Produce(symbols.Skip(1).SkipLast(1));
+ if (e != null)
+ {
+ return new NoSpaceExpression(new OpenParenthesis(), e,
+ new ClosedParenthesis());
+ }
+ }
NumericalConstant n = NumericalConstant.Produce(symbols);
if (n != null)
{
View
143 Calculator/SimpleFormulaParser.cs
@@ -5,84 +5,71 @@
namespace Calculator
{
- public class SimpleFormulaParser
- {
- private static Symbol char2Symbol(char c)
- {
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return new DecimalDigit(c);
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- return new WhiteSpace();
- case '+':
- return new Plus();
- case '-':
- return new Minus();
- case '*':
- return new Asterisk();
- case '/':
- return new ForwardSlash();
- case '^':
- return new Caret();
- case '.':
- return new Period();
- case '(':
- return new OpenParenthesis();
- case ')':
- return new ClosedParenthesis();
- default:
- return (Symbol)null;
- }
- }
-
- public static Formula ParseFormula(string s)
- {
- IEnumerable<Symbol> symbols = s.Select(char2Symbol);
- if (symbols.Any()) {
- Console.WriteLine("Terminal Symbols");
- Console.WriteLine("================");
- foreach (Symbol terminal in symbols)
- {
- Console.WriteLine("{0} >{1}<", terminal.GetType().Name.ToString(),
+ public class SimpleFormulaParser
+ {
+ public static Formula ParseFormula(string s)
+ {
+ IEnumerable<Symbol> symbols = s.Select(charToSymbol);
+ /*if (symbols.Any())
+ {
+ Console.WriteLine("Terminal Symbols");
+ Console.WriteLine("================");
+ foreach (Symbol terminal in symbols)
+ {
+ Console.WriteLine("{0} >{1}<",
+ terminal.GetType().Name.ToString(),
terminal.ToString());
- }
- Console.WriteLine();
- }
- Formula formula = Formula.Produce(symbols);
- if (formula == null)
- {
- throw new ParserException("Invalid formula");
- }
- return formula;
- }
-
- public static void DumpSymbolRecursive(StringBuilder sb, Symbol symbol,
- int depth)
- {
- sb.Append(string.Format("{0}{1} >{2}<",
- "".PadRight(depth * 2),
- symbol.GetType().Name.ToString(),
- symbol.ToString())).Append(Environment.NewLine);
- if (symbol.ConstituentSymbols != null)
- {
- foreach (var childSymbol in symbol.ConstituentSymbols)
- {
- DumpSymbolRecursive(sb, childSymbol, depth + 1);
- }
- }
- }
- }
+ }
+ Console.WriteLine();
+ }*/
+ Formula formula = Formula.Produce(symbols);
+ if (null == formula)
+ {
+ throw new ParserException("Invalid formula");
+ }
+ return formula;
+ }
+
+ private static Symbol charToSymbol(char c)
+ {
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ return new DecimalDigit(c);
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ return new WhiteSpace();
+ case '+':
+ return new Plus();
+ case '-':
+ return new Minus();
+ case '*':
+ return new Asterisk();
+ case '/':
+ return new ForwardSlash();
+ case '^':
+ return new Caret();
+ case '.':
+ return new Period();
+ case '(':
+ return new OpenParenthesis();
+ case ')':
+ return new ClosedParenthesis();
+ default:
+ return (Symbol)null;
+ }
+ }
+ }
}
View
25 Calculator/Symbol.cs
@@ -45,15 +45,9 @@ public Symbol(params Object[] symbols) : this()
public String Inspect()
{
- var sb = new StringBuilder();
- sb.AppendLine(GetType().ToString());
- foreach (Symbol sym in ConstituentSymbols)
- {
- sb.Append(sym.GetType().ToString())
- .Append(" - ")
- .AppendLine(sym.Inspect());
- }
- return sb.ToString();
+ var sb = new StringBuilder();
+ inspectRecursive(sb, this, 0);
+ return sb.ToString();
}
public override string ToString()
@@ -61,6 +55,19 @@ public override string ToString()
return ConstituentSymbols.Select(ct => ct.ToString())
.StringConcatenate();
}
+
+ private static void inspectRecursive(StringBuilder sb, Symbol symbol,
+ int depth)
+ {
+ sb.AppendLine(string.Format("{0}{1}: {2}",
+ "".PadRight(depth * 2),
+ symbol.GetType().Name,
+ symbol.ToString()));
+ foreach (var childSymbol in symbol.ConstituentSymbols)
+ {
+ inspectRecursive(sb, childSymbol, depth + 1);
+ }
+ }
}
}
View
3 Main/Main.csproj
@@ -38,6 +38,9 @@
<Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <Reference Include="libstetic">
+ <HintPath>..\..\..\..\..\Applications\MonoDevelop.app\Contents\MacOS\lib\monodevelop\AddIns\MonoDevelop.GtkCore\libstetic.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
View
424 Main/MainWindow.cs
@@ -4,90 +4,111 @@
public partial class MainWindow : Gtk.Window
{
- private const string ERROR_MESSAGE = "ERROR";
+ private static readonly Gdk.Color _numberButtonBg =
+ new Gdk.Color(242, 204, 133);
+ private static readonly Gdk.Color _numberButtonHoverBg =
+ new Gdk.Color(253, 221, 160);
+ private static readonly Gdk.Color _opButtonBg =
+ new Gdk.Color(166, 123, 123);
+ private static readonly Gdk.Color _opButtonHoverBg =
+ new Gdk.Color(181, 146, 146);
+ private static readonly Gdk.Color _miscButtonBg =
+ new Gdk.Color(191, 160, 142);
+ private static readonly Gdk.Color _miscButtonHoverBg =
+ new Gdk.Color(206, 180, 165);
+ private static readonly Gdk.Color _solveButtonBg =
+ new Gdk.Color(170, 242, 133);
+ private static readonly Gdk.Color _solveButtonHoverBg =
+ new Gdk.Color(188, 255, 153);
+ private static readonly Gdk.Color _undoButtonBg =
+ new Gdk.Color(242, 133, 133);
+ private static readonly Gdk.Color _undoButtonHoverBg =
+ new Gdk.Color(255, 155, 155);
+ private static Pango.FontDescription _buttonFont = null;
+ private const string ERROR_MESSAGE = "ERROR";
private const string FONT_DESCRIPTION = "American Typewriter Regular 26";
private Pango.Layout _equationLayout = null;
private string _equationText = "0";
-
- public MainWindow() : base (Gtk.WindowType.Toplevel)
- {
- Build();
- }
-
- protected void OnDeleteEvent(object sender, DeleteEventArgs a)
- {
- Application.Quit();
- a.RetVal = true;
- }
-
- protected void OnButton7Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(7);
- }
-
- protected void OnButton8Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(8);
- }
-
- protected void OnButton9Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(9);
- }
-
- protected void OnButtonDivideClicked(object sender, System.EventArgs e)
- {
- operatorButtonClicked(new ForwardSlash());
- }
-
- protected void OnButton4Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(4);
- }
-
- protected void OnButton5Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(5);
- }
-
- protected void OnButton6Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(6);
- }
-
- protected void OnButtonMultiplyClicked(object sender, System.EventArgs e)
- {
- operatorButtonClicked(new Asterisk());
- }
-
- protected void OnButton1Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(1);
- }
-
- protected void OnButton2Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(2);
- }
-
- protected void OnButton3Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(3);
- }
-
- protected void OnButtonSubtractClicked(object sender, System.EventArgs e)
- {
- operatorButtonClicked(new Minus());
- }
-
- protected void OnButton0Clicked(object sender, System.EventArgs e)
- {
- numberButtonClicked(0);
- }
-
- protected void OnButtonDotClicked(object sender, System.EventArgs e)
- {
- if (ERROR_MESSAGE.Equals(_equationText))
+
+ public MainWindow() : base (Gtk.WindowType.Toplevel)
+ {
+ Build();
+ }
+
+ protected void OnDeleteEvent(object sender, DeleteEventArgs a)
+ {
+ Application.Quit();
+ a.RetVal = true;
+ }
+
+ protected void OnButton7Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(7);
+ }
+
+ protected void OnButton8Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(8);
+ }
+
+ protected void OnButton9Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(9);
+ }
+
+ protected void OnButtonDivideClicked(object sender, System.EventArgs e)
+ {
+ operatorButtonClicked(new ForwardSlash());
+ }
+
+ protected void OnButton4Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(4);
+ }
+
+ protected void OnButton5Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(5);
+ }
+
+ protected void OnButton6Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(6);
+ }
+
+ protected void OnButtonMultiplyClicked(object sender, System.EventArgs e)
+ {
+ operatorButtonClicked(new Asterisk());
+ }
+
+ protected void OnButton1Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(1);
+ }
+
+ protected void OnButton2Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(2);
+ }
+
+ protected void OnButton3Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(3);
+ }
+
+ protected void OnButtonSubtractClicked(object sender, System.EventArgs e)
+ {
+ minusButtonClicked();
+ }
+
+ protected void OnButton0Clicked(object sender, System.EventArgs e)
+ {
+ numberButtonClicked(0);
+ }
+
+ protected void OnButtonDotClicked(object sender, System.EventArgs e)
+ {
+ if (ERROR_MESSAGE.Equals(_equationText))
{
changeEquationText("0.");
return;
@@ -97,12 +118,12 @@ protected void OnButtonDotClicked(object sender, System.EventArgs e)
{
changeEquationText(_equationText + ".");
}
- }
+ }
- protected void OnButtonAddClicked(object sender, System.EventArgs e)
- {
- operatorButtonClicked(new Plus());
- }
+ protected void OnButtonAddClicked(object sender, System.EventArgs e)
+ {
+ operatorButtonClicked(new Plus());
+ }
private void solveEquation()
{
@@ -113,57 +134,66 @@ private void solveEquation()
);
Console.WriteLine(formula.Inspect());
changeEquationText("" + formula.Solve());
- }
- catch (ParserException ex)
+ } catch (ParserException ex)
{
changeEquationText(ERROR_MESSAGE);
Console.WriteLine(ex.Message);
- }
- catch (DivideByZeroException)
+ } catch (DivideByZeroException)
{
changeEquationText(ERROR_MESSAGE);
}
}
- protected void OnButtonEqualsClicked(object sender, System.EventArgs e)
- {
+ protected void OnButtonEqualsClicked(object sender, System.EventArgs e)
+ {
solveEquation();
- }
+ }
private void clearEquationText()
{
changeEquationText("0");
}
- protected void OnButtonClearClicked(object sender, System.EventArgs e)
- {
+ protected void OnButtonClearClicked(object sender, System.EventArgs e)
+ {
clearEquationText();
- }
-
- private void operatorButtonClicked(Symbol op)
- {
- if (ERROR_MESSAGE.Equals(_equationText))
- {
+ }
+
+ private void minusButtonClicked()
+ {
+ if ("0".Equals(_equationText))
+ {
+ changeEquationText(new Minus().ToString());
+ return;
+ }
+ operatorButtonClicked(new Minus());
+ }
+
+ private void operatorButtonClicked(Symbol op)
+ {
+ if (ERROR_MESSAGE.Equals(_equationText))
+ {
changeEquationText("0" + op.ToString());
- return;
- }
- var eq = new Equation(_equationText);
- if (eq.HasFinalOperator()) {
+ return;
+ }
+ var eq = new Equation(_equationText);
+ if (eq.HasFinalOperator())
+ {
changeEquationText(eq.ReplaceFinalOperator(op));
- }
- else
- {
+ } else
+ {
changeEquationText(_equationText + op.ToString());
- }
- }
-
- private void numberButtonClicked(int number)
- {
- if ("0".Equals(_equationText) ||
- ERROR_MESSAGE.Equals(_equationText)) {
+ }
+ }
+
+ private void numberButtonClicked(int number)
+ {
+ if ("0".Equals(_equationText) ||
+ ERROR_MESSAGE.Equals(_equationText))
+ {
changeEquationText("" + number);
- return;
- }
+ return;
+ }
char lastChar = _equationText[_equationText.Length - 1];
if (new ClosedParenthesis().ToString().Equals(lastChar.ToString()))
{
@@ -171,7 +201,7 @@ private void numberButtonClicked(int number)
return;
}
changeEquationText(_equationText + number);
- }
+ }
protected void OnEquationAreaExposeEvent(object o, Gtk.ExposeEventArgs args)
{
@@ -221,7 +251,7 @@ protected void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args)
operatorButtonClicked(new Plus());
break;
case Gdk.Key.minus:
- operatorButtonClicked(new Minus());
+ minusButtonClicked();
break;
case Gdk.Key.slash:
operatorButtonClicked(new ForwardSlash());
@@ -230,6 +260,7 @@ protected void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args)
operatorButtonClicked(new Asterisk());
break;
case Gdk.Key.caret:
+ case Gdk.Key.ccircumflex:
operatorButtonClicked(new Caret());
break;
case Gdk.Key.Key_0:
@@ -262,6 +293,7 @@ protected void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args)
case Gdk.Key.Key_9:
numberButtonClicked(9);
break;
+ case Gdk.Key.equal:
case Gdk.Key.ISO_Enter:
case Gdk.Key.Key_3270_Enter:
case Gdk.Key.KP_Enter:
@@ -279,6 +311,9 @@ protected void OnKeyReleaseEvent(object o, Gtk.KeyReleaseEventArgs args)
case Gdk.Key.parenright:
closeParenthesis();
break;
+ case Gdk.Key.period:
+ operatorButtonClicked(new Period());
+ break;
}
}
@@ -330,4 +365,155 @@ protected void OnButtonClosedParenthesisClicked(object sender, System.EventArgs
{
closeParenthesis();
}
+
+ private static Pango.FontDescription getButtonFont()
+ {
+ if (null == _buttonFont)
+ {
+ _buttonFont = new Pango.FontDescription();
+ _buttonFont.Family = "Arial Rounded MT Bold";
+ _buttonFont.AbsoluteSize = 16 * Pango.Scale.PangoScale;
+ }
+ return _buttonFont;
+ }
+
+ private static void styleNumberButton(Gtk.Button button)
+ {
+ button.ModifyBg(StateType.Normal, _numberButtonBg);
+ button.ModifyBg(StateType.Prelight, _numberButtonHoverBg);
+ button.Child.ModifyFont(getButtonFont());
+ }
+
+ protected void OnButton7ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button7);
+ }
+
+ protected void OnButton8ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button8);
+ }
+
+ protected void OnButton9ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button9);
+ }
+
+ protected void OnButton4ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button4);
+ }
+
+ protected void OnButton5ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button5);
+ }
+
+ protected void OnButton6ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button6);
+ }
+
+ protected void OnButton1ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button1);
+ }
+
+ protected void OnButton2ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button2);
+ }
+
+ protected void OnButton3ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button3);
+ }
+
+ protected void OnButton0ExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleNumberButton(button0);
+ }
+
+ private static void styleOperatorButton(Gtk.Button button)
+ {
+ button.ModifyBg(StateType.Normal, _opButtonBg);
+ button.ModifyBg(StateType.Prelight, _opButtonHoverBg);
+ button.Child.ModifyFont(getButtonFont());
+ }
+
+ protected void OnButtonDivideExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleOperatorButton(buttonDivide);
+ }
+
+ protected void OnButtonMultiplyExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleOperatorButton(buttonMultiply);
+ }
+
+ protected void OnButtonSubtractExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleOperatorButton(buttonSubtract);
+ }
+
+ protected void OnButtonAddExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleOperatorButton(buttonAdd);
+ }
+
+ protected void OnButtonExponentExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleOperatorButton(buttonExponent);
+ }
+
+ private static void styleMiscButton(Gtk.Button button)
+ {
+ button.ModifyBg(StateType.Normal, _miscButtonBg);
+ button.ModifyBg(StateType.Prelight, _miscButtonHoverBg);
+ button.Child.ModifyFont(getButtonFont());
+ }
+
+ protected void OnButtonOpenParenthesisExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleMiscButton(buttonOpenParenthesis);
+ }
+
+ protected void OnButtonClosedParenthesisExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleMiscButton(buttonClosedParenthesis);
+ }
+
+ protected void OnButtonDotExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleMiscButton(buttonDot);
+ }
+
+ private static void styleSolveButton(Gtk.Button button)
+ {
+ button.ModifyBg(StateType.Normal, _solveButtonBg);
+ button.ModifyBg(StateType.Prelight, _solveButtonHoverBg);
+ button.Child.ModifyFont(getButtonFont());
+ }
+
+ protected void OnButtonEqualsExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleSolveButton(buttonEquals);
+ }
+
+ private static void styleUndoButton(Gtk.Button button)
+ {
+ button.ModifyBg(StateType.Normal, _undoButtonBg);
+ button.ModifyBg(StateType.Prelight, _undoButtonHoverBg);
+ button.Child.ModifyFont(getButtonFont());
+ }
+
+ protected void OnButtonClearExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleUndoButton(buttonClear);
+ }
+
+ protected void OnButtonBackspaceExposeEvent(object o, Gtk.ExposeEventArgs args)
+ {
+ styleUndoButton(buttonBackspace);
+ }
}
View
50 Main/gtk-gui/MainWindow.cs
@@ -5,8 +5,8 @@ public partial class MainWindow
{
private global::Gtk.VBox equationVbox;
private global::Gtk.HBox equationClearHbox;
- private global::Gtk.Button buttonBackspace;
private global::Gtk.DrawingArea equationArea;
+ private global::Gtk.Button buttonBackspace;
private global::Gtk.VBox vbox2;
private global::Gtk.HBox hbox1;
private global::Gtk.VBox vbox6;
@@ -43,6 +43,8 @@ protected virtual void Build ()
this.Name = "MainWindow";
this.Title = global::Mono.Unix.Catalog.GetString ("Snazzy Calculator");
this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+ this.Resizable = false;
+ this.AllowGrow = false;
this.DefaultWidth = 500;
this.DefaultHeight = 480;
// Container child MainWindow.Gtk.Container+ContainerChild
@@ -54,6 +56,12 @@ protected virtual void Build ()
this.equationClearHbox.Name = "equationClearHbox";
this.equationClearHbox.Spacing = 6;
// Container child equationClearHbox.Gtk.Box+BoxChild
+ this.equationArea = new global::Gtk.DrawingArea ();
+ this.equationArea.Name = "equationArea";
+ this.equationClearHbox.Add (this.equationArea);
+ global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.equationClearHbox [this.equationArea]));
+ w1.Position = 0;
+ // Container child equationClearHbox.Gtk.Box+BoxChild
this.buttonBackspace = new global::Gtk.Button ();
this.buttonBackspace.HeightRequest = 75;
this.buttonBackspace.CanFocus = true;
@@ -62,16 +70,10 @@ protected virtual void Build ()
this.buttonBackspace.UseUnderline = true;
this.buttonBackspace.Label = "gtk-undo";
this.equationClearHbox.Add (this.buttonBackspace);
- global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.equationClearHbox [this.buttonBackspace]));
- w1.Position = 0;
- w1.Expand = false;
- w1.Fill = false;
- // Container child equationClearHbox.Gtk.Box+BoxChild
- this.equationArea = new global::Gtk.DrawingArea ();
- this.equationArea.Name = "equationArea";
- this.equationClearHbox.Add (this.equationArea);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.equationClearHbox [this.equationArea]));
+ global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.equationClearHbox [this.buttonBackspace]));
w2.Position = 1;
+ w2.Expand = false;
+ w2.Fill = false;
this.equationVbox.Add (this.equationClearHbox);
global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.equationVbox [this.equationClearHbox]));
w3.Position = 0;
@@ -275,6 +277,7 @@ protected virtual void Build ()
this.vbox7.Spacing = 6;
// Container child vbox7.Gtk.Box+BoxChild
this.buttonDivide = new global::Gtk.Button ();
+ this.buttonDivide.WidthRequest = 90;
this.buttonDivide.HeightRequest = 59;
this.buttonDivide.CanFocus = true;
this.buttonDivide.Name = "buttonDivide";
@@ -352,6 +355,7 @@ protected virtual void Build ()
// Container child hbox2.Gtk.Box+BoxChild
this.buttonOpenParenthesis = new global::Gtk.Button ();
this.buttonOpenParenthesis.WidthRequest = 90;
+ this.buttonOpenParenthesis.HeightRequest = 75;
this.buttonOpenParenthesis.CanFocus = true;
this.buttonOpenParenthesis.Name = "buttonOpenParenthesis";
this.buttonOpenParenthesis.UseUnderline = true;
@@ -375,6 +379,7 @@ protected virtual void Build ()
w27.Fill = false;
// Container child hbox2.Gtk.Box+BoxChild
this.buttonEquals = new global::Gtk.Button ();
+ this.buttonEquals.CanDefault = true;
this.buttonEquals.CanFocus = true;
this.buttonEquals.Name = "buttonEquals";
this.buttonEquals.UseUnderline = true;
@@ -395,29 +400,52 @@ protected virtual void Build ()
if ((this.Child != null)) {
this.Child.ShowAll ();
}
+ this.buttonEquals.HasDefault = true;
this.Show ();
this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
this.KeyReleaseEvent += new global::Gtk.KeyReleaseEventHandler (this.OnKeyReleaseEvent);
- this.buttonBackspace.Clicked += new global::System.EventHandler (this.OnButtonBackspaceClicked);
this.equationArea.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnEquationAreaExposeEvent);
+ this.buttonBackspace.Clicked += new global::System.EventHandler (this.OnButtonBackspaceClicked);
+ this.buttonBackspace.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonBackspaceExposeEvent);
this.button7.Clicked += new global::System.EventHandler (this.OnButton7Clicked);
+ this.button7.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton7ExposeEvent);
this.button4.Clicked += new global::System.EventHandler (this.OnButton4Clicked);
+ this.button4.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton4ExposeEvent);
this.button1.Clicked += new global::System.EventHandler (this.OnButton1Clicked);
+ this.button1.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton1ExposeEvent);
this.button0.Clicked += new global::System.EventHandler (this.OnButton0Clicked);
+ this.button0.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton0ExposeEvent);
this.button8.Clicked += new global::System.EventHandler (this.OnButton8Clicked);
+ this.button8.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton8ExposeEvent);
this.button5.Clicked += new global::System.EventHandler (this.OnButton5Clicked);
+ this.button5.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton5ExposeEvent);
this.button2.Clicked += new global::System.EventHandler (this.OnButton2Clicked);
+ this.button2.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton2ExposeEvent);
this.buttonDot.Clicked += new global::System.EventHandler (this.OnButtonDotClicked);
+ this.buttonDot.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonDotExposeEvent);
this.button9.Clicked += new global::System.EventHandler (this.OnButton9Clicked);
+ this.button9.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton9ExposeEvent);
this.button6.Clicked += new global::System.EventHandler (this.OnButton6Clicked);
+ this.button6.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton6ExposeEvent);
this.button3.Clicked += new global::System.EventHandler (this.OnButton3Clicked);
+ this.button3.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButton3ExposeEvent);
this.buttonClear.Clicked += new global::System.EventHandler (this.OnButtonClearClicked);
+ this.buttonClear.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonClearExposeEvent);
this.buttonDivide.Clicked += new global::System.EventHandler (this.OnButtonDivideClicked);
+ this.buttonDivide.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonDivideExposeEvent);
this.buttonMultiply.Clicked += new global::System.EventHandler (this.OnButtonMultiplyClicked);
+ this.buttonMultiply.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonMultiplyExposeEvent);
this.buttonSubtract.Clicked += new global::System.EventHandler (this.OnButtonSubtractClicked);
+ this.buttonSubtract.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonSubtractExposeEvent);
this.buttonAdd.Clicked += new global::System.EventHandler (this.OnButtonAddClicked);
+ this.buttonAdd.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonAddExposeEvent);
+ this.buttonExponent.Clicked += new global::System.EventHandler (this.OnButtonExponentClicked);
+ this.buttonExponent.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonExponentExposeEvent);
this.buttonOpenParenthesis.Clicked += new global::System.EventHandler (this.OnButtonOpenParenthesisClicked);
+ this.buttonOpenParenthesis.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonOpenParenthesisExposeEvent);
this.buttonClosedParenthesis.Clicked += new global::System.EventHandler (this.OnButtonClosedParenthesisClicked);
+ this.buttonClosedParenthesis.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonClosedParenthesisExposeEvent);
this.buttonEquals.Clicked += new global::System.EventHandler (this.OnButtonEqualsClicked);
+ this.buttonEquals.ExposeEvent += new global::Gtk.ExposeEventHandler (this.OnButtonEqualsExposeEvent);
}
}
View
53 Main/gtk-gui/gui.stetic
@@ -7,11 +7,14 @@
<import>
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<widget-library name="../bin/Debug/Main.exe" internal="true" />
+ <widget-library name="../../../../../../Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.GtkCore/libstetic.dll" />
</import>
- <widget class="Gtk.Window" id="MainWindow" design-size="406 534">
+ <widget class="Gtk.Window" id="MainWindow" design-size="460 534">
<property name="MemberName" />
<property name="Title" translatable="yes">Snazzy Calculator</property>
<property name="WindowPosition">CenterOnParent</property>
+ <property name="Resizable">False</property>
+ <property name="AllowGrow">False</property>
<property name="DefaultWidth">500</property>
<property name="DefaultHeight">480</property>
<signal name="DeleteEvent" handler="OnDeleteEvent" />
@@ -25,6 +28,16 @@
<property name="MemberName" />
<property name="Spacing">6</property>
<child>
+ <widget class="Gtk.DrawingArea" id="equationArea">
+ <property name="MemberName" />
+ <signal name="ExposeEvent" handler="OnEquationAreaExposeEvent" />
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">True</property>
+ </packing>
+ </child>
+ <child>
<widget class="Gtk.Button" id="buttonBackspace">
<property name="MemberName" />
<property name="HeightRequest">75</property>
@@ -33,25 +46,16 @@
<property name="Type">StockItem</property>
<property name="StockId">gtk-undo</property>
<signal name="Clicked" handler="OnButtonBackspaceClicked" />
+ <signal name="ExposeEvent" handler="OnButtonBackspaceExposeEvent" />
<property name="label">gtk-undo</property>
</widget>
<packing>
- <property name="Position">0</property>
+ <property name="Position">1</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
- <child>
- <widget class="Gtk.DrawingArea" id="equationArea">
- <property name="MemberName" />
- <signal name="ExposeEvent" handler="OnEquationAreaExposeEvent" />
- </widget>
- <packing>
- <property name="Position">1</property>
- <property name="AutoSize">True</property>
- </packing>
- </child>
</widget>
<packing>
<property name="Position">0</property>
@@ -81,6 +85,7 @@
<property name="Label" translatable="yes">7</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton7Clicked" />
+ <signal name="ExposeEvent" handler="OnButton7ExposeEvent" />
</widget>
<packing>
<property name="Position">0</property>
@@ -99,6 +104,7 @@
<property name="Label" translatable="yes">4</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton4Clicked" />
+ <signal name="ExposeEvent" handler="OnButton4ExposeEvent" />
</widget>
<packing>
<property name="Position">1</property>
@@ -117,6 +123,7 @@
<property name="Label" translatable="yes">1</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton1Clicked" />
+ <signal name="ExposeEvent" handler="OnButton1ExposeEvent" />
</widget>
<packing>
<property name="Position">2</property>
@@ -135,6 +142,7 @@
<property name="Label" translatable="yes">0</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton0Clicked" />
+ <signal name="ExposeEvent" handler="OnButton0ExposeEvent" />
</widget>
<packing>
<property name="PackType">End</property>
@@ -166,6 +174,7 @@
<property name="Label" translatable="yes">8</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton8Clicked" />
+ <signal name="ExposeEvent" handler="OnButton8ExposeEvent" />
</widget>
<packing>
<property name="Position">0</property>
@@ -184,6 +193,7 @@
<property name="Label" translatable="yes">5</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton5Clicked" />
+ <signal name="ExposeEvent" handler="OnButton5ExposeEvent" />
</widget>
<packing>
<property name="Position">1</property>
@@ -202,6 +212,7 @@
<property name="Label" translatable="yes">2</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton2Clicked" />
+ <signal name="ExposeEvent" handler="OnButton2ExposeEvent" />
</widget>
<packing>
<property name="Position">2</property>
@@ -220,6 +231,7 @@
<property name="Label" translatable="yes">.</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonDotClicked" />
+ <signal name="ExposeEvent" handler="OnButtonDotExposeEvent" />
</widget>
<packing>
<property name="PackType">End</property>
@@ -251,6 +263,7 @@
<property name="Label" translatable="yes">9</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton9Clicked" />
+ <signal name="ExposeEvent" handler="OnButton9ExposeEvent" />
</widget>
<packing>
<property name="Position">0</property>
@@ -269,6 +282,7 @@
<property name="Label" translatable="yes">6</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton6Clicked" />
+ <signal name="ExposeEvent" handler="OnButton6ExposeEvent" />
</widget>
<packing>
<property name="Position">1</property>
@@ -287,6 +301,7 @@
<property name="Label" translatable="yes">3</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButton3Clicked" />
+ <signal name="ExposeEvent" handler="OnButton3ExposeEvent" />
</widget>
<packing>
<property name="Position">2</property>
@@ -304,6 +319,7 @@
<property name="Type">StockItem</property>
<property name="StockId">gtk-clear</property>
<signal name="Clicked" handler="OnButtonClearClicked" />
+ <signal name="ExposeEvent" handler="OnButtonClearExposeEvent" />
<property name="label">gtk-clear</property>
</widget>
<packing>
@@ -329,12 +345,14 @@
<child>
<widget class="Gtk.Button" id="buttonDivide">
<property name="MemberName" />
+ <property name="WidthRequest">90</property>
<property name="HeightRequest">59</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
<property name="Label" translatable="yes">/</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonDivideClicked" />
+ <signal name="ExposeEvent" handler="OnButtonDivideExposeEvent" />
</widget>
<packing>
<property name="Position">0</property>
@@ -352,6 +370,7 @@
<property name="Label" translatable="yes">x</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonMultiplyClicked" />
+ <signal name="ExposeEvent" handler="OnButtonMultiplyExposeEvent" />
</widget>
<packing>
<property name="Position">1</property>
@@ -369,6 +388,7 @@
<property name="Label" translatable="yes">-</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonSubtractClicked" />
+ <signal name="ExposeEvent" handler="OnButtonSubtractExposeEvent" />
</widget>
<packing>
<property name="Position">2</property>
@@ -386,6 +406,7 @@
<property name="Label" translatable="yes">+</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonAddClicked" />
+ <signal name="ExposeEvent" handler="OnButtonAddExposeEvent" />
</widget>
<packing>
<property name="Position">3</property>
@@ -402,6 +423,8 @@
<property name="Type">TextOnly</property>
<property name="Label" translatable="yes">^</property>
<property name="UseUnderline">True</property>
+ <signal name="Clicked" handler="OnButtonExponentClicked" />
+ <signal name="ExposeEvent" handler="OnButtonExponentExposeEvent" />
</widget>
<packing>
<property name="Position">4</property>
@@ -436,11 +459,13 @@
<widget class="Gtk.Button" id="buttonOpenParenthesis">
<property name="MemberName" />
<property name="WidthRequest">90</property>
+ <property name="HeightRequest">75</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
<property name="Label" translatable="yes">(</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonOpenParenthesisClicked" />
+ <signal name="ExposeEvent" handler="OnButtonOpenParenthesisExposeEvent" />
</widget>
<packing>
<property name="Position">0</property>
@@ -458,6 +483,7 @@
<property name="Label" translatable="yes">)</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonClosedParenthesisClicked" />
+ <signal name="ExposeEvent" handler="OnButtonClosedParenthesisExposeEvent" />
</widget>
<packing>
<property name="Position">1</property>
@@ -469,11 +495,14 @@
<child>
<widget class="Gtk.Button" id="buttonEquals">
<property name="MemberName" />
+ <property name="CanDefault">True</property>
+ <property name="HasDefault">True</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
<property name="Label" translatable="yes">=</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnButtonEqualsClicked" />
+ <signal name="ExposeEvent" handler="OnButtonEqualsExposeEvent" />
</widget>
<packing>
<property name="Position">2</property>
View
BIN screenshot1-formula.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN screenshot2-solution.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc6afe5

Please sign in to comment.
Something went wrong with that request. Please try again.