MODULE WMTextStyleTool; (** AUTHOR "TF"; PURPOSE "Text Tool"; *) IMPORT Commands, Streams, Texts, Strings, WMComponents, WMRestorable, WMStringGrids, WMGrids, WMEditors, WMGraphics, WMMessages, WMStandardComponents, Modules, WMPopups, WMRectangles, WMDialogs, FP1616, Files, XMLParser, XMLScanner, XML, XMLObjects, WM := WMWindowManager; CONST AlignLeft = 0; AlignCenter = 1; AlignRight = 2; AlignJustified = 3; StyleRegular = 0; StyleBold = 1; StyleItalic = 2; StyleBoldItalic = 3; (* field parameter for Change procedure *) ChangeFont = {0}; ChangeSize = {1}; ChangeStyle = {2}; ChangeFgColor = {3}; ChangeBgColor = {4}; (* mode parameter for Change procedure *) Absolute = 0; IncrementBy = 1; DecrementBy = 2; TYPE KillerMsg = OBJECT END KillerMsg; ContextMenuData = OBJECT VAR val: LONGINT; PROCEDURE &New*(val: LONGINT); BEGIN SELF.val := val; END New; END ContextMenuData; TYPE ChangeInfo= OBJECT (Texts.Attributes) VAR fields : SET; (* which fields should be changed *) name : ARRAY 128 OF CHAR; deltaSizeMode : LONGINT; (* Interpretation of deltasize field: Absolute, IncrementBy, DecrementBy *) deltaSize : LONGINT; fgColor, bgColor : LONGINT; style : SET; PROCEDURE &Init*; BEGIN fields := {}; deltaSizeMode := 0; deltaSize := 0; fgColor := 0; bgColor := 0; style := {}; END Init; END ChangeInfo; TYPE Window* = OBJECT (WMComponents.FormWindow) VAR bold, lock, comment, stupid, assert, preferred, debug, normal, highlight, adhoc, more, edit, link, label: WMStandardComponents.Button; winpanel : WMStandardComponents.Panel; cList : WMStringGrids.StringGrid; styleEditor : StyleEditor; PROCEDURE CreateForm(): WMComponents.VisualComponent; VAR panel : WMStandardComponents.Panel; toolbar: WMStandardComponents.Panel; PROCEDURE AB(panel : WMStandardComponents.Panel; btn: WMStandardComponents.Button); BEGIN btn.alignment.Set(WMComponents.AlignLeft); btn.bounds.SetWidth(60); panel.AddContent(btn) END AB; BEGIN NEW(panel); panel.bounds.SetExtents(120, 140); panel.takesFocus.Set(TRUE); (* link & label*) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(link); link.caption.SetAOC("Add Link"); AB(toolbar, link); link.clDefault.Set(080CC80H); NEW(label); label.caption.SetAOC("Add Label"); AB(toolbar, label); label.clDefault.Set(080CC80H); (* styles *) (**) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(bold); bold.caption.SetAOC("Bold"); AB(toolbar, bold); NEW(lock); lock.caption.SetAOC("Lock"); AB(toolbar, lock); (**) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(comment); comment.caption.SetAOC("Comment"); AB(toolbar, comment); NEW(debug); debug.caption.SetAOC("Debug"); AB(toolbar, debug); (**) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(stupid); stupid.caption.SetAOC("Stupid"); AB(toolbar, stupid); NEW(assert); assert.caption.SetAOC("Assert"); AB(toolbar, assert); (**) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(preferred); preferred.caption.SetAOC("Preferred"); AB(toolbar, preferred); NEW(normal); normal.caption.SetAOC("Normal"); AB(toolbar, normal); (**) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(highlight); highlight.caption.SetAOC("Highlight"); AB(toolbar, highlight); NEW(adhoc); adhoc.caption.SetAOC("AdHoc"); AB(toolbar, adhoc); adhoc.clDefault.Set(0CC0080H); (* style edit *) NEW(toolbar); toolbar.bounds.SetHeight(20); toolbar.alignment.Set(WMComponents.AlignTop); panel.AddContent(toolbar); NEW(more); more.caption.SetAOC("More"); AB(toolbar, more); more.clDefault.Set(0CC000080H); NEW(edit); edit.caption.SetAOC("Edit"); AB(toolbar, edit); edit.clDefault.Set(0CC000080H); edit.visible.Set(FALSE); (* List *) NEW(cList); cList.alignment.Set(WMComponents.AlignClient); cList.onClick.Add(SetStyleFromList); cList.clCell.Set(0FFFFFFCCH); cList.clHover.Set(0FFFF00CCH); cList.model.Acquire; cList.model.SetNofCols(1); cList.model.SetNofRows(1); cList.SetSelectionMode(WMGrids.GridSelectSingleRow); cList.model.Release; panel.AddContent(cList); winpanel := panel; RETURN panel END CreateForm; PROCEDURE &New*(c : WMRestorable.Context); VAR vc : WMComponents.VisualComponent; xml : XML.Element; s : Strings.String; temp : BOOLEAN; BEGIN IncCount; vc := CreateForm(); bold.onClick.Add(SetStyle); lock.onClick.Add(SetStyle); comment.onClick.Add(SetStyle); debug.onClick.Add(SetStyle); stupid.onClick.Add(SetStyle); assert.onClick.Add(SetStyle); preferred.onClick.Add(SetStyle); normal.onClick.Add(SetStyle); highlight.onClick.Add(SetStyle); (* adhoc style *) adhoc.onClick.Add(AdHocStyle); (* style editor *) more.onClick.Add(ShowList); edit.onClick.Add(EditStyles); link.onClick.Add(AddLink); label.onClick.Add(AddLabel); Init(vc.bounds.GetWidth(), vc.bounds.GetHeight(), TRUE); SetContent(vc); BuildList; IF c # NIL THEN WMRestorable.AddByContext(SELF, c); IF c.appData # NIL THEN xml := c.appData(XML.Element); s := xml.GetAttributeValue("expanded"); IF s # NIL THEN Strings.StrToBool(s^, temp) END; IF temp THEN more.caption.SetAOC("Less"); edit.visible.Set(TRUE); END; END; Resized(GetWidth(), GetHeight()); ELSE WM.AddWindow(SELF, 50, 50) END; SetTitle(Strings.NewString("Text Styles")) END New; (* -- Handlers -- *) PROCEDURE AdHocStyle(sender, data : ANY); VAR adhocStyle : AdHocStyleWindow; BEGIN NEW(adhocStyle) END AdHocStyle; PROCEDURE EditStyles(sender, data: ANY); BEGIN IF styleEditor = NIL THEN NEW(styleEditor); styleEditor.UpdateProc := BuildList; END; styleEditor.Show(200, 150); END EditStyles; PROCEDURE ShowList(sender, data: ANY); VAR caption : Strings.String; button : WMStandardComponents.Button; width, height : LONGINT; BEGIN button := sender(WMStandardComponents.Button); caption := button.caption.Get(); manager := WM.GetDefaultManager(); IF caption^ = "More" THEN button.caption.SetAOC("Less"); width := GetWidth(); height := GetHeight()+ 300; edit.visible.Set(TRUE); ELSE button.caption.SetAOC("More"); width := GetWidth(); height := 140; edit.visible.Set(FALSE); END; manager.SetWindowSize(SELF, width, height); Resized(width, height); END ShowList; PROCEDURE BuildList; VAR styles : Texts.CharacterStyleArray; i : LONGINT; BEGIN styles := Texts.GetCharacterStyleArray(); cList.model.Acquire; i := 0; WHILE ((i *) NEW(panel); panel.bounds.SetHeight(20); panel.alignment.Set(WMComponents.AlignTop); label := CreateLabel(" Tracking:"); panel.AddContent(label); cTracking := CreateEditor(); panel.AddContent(cTracking); (* propertyPanel.AddContent(panel); *) NEW(panel); panel.bounds.SetHeight(20); panel.alignment.Set(WMComponents.AlignTop); label := CreateLabel(" Stretch Horizontal:"); panel.AddContent(label); cStretchH := CreateEditor(); panel.AddContent(cStretchH); (* propertyPanel.AddContent(panel); *) NEW(panel); panel.bounds.SetHeight(20); panel.alignment.Set(WMComponents.AlignTop); label := CreateLabel(" Stretch Vertical:"); panel.AddContent(label); cStretchV := CreateEditor(); panel.AddContent(cStretchV); (* propertyPanel.AddContent(panel); *) (* <---------------- *) (* preview panel *) NEW(panel); panel.bounds.SetHeight(15); panel.alignment.Set(WMComponents.AlignTop); propertyPanel.AddContent(panel); NEW(groupPanel); groupPanel.alignment.Set(WMComponents.AlignTop); groupPanel.caption.SetAOC("Preview:"); groupPanel.bounds.SetHeight(80); NEW(previewLabel); previewLabel.fillColor.Set(0FFFFFFFFH); previewLabel.alignment.Set(WMComponents.AlignClient); previewLabel.caption.SetAOC("The quick brown Fox jumped over the lazy Dog"); previewLabel.alignH.Set(1); previewLabel.alignV.Set(1); groupPanel.AddContent(previewLabel); propertyPanel.AddContent(groupPanel); NEW(fontNotFound); fontNotFound.bounds.SetHeight(20); fontNotFound.alignment.Set(WMComponents.AlignTop); fontNotFound.caption.SetAOC(" ERROR: Font not found! - using DefaultFont"); fontNotFound.visible.Set(FALSE); propertyPanel.AddContent(fontNotFound); fontNotFound.textColor.Set(0FF0000FFH); (* -- character style buttons -- *) NEW(buttonPanel); buttonPanel.bounds.SetHeight(20); buttonPanel.fillColor.Set(windowStyle.bgColor); buttonPanel.alignment.Set(WMComponents.AlignBottom); NEW(button); button.caption.SetAOC("Apply"); button.alignment.Set(WMComponents.AlignRight); button.onClick.Add(ApplyCHandler); buttonPanel.AddContent(button); NEW(button); button.caption.SetAOC("Delete"); button.alignment.Set(WMComponents.AlignRight); button.onClick.Add(RemoveCHandler); buttonPanel.AddContent(button); NEW(button); button.caption.SetAOC("Export"); button.alignment.Set(WMComponents.AlignRight); button.onClick.Add(ExportCHandler); buttonPanel.AddContent(button); NEW(button); button.caption.SetAOC("Import"); button.alignment.Set(WMComponents.AlignRight); button.onClick.Add(ImportCHandler); buttonPanel.AddContent(button); NEW(button); button.caption.SetAOC("New"); button.alignment.Set(WMComponents.AlignRight); button.onClick.Add(NewCHandler); buttonPanel.AddContent(button); propertyPanel.AddContent(buttonPanel); RETURN mainPanel; END CreateForm; PROCEDURE &New*; VAR BEGIN vc := CreateForm(); Init(vc.bounds.GetWidth(), vc.bounds.GetHeight(), FALSE); SetContent(vc); SetTitle(Strings.NewString("Style Editor")); pStyles := Texts.GetParagraphStyleArray(); cStyles := Texts.GetCharacterStyleArray(); END New; PROCEDURE Show*(x, y: LONGINT); BEGIN LoadStyleList; IF ~shown THEN shown := TRUE; ELSE Hide; shown := TRUE; END; manager := WM.GetDefaultManager(); WM.AddWindow(SELF, x, y); manager.SetFocus(SELF); cList.SetSelection(0,0,0,0) END Show; PROCEDURE Hide*; BEGIN IF shown THEN shown := FALSE; manager := WM.GetDefaultManager(); manager.Remove(SELF); END; END Hide; PROCEDURE Close*; BEGIN Close^; IF UpdateProc # NIL THEN UpdateProc END; shown := FALSE; END Close; PROCEDURE LoadStyleList; VAR i : LONGINT; BEGIN vc.Acquire; pList.model.Acquire; i := 0; WHILE ((i 0 THEN CClickSelected(NIL, cList.model.GetCellData(0, 0)); END; cList.model.Release; vc.Release; END LoadStyleList; PROCEDURE TabHandler(sender, data: ANY); BEGIN IF (sender # NIL) & (sender IS WMStandardComponents.Button) THEN IF sender = pstyleButton THEN cstylePanel.visible.Set(FALSE); cstyleButton.clDefault.Set(tabColor); pstylePanel.visible.Set(TRUE); pstyleButton.clDefault.Set(tabSelectedColor); ELSIF sender = cstyleButton THEN pstylePanel.visible.Set(FALSE); pstyleButton.clDefault.Set(tabColor); cstylePanel.visible.Set(TRUE); cstyleButton.clDefault.Set(tabSelectedColor); ELSE END; END; END TabHandler; PROCEDURE PClickSelected(sender, data: ANY); VAR tempString: ARRAY 64 OF CHAR; BEGIN IF (data # NIL) THEN currentPStyle := data(Texts.ParagraphStyle); tempPStyle := currentPStyle.Clone(); pName.SetAsString(currentPStyle.name); IF (currentPStyle.alignment = 0) THEN tempString := "Left"; ELSIF (currentPStyle.alignment = 1) THEN tempString := "Center"; ELSIF (currentPStyle.alignment = 2) THEN tempString := "Right"; ELSE tempString := "Justified"; END; pAlign.SetAsString(tempString); Strings.FloatToStr(currentPStyle.firstIndent, 0,4,0, tempString); pFirstIndent.SetAsString(tempString); Strings.FloatToStr(currentPStyle.leftIndent, 0,4,0, tempString); pLeftIndent.SetAsString(tempString); Strings.FloatToStr(currentPStyle.rightIndent, 0,4,0, tempString); pRightIndent.SetAsString(tempString); Strings.FloatToStr(currentPStyle.spaceBefore, 0,4,0, tempString); pSpaceBefore.SetAsString(tempString); Strings.FloatToStr(currentPStyle.spaceAfter, 0,4,0, tempString); pSpaceAfter.SetAsString(tempString); pDefCharStyle.SetAsString(currentPStyle.charStyle.name); COPY(currentPStyle.name, oldPStyleName); END; END PClickSelected; PROCEDURE CClickSelected(sender, data: ANY); VAR tempString: ARRAY 64 OF CHAR; tempFont: WMGraphics.Font; BEGIN IF (data # NIL) THEN currentCStyle := data(Texts.CharacterStyle); tempCStyle := currentCStyle.Clone(); cName.SetAsString(currentCStyle.name); cFont.SetAsString(currentCStyle.family); IF (currentCStyle.style * {0, 1} = {}) THEN tempString := "Regular"; ELSIF (currentCStyle.style * {0, 1} = {0}) THEN tempString := "Bold"; ELSIF (currentCStyle.style * {0, 1} = {1}) THEN tempString := "Italic"; ELSE tempString := "Bold Italic"; END; cStyle.SetAsString(tempString); Strings.FloatToStr(FP1616.FixpToFloat(currentCStyle.size), 0,4,0, tempString); cSize.SetAsString(tempString); Strings.FloatToStr(FP1616.FixpToFloat(currentCStyle.leading), 0,4,0, tempString); cLeading.SetAsString(tempString); Strings.FloatToStr(currentCStyle.baselineShift, 0,4,0, tempString); cBaselineShift.SetAsString(tempString); Strings.IntToHexStr(currentCStyle.color, 7, tempString); cColor.SetAsString(tempString); Strings.IntToHexStr(currentCStyle.bgColor, 7, tempString); cBackColor.SetAsString(tempString); Strings.FloatToStr(FP1616.FixpToFloat(currentCStyle.tracking), 0,4,0, tempString); cTracking.SetAsString(tempString); Strings.FloatToStr(FP1616.FixpToFloat(currentCStyle.scaleHorizontal), 0,4,0, tempString); cStretchH.SetAsString(tempString); Strings.FloatToStr(FP1616.FixpToFloat(currentCStyle.scaleVertical), 0,4,0, tempString); cStretchV.SetAsString(tempString); COPY(currentCStyle.name, oldCStyleName); (* update preview *) tempFont := WMGraphics.GetFont(tempCStyle.family, ENTIER(FP1616.FixpToFloat(tempCStyle.size)), tempCStyle.style); previewLabel.SetFont(tempFont); previewLabel.fillColor.Set(tempCStyle.bgColor); previewLabel.textColor.Set(tempCStyle.color); previewLabel.Invalidate; END; END CClickSelected; PROCEDURE UpdateValueHandler(sender, data: ANY); VAR tempString : ARRAY 64 OF CHAR; tempLReal : LONGREAL; tempInt : LONGINT; res : WORD; tempCharStyle : Texts.CharacterStyle; tempFont : WMGraphics.Font; tempEditor : WMEditors.Editor; BEGIN (* paragraph style *) IF sender IS WMEditors.Editor THEN tempEditor := sender(WMEditors.Editor); tempEditor.GetAsString(tempString); END; IF (tempEditor = pName) THEN COPY(tempString, tempPStyle.name); ELSIF (tempEditor = pAlign) THEN Strings.LowerCase(tempString); IF (tempString = "left") THEN tempPStyle.alignment := 0; pAlign.SetAsString("Left"); ELSIF (tempString = "center") THEN tempPStyle.alignment := 1; pAlign.SetAsString("Center"); ELSIF (tempString = "right") THEN tempPStyle.alignment := 2; pAlign.SetAsString("Right"); ELSIF (tempString = "justified") THEN tempPStyle.alignment := 3; pAlign.SetAsString("Justified"); ELSE tempPStyle.alignment := 0; pAlign.SetAsString("Left"); END; ELSIF (tempEditor = pFirstIndent) THEN Strings.StrToFloat(tempString, tempLReal); tempPStyle.firstIndent := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); pFirstIndent.SetAsString(tempString); ELSIF (tempEditor = pLeftIndent) THEN Strings.StrToFloat(tempString, tempLReal); tempPStyle.leftIndent := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); pLeftIndent.SetAsString(tempString); ELSIF (tempEditor = pRightIndent) THEN Strings.StrToFloat(tempString, tempLReal); tempPStyle.rightIndent := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); pRightIndent.SetAsString(tempString); ELSIF (tempEditor = pSpaceBefore) THEN Strings.StrToFloat(tempString, tempLReal); tempPStyle.spaceBefore := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); pSpaceBefore.SetAsString(tempString); ELSIF (tempEditor = pSpaceAfter) THEN Strings.StrToFloat(tempString, tempLReal); tempPStyle.spaceAfter := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); pSpaceAfter.SetAsString(tempString); ELSIF (tempEditor = pDefCharStyle) THEN tempCharStyle := Texts.GetCharacterStyleByName(tempString); IF tempCharStyle # NIL THEN tempPStyle.charStyle := tempCharStyle; ELSE tempPStyle.charStyle := Texts.GetCharacterStyleByName("Normal"); pDefCharStyle.SetAsString(tempPStyle.charStyle.name); END; (* character style *) ELSIF (tempEditor = cName) THEN COPY(tempString, tempCStyle.name); ELSIF (tempEditor = cFont) THEN COPY(tempString, tempCStyle.family); (* load font *) tempFont := WMGraphics.GetFont(tempCStyle.family, ENTIER(FP1616.FixpToFloat(tempCStyle.size)), tempCStyle.style); previewLabel.SetFont(tempFont); previewLabel.Invalidate; IF (tempFont.name # tempCStyle.family) OR (tempFont.size # ENTIER(FP1616.FixpToFloat(tempCStyle.size))) THEN (* OR (tempFont.style # tempCStyle.style) *) fontNotFound.visible.Set(TRUE); ELSE fontNotFound.visible.Set(FALSE); END; ELSIF (tempEditor = cStyle) THEN Strings.LowerCase(tempString); IF (tempString = "regular") THEN tempCStyle.style := {}; cStyle.SetAsString("Regular"); ELSIF (tempString = "bold") THEN tempCStyle.style := {0}; cStyle.SetAsString("Bold"); ELSIF (tempString = "italic") THEN tempCStyle.style := {1}; cStyle.SetAsString("Italic"); ELSIF (tempString = "bold italic") THEN tempCStyle.style := {0, 1}; cStyle.SetAsString("Bold Italic"); ELSE tempCStyle.style := {}; cStyle.SetAsString("Regular"); END; tempFont := WMGraphics.GetFont(tempCStyle.family, ENTIER(FP1616.FixpToFloat(tempCStyle.size)), tempCStyle.style); previewLabel.SetFont(tempFont); previewLabel.Invalidate; IF (tempFont.name # tempCStyle.family) OR (tempFont.size # ENTIER(FP1616.FixpToFloat(tempCStyle.size))) THEN fontNotFound.visible.Set(TRUE); ELSE fontNotFound.visible.Set(FALSE); END; ELSIF (tempEditor = cSize) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.size := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cSize.SetAsString(tempString); (* set leading to 120% of size *) tempLReal := tempLReal*1.2; tempCStyle.leading := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cLeading.SetAsString(tempString); tempFont := WMGraphics.GetFont(tempCStyle.family, ENTIER(FP1616.FixpToFloat(tempCStyle.size)), tempCStyle.style); previewLabel.SetFont(tempFont); previewLabel.Invalidate; IF (tempFont.name # tempCStyle.family) OR (tempFont.size # ENTIER(FP1616.FixpToFloat(tempCStyle.size))) THEN fontNotFound.visible.Set(TRUE); ELSE fontNotFound.visible.Set(FALSE); END; ELSIF (tempEditor = cLeading) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.leading := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cLeading.SetAsString(tempString); ELSIF (tempEditor = cBaselineShift) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.baselineShift := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cBaselineShift.SetAsString(tempString); ELSIF (tempEditor = cColor) THEN Strings.HexStrToInt(tempString, tempInt, res); tempCStyle.color := tempInt; Strings.IntToHexStr(tempInt, 7, tempString); cColor.SetAsString(tempString); previewLabel.textColor.Set(tempInt); previewLabel.Invalidate; ELSIF (tempEditor = cBackColor) THEN Strings.HexStrToInt(tempString, tempInt, res); tempCStyle.bgColor := tempInt; Strings.IntToHexStr(tempInt, 7, tempString); cBackColor.SetAsString(tempString); previewLabel.fillColor.Set(tempInt); previewLabel.Invalidate; ELSIF (tempEditor = cTracking) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.tracking := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cTracking.SetAsString(tempString); ELSIF (tempEditor = cStretchH) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.scaleHorizontal := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cStretchH.SetAsString(tempString); ELSIF (tempEditor = cStretchV) THEN Strings.StrToFloat(tempString, tempLReal); tempCStyle.scaleVertical := FP1616.FloatToFixp(SHORT(tempLReal)); Strings.FloatToStr(tempLReal, 0,4,0, tempString); cStretchV.SetAsString(tempString); ELSE END; END UpdateValueHandler; PROCEDURE UpdateList; VAR i : LONGINT; BEGIN pList.model.Acquire; i := 0; WHILE ((i'); w.Ln; w.String(""); w.Ln; (* processing character styles *) i := 0; WHILE ((i'); w.Ln; INC(i); END; w.String(""); w.Ln; w.Update; Files.Register(f); END ExportCharacterStyles; PROCEDURE ImportCHandler(sender, data: ANY); VAR filename: ARRAY 128 OF CHAR; BEGIN filename := ""; IF WMDialogs.QueryString("Import Character Styles from File:", filename) = WMDialogs.ResOk THEN ImportCharacterStyles(filename); END; UpdateList; END ImportCHandler; PROCEDURE ImportCharacterStyles(CONST filename: ARRAY OF CHAR); VAR tempString : ARRAY 256 OF CHAR; tempReal: LONGREAL; tempInt: LONGINT; res: WORD; reader : Files.Reader; parser : XMLParser.Parser; scanner : XMLScanner.Scanner; f : Files.File; XMLdocStyle : XML.Document; root: XML.Element; cont: XMLObjects.Enumerator; ptr: ANY; str: Strings.String; cStyle: Texts.CharacterStyle; BEGIN COPY(filename, tempString); Strings.Append(tempString, ".XML"); f := Files.Old(tempString); IF f = NIL THEN RETURN END; NEW(reader, f, 0); NEW(scanner, reader); NEW(parser, scanner); XMLdocStyle := parser.Parse(); root := XMLdocStyle.GetRoot(); cont := root.GetContents(); cont.Reset(); WHILE cont.HasMoreElements() DO ptr := cont.GetNext(); IF ptr IS XML.Element THEN str := ptr(XML.Element).GetName(); (* KernelLog.String(str^); KernelLog.Ln; *) IF (str # NIL) & (str^ = "character-style") THEN (* character styles *) NEW(cStyle); str := ptr(XML.Element).GetAttributeValue("name"); IF str # NIL THEN COPY(str^, cStyle.name) END; str := ptr(XML.Element).GetAttributeValue("font-family"); IF str # NIL THEN COPY(str^, cStyle.family) END; str := ptr(XML.Element).GetAttributeValue("font-style"); IF str # NIL THEN IF (str^ = "0") THEN cStyle.style := {}; ELSIF (str^ = "1") THEN cStyle.style := {0}; ELSIF (str^ = "2") THEN cStyle.style := {1}; ELSIF (str^ = "3") THEN cStyle.style := {0,1}; ELSE cStyle.style := {}; END; END; str := ptr(XML.Element).GetAttributeValue("font-size"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.size := FP1616.FloatToFixp(SHORT(tempReal)); END; str := ptr(XML.Element).GetAttributeValue("leading"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.leading := FP1616.FloatToFixp(SHORT(tempReal)); END; str := ptr(XML.Element).GetAttributeValue("baseline-shift"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.baselineShift := FP1616.FloatToFixp(SHORT(tempReal)); END; str := ptr(XML.Element).GetAttributeValue("color"); IF str # NIL THEN Strings.HexStrToInt(str^, tempInt, res); cStyle.color := tempInt; END; str := ptr(XML.Element).GetAttributeValue("bgcolor"); IF str # NIL THEN Strings.HexStrToInt(str^, tempInt, res); cStyle.bgColor := tempInt; END; str := ptr(XML.Element).GetAttributeValue("tracking"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.tracking := FP1616.FloatToFixp(SHORT(tempReal)); END; str := ptr(XML.Element).GetAttributeValue("h-scale"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.scaleHorizontal := FP1616.FloatToFixp(SHORT(tempReal)); END; str := ptr(XML.Element).GetAttributeValue("v-scale"); IF str # NIL THEN Strings.StrToFloat(str^, tempReal); cStyle.scaleVertical := FP1616.FloatToFixp(SHORT(tempReal)); END; Texts.AddCharacterStyle(cStyle); END; END; END; END ImportCharacterStyles; PROCEDURE RemoveCHandler(sender, data: ANY); VAR i : LONGINT; BEGIN Texts.RemoveCharacterStyle(currentCStyle); cList.model.Acquire; i := 0; WHILE ((i