[AgRule("Widget", "Group")] static Box GroupWidget(Ast n) { VBox contentBox = new VBox(false, 5); Frame frame = new Frame(n.GetExpression().SExpr()); frame.BorderWidth = 5; frame.Add(contentBox); if (!n.IsLValid()) { Gdk.Color col = new Gdk.Color(); Gdk.Color.Parse("red", ref col); frame.ModifyBg(StateType.Normal, col); } n.Parent().Widget().PackStart(frame, false, false, 5); frame.Show(); return(contentBox); }
[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); }
[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); }
[AgRule("IsValid", "Question")] static bool QuestionIsValid(Ast n) { return(n.IsLValid()); }
[AgRule("IsValid", "Group")] static bool GroupIsValid(Ast n) { return(n.IsLValid() && n.GetBody().Children().All(x => ((Ast)x).IsValid())); }
static bool QuestionIsValid(Racr.AstNode n) { return(n.IsLValid()); }
static bool GroupIsValid(Racr.AstNode n) { return(n.IsLValid() && n.GetBody().Children().All(x => ((Racr.AstNode)x).IsValid())); }