Browse Source

fixed issue --the text consisting of not Latin symbols is not scaled. The reason - is always used hardcoded not unicode font Vera/size
fixed issue -- not correctly attributes of the text changed. The reason - is used hardcoded font name and size
--Use default text attributes.
Texts.Mod - read default attributes from Configuration.XML. Exported var defaultAttributes- : Attributes;
Adapted modules for changes

git-svn-id: https://svn-dept.inf.ethz.ch/svn/lecturers/a2/trunk@8833 8c9fc860-2736-0410-a75d-ab315db34111

infsvn.durmanov 6 years ago
parent
commit
610df2a7de
5 changed files with 26 additions and 35 deletions
  1. 1 1
      source/SyntaxHighlighter.Mod
  2. 1 13
      source/TextUtilities.Mod
  3. 21 8
      source/Texts.Mod
  4. 1 6
      source/WMTextTool.Mod
  5. 2 7
      source/WMTextView.Mod

+ 1 - 1
source/SyntaxHighlighter.Mod

@@ -1955,7 +1955,7 @@ BEGIN
 	IF (style # NIL) & (style.attributes # NIL) THEN
 		attributes := style.attributes;
 	ELSE
-		attributes := TextUtilities.GetDefaultAttributes();
+		attributes := Texts.defaultAttributes;
 	END;
 	text.SetAttributes(0, text.GetLength(), attributes);
 

+ 1 - 13
source/TextUtilities.Mod

@@ -2564,20 +2564,8 @@ BEGIN
 END GetTextReader;
 
 PROCEDURE GetDefaultAttributes* () : Texts.Attributes;
-VAR
-	defaultAttributes 			: Texts.Attributes;
-	font 						: WMGraphics.Font;
-	textColor, textBackColor	: LONGINT;
-	res 						: WORD;
 BEGIN
-	NEW( defaultAttributes );
-	Configuration.GetColor( "WindowManager.ColorScheme.Default.TextBackColor", textBackColor, res );
-	IF res # Configuration.Ok THEN textBackColor := 0H; END; (* transparent *)
-	Configuration.GetColor( "WindowManager.ColorScheme.Default.TextColor", textColor, res );
-	IF res # Configuration.Ok THEN textColor := 0FFH; END; (* black *)
-	font := WMGraphics.GetDefaultFont( );
-	defaultAttributes.Set( textColor, textBackColor, 0, font.name, font.size, font.style );
-	RETURN defaultAttributes
+	RETURN Texts.defaultAttributes;
 END GetDefaultAttributes;
 
 BEGIN

+ 21 - 8
source/Texts.Mod

@@ -2,7 +2,7 @@ MODULE Texts;	(** AUTHOR "TF"; PURPOSE "Basic Unicode text system"; *)
 
 IMPORT
 	KernelLog, Streams, Kernel, WMEvents, Locks, Strings, FP1616, UTF8Strings,
-	XML, XMLParser, XMLScanner, XMLObjects, Files;
+	XML, XMLParser, XMLScanner, XMLObjects, Files, Configuration;
 
 CONST
 	OpInsert* = 0;
@@ -1229,6 +1229,7 @@ VAR
 	cStyles : CharacterStyleArray; nofCStyles : LONGINT;
 
 	forceUTF*, unforceUTF* : BOOLEAN;
+	defaultAttributes- : Attributes;
 
 (** Insert the given Paragraph Style into the Paragraph Style Array *)
 PROCEDURE AddParagraphStyle*(style: ParagraphStyle);
@@ -1487,15 +1488,26 @@ BEGIN {EXCLUSIVE}
 	RETURN lastText
 END GetLastText;
 
-(*! Moved to the TextUtilities
-PROCEDURE GetDefaultAttributes* () : Attributes;
-VAR defaultAttributes : Attributes;
+PROCEDURE GetDefaultAttributes ();
+VAR
+	res : WORD;
+	textColor := 0xFF, textBackColor := 0x00: LONGINT;
+	fontSize := 14: LONGINT;
+	fontName : ARRAY 256 OF CHAR;
 BEGIN
-	NEW(defaultAttributes);
-	defaultAttributes.Set(0FFH, 0H, 0, "Oberon", 10, {});
-	RETURN defaultAttributes
+	fontName := "Vera";
+	NEW( defaultAttributes );
+	Configuration.GetColor( "WindowManager.ColorScheme.Default.TextBackColor", textBackColor, res );
+(*	IF res # Configuration.Ok THEN textBackColor := 0H; END; (* transparent *)*)
+	Configuration.GetColor( "WindowManager.ColorScheme.Default.TextColor", textColor, res );
+(*	IF res # Configuration.Ok THEN textColor := 0FFH; END; (* black *) *)
+	Configuration.Get( "WindowManager.FontManager.DefaultFont.Name", fontName, res );
+(*	IF res # Configuration.Ok THEN fontName := "Vera"; END;*)
+	Configuration.GetInteger( "WindowManager.FontManager.DefaultFont.Size", fontSize, res );
+(*	IF res # Configuration.Ok THEN fontSize := 14; END;*)
+	defaultAttributes.Set( textColor, textBackColor, 0, fontName, fontSize, {} );
 END GetDefaultAttributes;
-*)
+
 BEGIN
 	NEW(pStyles, 4); nofPStyles := 0;
 	NEW(cStyles, 4); nofCStyles := 0;
@@ -1509,5 +1521,6 @@ BEGIN
 
 	forceUTF := FALSE;
 	unforceUTF := TRUE;
+	GetDefaultAttributes;
 END Texts.
 

+ 1 - 6
source/WMTextTool.Mod

@@ -552,12 +552,7 @@ END GetNewSize;
 PROCEDURE EnsureAttribute(VAR attr : Texts.Attributes);
 BEGIN
 	IF (attr = NIL) THEN
-		NEW(attr); NEW(attr.fontInfo);
-		attr.fontInfo.name := "Oberon";
-		attr.fontInfo.size := 10;
-		attr.fontInfo.style := {};
-		attr.color := 0000000FFH;
-		attr.bgcolor := 000000000H;
+		attr := Texts.defaultAttributes;
 	END
 END EnsureAttribute;
 

+ 2 - 7
source/WMTextView.Mod

@@ -4233,13 +4233,8 @@ END DZ;
 PROCEDURE EnsureAttribute(VAR attr : Texts.Attributes);
 BEGIN
 	IF (attr = NIL) THEN
-		NEW(attr); NEW(attr.fontInfo);
-		attr.fontInfo.name := "Vera";
-		attr.fontInfo.size := 16;
-		attr.fontInfo.style := {};
-		attr.color := 0000000FFH;
-		attr.bgcolor := 000000000H;
-	END
+		attr := Texts.defaultAttributes;
+	END;
 END EnsureAttribute;
 
 PROCEDURE ChangeAttribute(VAR attr : Texts.Attributes; userData : ANY);