Ejemplo n.º 1
0
    static Control ComputedQuestionWidget(Racr.AstNode n)
    {
        Widget w;

        if (n.Type() == ValueTypes.Boolean)
        {
            w = new CheckWidget(n.GetLabel(), false);
        }
        else
        {
            w = new TextWidget(n.GetLabel(), false);
        }
        n.Parent().Widget().Controls.Add(w);
        return(w);
    }
Ejemplo n.º 2
0
    [AgRule("Widget", "OrdinaryQuestion")] static Control OrdinaryQuestionWidget(Ast n)
    {
        QDialog dialog = n.Dialog();

        ((Control)dialog).Enabled = true;
        EventHandler h = (object o, EventArgs a) => {
            if (!((Control)o).ContainsFocus)
            {
                return;                                          // TODO: For which reason is this check needed?
            }
            n.SetValue(dialog.GetValue());
            n.Root().Render();
        };

        dialog.AddEventHandler(h);

        var contentBox = new FlowLayoutPanel();

        contentBox.AutoSize      = true;
        contentBox.WrapContents  = false;
        contentBox.FlowDirection = FlowDirection.LeftToRight;
        var label = new Label();

        label.Text     = n.GetLabel();
        label.AutoSize = true;
        label.Anchor   = AnchorStyles.Left;
        contentBox.Controls.Add(label);
        contentBox.Controls.Add((Control)dialog);

        n.Parent().Widget().Controls.Add(contentBox);
        return(contentBox);
    }
Ejemplo n.º 3
0
    static Control OrdinaryQuestionWidget(Racr.AstNode n)
    {
        Widget w;

        if (n.Type() == ValueTypes.Boolean)
        {
            w = new CheckWidget(n.GetLabel());
            var cb = w.GetCheckBox();
            cb.CheckedChanged += (object sender, EventArgs e) => {
                if (!cb.ContainsFocus)
                {
                    return;
                }
                n.SetValue(cb.Checked);
                n.Root().Render();
            };
        }
        else
        {
            w = new TextWidget(n.GetLabel());
            var tb = w.GetTextBox();
            tb.TextChanged += (object sender, EventArgs e) => {
                if (!tb.ContainsFocus)
                {
                    return;
                }
                if (n.Type() == ValueTypes.Number)
                {
                    try { n.SetValue(Convert.ToDouble(tb.Text)); }
                    catch { return; }
                }
                else
                {
                    n.SetValue(tb.Text);
                }
                n.Root().Render();
            };
        }
        n.Parent().Widget().Controls.Add(w);
        return(w);
    }
Ejemplo n.º 4
0
    [AgRule("Widget", "ComputedQuestion")] static Box ComputedQuestionWidget(Ast n)
    {
        Widget dialog = (Widget)n.Dialog();

        dialog.Sensitive = false;
        HBox box = new HBox(false, 5);

        if (!n.IsLValid())
        {
            Image warning = new Image(Stock.DialogWarning, IconSize.Button);
            box.PackStart(warning, false, false, 3);
        }
        box.PackStart(new Label(n.GetLabel()), false, false, 5);
        box.PackStart(dialog, true, true, 5);
        n.Parent().Widget().PackStart(box, false, false, 5);
        box.ShowAll();
        return(box);
    }
Ejemplo n.º 5
0
    [AgRule("Widget", "ComputedQuestion")] static Control ComputedQuestionWidget(Ast n)
    {
        Control dialog = (Control)n.Dialog();

        dialog.Enabled = false;

        var contentBox = new FlowLayoutPanel();

        contentBox.AutoSize      = true;
        contentBox.WrapContents  = false;
        contentBox.FlowDirection = FlowDirection.LeftToRight;
        var label = new Label();

        label.Text     = n.GetLabel();
        label.AutoSize = true;
        label.Anchor   = AnchorStyles.Left;
        contentBox.Controls.Add(label);
        contentBox.Controls.Add(dialog);

        n.Parent().Widget().Controls.Add(contentBox);
        return(contentBox);
    }
Ejemplo n.º 6
0
    [AgRule("Widget", "OrdinaryQuestion")] static Box OrdinaryQuestionWidget(Ast n)
    {
        QDialog      dialog = n.Dialog();
        EventHandler h      = (object o, EventArgs a) => {
            n.SetValue(dialog.GetValue());
            n.Root().Render();
        };

        dialog.AddEventHandler(h);
        HBox box = new HBox(false, 5);

        if (!n.IsLValid())
        {
            Image warning = new Image(Stock.DialogWarning, IconSize.Button);
            box.PackStart(warning, false, false, 3);
        }
        box.PackStart(new Label(n.GetLabel()), false, false, 5);
        box.PackStart((Widget)dialog, true, true, 5);
        n.Parent().Widget().PackStart(box, false, false, 5);
        box.ShowAll();
        return(box);
    }
Ejemplo n.º 7
0
 [AgRule("SExpr", "ComputedQuestion")] static string ComputedQuestionSExpr(Ast n)
 {
     return("(~? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) +
            " " + n.GetExpression().SExpr() + ")");
 }
Ejemplo n.º 8
0
 [AgRule("SExpr", "OrdinaryQuestion")] static string OrdinaryQuestionSExpr(Ast n)
 {
     return("(?? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) + " " + n.Type() + " " +
            (n.GetValue() == ErrorValue ? "" : Lexer.EscapeValue(n.GetValue())) + ")");
 }
Ejemplo n.º 9
0
 static string ComputedQuestionSExpr(Racr.AstNode n)
 {
     return("(~? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) + " " + n.GetExpression().SExpr() + ")");
 }
Ejemplo n.º 10
0
 static string OrdinaryQuestionSExpr(Racr.AstNode n)
 {
     return("(?? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) + " " + n.Type() + " " + Lexer.EscapeValue(n.Value()) + ")");
 }