浏览代码

WMClock localized for russian and ukrainian languages; WMClockImages.tar replaced by WMClock.rep;
Bug in WMPopups fixed: size of popup was determined incorrectly if strings in format "::Repository:Dictionary:Word" provided

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

infsvn.sage 6 年之前
父节点
当前提交
ac33e525fe
共有 5 个文件被更改,包括 42 次插入10 次删除
  1. 1 1
      source/Release.Tool
  2. 7 7
      source/WMClock.Mod
  3. 二进制
      source/WMClock.rep
  4. 二进制
      source/WMClockImages.tar
  5. 34 2
      source/WMPopups.Mod

+ 1 - 1
source/Release.Tool

@@ -1180,7 +1180,7 @@ PACKAGE GuiApplicationsMini ARCHIVE "GuiApplicationsMini.zip" SOURCE "GuiApplica
 	WMPerfMon.Mod WMPerfMon.Text
 
 	WMClock.Mod
-	WMClockImages.tar
+	WMClock.rep
 	WMCalendar.Mod
 
 	WMV24Component.Mod

+ 7 - 7
source/WMClock.Mod

@@ -124,12 +124,12 @@ TYPE
 				resizing := TRUE;
 			ELSIF keys = {2} THEN
 				NEW(contextMenu);
-				contextMenu.Add("Close", HandleClose);
-				contextMenu.AddParButton("Time", HandleToggleView, contextMenuParStandard);
-				contextMenu.AddParButton("Date", HandleToggleView, contextMenuParDateTime);
-				contextMenu.AddParButton("Day of Week", HandleToggleView, contextMenuParDayOfWeek);
-				contextMenu.AddParButton("Analog", HandleToggleView, contextMenuParAnalog);
-				contextMenu.AddParButton("Toggle Color", HandleToggleColor, NIL);
+				contextMenu.Add("::WMClock:ClockMenu:SClose", HandleClose);
+				contextMenu.AddParButton("::WMClock:ClockMenu:STime", HandleToggleView, contextMenuParStandard);
+				contextMenu.AddParButton("::WMClock:ClockMenu:SDate", HandleToggleView, contextMenuParDateTime);
+				contextMenu.AddParButton("::WMClock:ClockMenu:SDayOfWeek", HandleToggleView, contextMenuParDayOfWeek);
+				contextMenu.AddParButton("::WMClock:ClockMenu:SAnalog", HandleToggleView, contextMenuParAnalog);
+				contextMenu.AddParButton("::WMClock:ClockMenu:SToggleColor", HandleToggleColor, NIL);
 				contextMenu.Popup(bounds.l + x, bounds.t + y)
 			END
 		END PointerDown;
@@ -429,7 +429,7 @@ BEGIN
 
 	(* AnalogClock *)
 	NEW(PrototypeImageName, NIL, Strings.NewString("ImageName"), Strings.NewString("Clock face image name"));
-	PrototypeImageName.SetAOC("WMClockImages.tar://roman_numeral_wall_clock.png");
+	PrototypeImageName.SetAOC("WMClock.rep://images/roman_numeral_wall_clock.png");
 	NEW(PrototypeTimeOffset, NIL, Strings.NewString("TimeOffset"), Strings.NewString("Time offset in hours"));
 	PrototypeTimeOffset.Set(0);
 	NEW(PrototypeSecondHandLength, NIL, Strings.NewString("SecondHandLength"), Strings.NewString("Length of second hand in percent of radius"));

二进制
source/WMClock.rep


二进制
source/WMClockImages.tar


+ 34 - 2
source/WMPopups.Mod

@@ -1,7 +1,8 @@
 MODULE WMPopups;	(** AUTHOR "BF"; PURPOSE "Popup Windows"; *)
 
 IMPORT
-	Strings, WMRectangles, WMGraphics, WMEvents, WMWindowManager, WMComponents, WMStandardComponents;
+	Strings, WMRectangles, WMGraphics, WMEvents, WMWindowManager, WMComponents, WMStandardComponents,
+	Localization, Repositories;
 
 CONST
 
@@ -32,6 +33,7 @@ TYPE
 	PopupWindow = OBJECT(WMComponents.FormWindow)
 	VAR
 		isClosed : BOOLEAN;
+		languages : Localization.Languages;
 
 		PROCEDURE &New(entries : Entry);
 		VAR vc : WMComponents.VisualComponent;
@@ -42,6 +44,26 @@ TYPE
 			SetContent(vc);
 			isClosed := FALSE;
 		END New;
+		
+		PROCEDURE Translate(value: Strings.String): Strings.String;
+		VAR
+			res : WORD;
+			temp, word : Strings.String;
+			dictionary : Repositories.Dictionary;
+		BEGIN
+			IF (value # NIL) & (LEN(value^) > 4) & (value^[0] = ':') & (value^[1] = ':') THEN
+				(** If string needs translation. E.g. has prefix that points to repository and dictionary	at least:
+					::<Repository name>:<Dictionary name>: **)
+				Repositories.GetTranslationInfo(value^, dictionary, word, res);
+				IF (dictionary # NIL) & (word # NIL) THEN
+					temp := dictionary.Translate(word, languages);
+					IF (temp # word) THEN
+						RETURN temp
+					END
+				END
+			END;
+			RETURN NIL
+		END Translate;
 
 		PROCEDURE CreateForm(entries : Entry) : WMComponents.VisualComponent;
 		VAR
@@ -50,9 +72,12 @@ TYPE
 			font : WMGraphics.Font;
 			entry : Entry;
 			width, height, w, h : LONGINT;
+			temp : Strings.String;
 		BEGIN
 			NEW(panel);
 			panel.fillColor.Set(WMGraphics.White);
+			
+			languages := Localization.GetLanguagePreferences();
 
 			width := 100; height := 0;
 
@@ -68,7 +93,14 @@ TYPE
 				panel.AddInternalComponent(button);
 
 				font := button.GetFont();
-				font.GetStringSize(entry.caption^, w, h);
+				
+				temp := Translate(entry.caption);
+				IF temp # NIL THEN
+					font.GetStringSize(temp^, w, h);
+				ELSE
+					font.GetStringSize(entry.caption^, w, h);
+				END;
+				
 				IF (w + 10 > width) THEN
 					width := w + 10;
 				END;