<* PRAGMA LL *> MODULEButton support procs; IMPORT FormsVBT, Split, NodeVBT, Text, VBT, Rd, Wr, RW; REVEAL ButtonNode = NodeVBT.Widget BRANDED "VO-ButtonNode" OBJECT textLabel: BOOLEAN := TRUE; text : TEXT := "Label"; pixmap : TEXT := ""; Guard : BOOLEAN := FALSE; Trill : BOOLEAN := FALSE; OVERRIDES loadAttributes := BuLoadAttributes; (* checkAttributes := BuCheckAttributes;*) applyAttributes := BuApplyAttributes; computeSX := BuComputeSX; save := BuSave; load := BuLoad; initObliqAttrs := BuObAttrs; END; BooleanNode = NodeVBT.Widget BRANDED "VO-BooleanNode" OBJECT textLabel : BOOLEAN := TRUE; text : TEXT := "Label"; pixmap : TEXT := ""; initialValue : BOOLEAN := FALSE; feedbackStyle: TEXT := "CheckBox"; (* may be "CheckBox", "CheckMark", "Inverted" *) OVERRIDES loadAttributes := BoLoadAttributes; applyAttributes := BoApplyAttributes; computeSX := BoComputeSX; save := BoSave; load := BoLoad; initObliqAttrs := BoObAttrs; END; ChoiceNode = NodeVBT.Widget BRANDED "VO-ChoiceNode" OBJECT textLabel : BOOLEAN := TRUE; text : TEXT := "Label"; pixmap : TEXT := ""; initialValue : BOOLEAN := FALSE; feedbackStyle: TEXT := "CheckBox"; (* may be "CheckBox", "CheckMark", "Inverted" *) OVERRIDES loadAttributes := ChLoadAttributes; applyAttributes := ChApplyAttributes; computeSX := ChComputeSX; save := ChSave; load := ChLoad; initObliqAttrs := ChObAttrs; END; <* FATAL FormsVBT.Error,FormsVBT.Unimplemented, Split.NotAChild *> PROCEDURE Clickable ButtonConstructor (): NodeVBT.T = BEGIN RETURN NEW(ButtonNode, BgColor := "RatherLightYellow", FgColor := "Black", Rim := 0, Border := 1, Font := "-*-helvetica-bold-*R-*120-*", width := 50, height := 20, Embellishment := "None", ResizeModel := "CenterPin"); END ButtonConstructor; PROCEDUREBooleanConstructor (): NodeVBT.T = BEGIN RETURN NEW(BooleanNode, BgColor := "Grey90", FgColor := "Black", Rim := 0, Border := 1, Font := "-*-helvetica-bold-*R-*120-*", width := 50, height := 20, Embellishment := "None", ResizeModel := "CenterPin"); END BooleanConstructor; PROCEDUREChoiceConstructor (): NodeVBT.T = BEGIN RETURN NEW(ChoiceNode, BgColor := "Grey90", FgColor := "Black", Rim := 0, Border := 0, Font := "-*-helvetica-bold-*R-*120-*", width := 50, height := 20, Embellishment := "None", ResizeModel := "CenterPin"); END ChoiceConstructor;
PROCEDUREBuLoadAttributes (nv: ButtonNode; as: FormsVBT.T) = BEGIN IF nv.textLabel THEN FormsVBT.PutChoice(as, "buRadio", "buTChoice") ELSE FormsVBT.PutChoice(as, "buRadio", "buPChoice") END; FormsVBT.PutText(as, "buText", nv.text, FALSE); FormsVBT.PutText(as, "buPix", nv.pixmap, FALSE); FormsVBT.PutBoolean(as, "buGuard", nv.Guard); FormsVBT.PutBoolean(as, "buTrill", nv.Trill); NodeVBT.T.loadAttributes(nv, as); END BuLoadAttributes;
PROCEDURE BuCheckAttributes ( nv : ButtonNode; as : FormsVBT.T; VAR error: TEXT ): BOOLEAN = BEGIN IF NOT NodeVBT.T.checkAttributes(nv, as, error) THEN RETURN FALSE END;
IF Text.Equal(FormsVBT.GetChoice(as, buRadio
), buPChoice
) THEN
(* check pixmap
WITH pixmap = FormsVBT.GetText(as, "buPix") DO TRY EVAL GetRawImage(pixmap) EXCEPT Error (msg) => error := "Invalid Pixmap" & msg; RETURN FALSE ELSE END END END; RETURN TRUE; END BuCheckAttributes; *) PROCEDUREBoolean support procsBuApplyAttributes (nv: ButtonNode; as: FormsVBT.T) = BEGIN NodeVBT.T.applyAttributes(nv, as); nv.text := FormsVBT.GetText(as, "buText"); nv.pixmap := FormsVBT.GetText(as, "buPix"); nv.textLabel := Text.Equal(FormsVBT.GetChoice(as, "buRadio"), "buTChoice"); nv.Guard := FormsVBT.GetBoolean(as, "buGuard"); nv.Trill := FormsVBT.GetBoolean(as, "buTrill"); END BuApplyAttributes; PROCEDUREBuComputeSX (nv: ButtonNode; Final: BOOLEAN := FALSE): TEXT = BEGIN IF nv.Guard THEN nv.DialogSX := NodeVBT.FindAndReplace(NodeVBT.FindAndReplace( nv.DialogSX, "GuardHeader", "(Guard %@guard "), "GuardFooter", ")"); ELSE nv.DialogSX := NodeVBT.FindAndReplace(NodeVBT.FindAndReplace( nv.DialogSX, "GuardHeader", ""), "GuardFooter", ""); END; IF nv.Trill THEN nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "Trill", "Trill") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "Trill", "") END; IF nv.textLabel THEN nv.DialogSX := NodeVBT.FindAndReplace( nv.DialogSX, "ButtonContents", "Text %@text \"" & nv.text & "\"") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "ButtonContents", "Pixmap Accurate %@pixmap \"" & nv.pixmap & "\"") END; RETURN NodeVBT.T.computeSX(nv, Final); END BuComputeSX; PROCEDUREBuObAttrs (nv: ButtonNode): TEXT = VAR code := ""; BEGIN code := NodeVBT.BoolAttr("textLabel", nv.textLabel) & NodeVBT.TextAttr("textString", nv.text) & NodeVBT.TextAttr("pixmap", nv.pixmap) & NodeVBT.BoolAttr("Guard", nv.Guard) & NodeVBT.BoolAttr("Trill", nv.Trill); RETURN NodeVBT.T.initObliqAttrs(nv) & code ; END BuObAttrs;
PROCEDUREChoice support procsBoLoadAttributes (nv: BooleanNode; as: FormsVBT.T) = BEGIN NodeVBT.T.loadAttributes(nv, as); FormsVBT.PutBoolean(as, "boInitial", nv.initialValue); FormsVBT.PutChoice(as, "Booleanfbs", "B" & nv.feedbackStyle); IF nv.textLabel THEN FormsVBT.PutChoice(as, "boRadio", "boTChoice") ELSE FormsVBT.PutChoice(as, "boRadio", "boPChoice") END; FormsVBT.PutText(as, "boText", nv.text, FALSE); FormsVBT.PutText(as, "boPix", nv.pixmap, FALSE); nv.text := FormsVBT.GetText(as, "boText"); nv.pixmap := FormsVBT.GetText(as, "boPix"); nv.textLabel := Text.Equal(FormsVBT.GetChoice(as, "boRadio"), "boTChoice"); END BoLoadAttributes; PROCEDUREBoApplyAttributes (nv: BooleanNode; as: FormsVBT.T) = BEGIN NodeVBT.T.applyAttributes(nv, as); nv.initialValue := FormsVBT.GetBoolean(as, "boInitial"); nv.feedbackStyle := Text.Sub(FormsVBT.GetChoice(as, "Booleanfbs"), 1); nv.text := FormsVBT.GetText(as, "boText"); nv.pixmap := FormsVBT.GetText(as, "boPix"); nv.textLabel := Text.Equal(FormsVBT.GetChoice(as, "boRadio"), "boTChoice"); END BoApplyAttributes; PROCEDUREBoComputeSX (nv: BooleanNode; Final: BOOLEAN := FALSE): TEXT = BEGIN nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "fbstyle", nv.feedbackStyle); IF nv.initialValue THEN nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "initValue", "TRUE") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "initValue", "FALSE") END; IF nv.textLabel THEN nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "BooleanContents", "Text %@text \"" & nv.text & "\"") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "BooleanContents", "Pixmap %@pixmap \"" & nv.pixmap & "\"") END; RETURN NodeVBT.T.computeSX(nv, Final); END BoComputeSX; PROCEDUREBoObAttrs (nv: BooleanNode) : TEXT = VAR code := ""; BEGIN code := NodeVBT.BoolAttr("textLabel", nv.textLabel) & NodeVBT.TextAttr("textString", nv.text) & NodeVBT.TextAttr("feedbackStyle", nv.feedbackStyle) & NodeVBT.BoolAttr("initialValue", nv.initialValue); RETURN NodeVBT.T.initObliqAttrs(nv) & code ; END BoObAttrs;
PROCEDUREChLoadAttributes (nv: ChoiceNode; as: FormsVBT.T) = BEGIN NodeVBT.T.loadAttributes(nv, as); FormsVBT.PutBoolean(as, "chInitial", nv.initialValue); FormsVBT.PutChoice(as, "Choicefbs", "C" & nv.feedbackStyle); IF nv.textLabel THEN FormsVBT.PutChoice(as, "chRadio", "chTChoice") ELSE FormsVBT.PutChoice(as, "chRadio", "chPChoice") END; FormsVBT.PutText(as, "chText", nv.text, FALSE); FormsVBT.PutText(as, "chPix", nv.pixmap, FALSE); END ChLoadAttributes; PROCEDUREChApplyAttributes (nv: ChoiceNode; as: FormsVBT.T) = VAR child: VBT.T; BEGIN NodeVBT.T.applyAttributes(nv, as); nv.initialValue := FormsVBT.GetBoolean(as, "chInitial"); nv.feedbackStyle := Text.Sub(FormsVBT.GetChoice(as, "Choicefbs"), 1); IF nv.initialValue THEN (* Since this choice is being set turn off all other siblings *) WITH parent = nv.parent DO (* turn off all siblings *) (* parent is a NodeVBT.TYPE and hence a ZHandleVBT.T and hence a ZSplit.T *) child := Split.Succ(parent, NIL); (* Top *) WHILE child # NIL DO IF ISTYPE(child, ChoiceNode) THEN WITH kid = NARROW(child, ChoiceNode), sonny = NARROW(kid.getchild(), FormsVBT.T) DO FormsVBT.PutBoolean(sonny, kid.name, FALSE); kid.initialValue := FALSE; END END; child := Split.Succ(parent, child); END END; nv.initialValue := TRUE; (*since we would have turned this off as well*) END; nv.text := FormsVBT.GetText(as, "chText"); nv.pixmap := FormsVBT.GetText(as, "chPix"); nv.textLabel := Text.Equal(FormsVBT.GetChoice(as, "chRadio"), "chTChoice"); END ChApplyAttributes; PROCEDUREChComputeSX (nv: ChoiceNode; Final: BOOLEAN := FALSE): TEXT = BEGIN IF NOT Final THEN nv.DialogSX := "(Radio \n" & nv.DialogSX & ")\n" END; nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "fbstyle", nv.feedbackStyle); IF nv.initialValue THEN nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "initValue", "TRUE") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "initValue", "FALSE") END; IF nv.textLabel THEN nv.DialogSX := NodeVBT.FindAndReplace( nv.DialogSX, "ChoiceContents", "Text %@text \"" & nv.text & "\"") ELSE nv.DialogSX := NodeVBT.FindAndReplace(nv.DialogSX, "ChoiceContents", "Pixmap %@pixmap \"" & nv.pixmap & "\"") END; RETURN NodeVBT.T.computeSX(nv, Final); END ChComputeSX; PROCEDUREChObAttrs (nv: ChoiceNode) : TEXT = VAR code := ""; BEGIN code := NodeVBT.BoolAttr("textLabel", nv.textLabel) & NodeVBT.TextAttr("textString", nv.text) & NodeVBT.TextAttr("pixmap", nv.pixmap) & NodeVBT.TextAttr("feedbackStyle", nv.feedbackStyle) & NodeVBT.BoolAttr("initialValue", nv.initialValue); RETURN NodeVBT.T.initObliqAttrs(nv) & code ; END ChObAttrs; PROCEDUREBuSave (nv: ButtonNode; fv: FormsVBT.T; s: Wr.T) = BEGIN NodeVBT.T.save(nv, fv, s); RW.wbool(s, nv.textLabel); RW.wtext(s, nv.text); RW.wtext(s, nv.pixmap); RW.wbool(s, nv.Guard); RW.wbool(s, nv.Trill); END BuSave; PROCEDUREBuLoad (nv: ButtonNode; fv: FormsVBT.T; s: Rd.T) = BEGIN NodeVBT.T.load(nv, fv, s); RW.rbool(s, nv.textLabel); RW.rtext(s, nv.text); RW.rtext(s, nv.pixmap); RW.rbool(s, nv.Guard); RW.rbool(s, nv.Trill); END BuLoad; PROCEDUREBoSave (nv: BooleanNode; fv: FormsVBT.T; s: Wr.T) = BEGIN NodeVBT.T.save(nv, fv, s); RW.wbool(s, nv.textLabel); RW.wtext(s, nv.text); RW.wtext(s, nv.pixmap); RW.wbool(s, nv.initialValue); RW.wtext(s, nv.feedbackStyle); END BoSave; PROCEDUREBoLoad (nv: BooleanNode; fv: FormsVBT.T; s: Rd.T) = BEGIN NodeVBT.T.load(nv, fv, s); RW.rbool(s, nv.textLabel); RW.rtext(s, nv.text); RW.rtext(s, nv.pixmap); RW.rbool(s, nv.initialValue); RW.rtext(s, nv.feedbackStyle); END BoLoad; PROCEDUREChSave (nv: ChoiceNode; fv: FormsVBT.T; s: Wr.T) = BEGIN NodeVBT.T.save(nv, fv, s); RW.wbool(s, nv.textLabel); RW.wtext(s, nv.text); RW.wtext(s, nv.pixmap); RW.wbool(s, nv.initialValue); RW.wtext(s, nv.feedbackStyle); END ChSave; PROCEDUREChLoad (nv: ChoiceNode; fv: FormsVBT.T; s: Rd.T) = BEGIN NodeVBT.T.load(nv, fv, s); RW.rbool(s, nv.textLabel); RW.rtext(s, nv.text); RW.rtext(s, nv.pixmap); RW.rbool(s, nv.initialValue); RW.rtext(s, nv.feedbackStyle); END ChLoad; PROCEDUREInitialize () = BEGIN EVAL NodeVBT.Register("button", ButtonConstructor); EVAL NodeVBT.Register("boolean", BooleanConstructor); EVAL NodeVBT.Register("choice", ChoiceConstructor); END Initialize; BEGIN END Clickable.