Update of /cvsroot/lngcompiler/lngcompiler
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9878/lngcompiler
Modified Files:
LngForm.dfm LngForm.pas
Log Message:
new section - NAMES - can be edited (but not compiled in)
Index: LngForm.dfm
===================================================================
RCS file: /cvsroot/lngcompiler/lngcompiler/LngForm.dfm,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** LngForm.dfm 28 Feb 2005 08:24:02 -0000 1.12
--- LngForm.dfm 28 Feb 2005 11:55:16 -0000 1.13
***************
*** 479,484 ****
ColCount = 3
FixedCols = 0
! Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing]
TabOrder = 0
ColWidths = (
140
--- 479,486 ----
ColCount = 3
FixedCols = 0
! Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goThumbTracking]
TabOrder = 0
+ OnDrawCell = gNamesDrawCell
+ OnSetEditText = gNamesSetEditText
ColWidths = (
140
***************
*** 498,513 ****
Left = 80
Top = 8
! Width = 105
Height = 25
! Caption = '&Add'
TabOrder = 0
! end
! object bDelName: TButton
! Left = 296
! Top = 8
! Width = 99
! Height = 25
! Caption = '&Delete'
! TabOrder = 1
end
end
--- 500,508 ----
Left = 80
Top = 8
! Width = 129
Height = 25
! Caption = '&New ID'
TabOrder = 0
! OnClick = bAddNameClick
end
end
Index: LngForm.pas
===================================================================
RCS file: /cvsroot/lngcompiler/lngcompiler/LngForm.pas,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** LngForm.pas 28 Feb 2005 08:24:02 -0000 1.18
--- LngForm.pas 28 Feb 2005 11:55:16 -0000 1.19
***************
*** 241,245 ****
pnNameButtons: TPanel;
bAddName: TButton;
- bDelName: TButton;
procedure Exit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
--- 241,244 ----
***************
*** 273,276 ****
--- 272,280 ----
procedure Savechanges1Click(Sender: TObject);
procedure pnNameButtonsResize(Sender: TObject);
+ procedure gNamesDrawCell(Sender: TObject; ACol, ARow: Integer;
+ RR: TRect; State: TGridDrawState);
+ procedure gNamesSetEditText(Sender: TObject; ACol, ARow: Integer;
+ const Value: String);
+ procedure bAddNameClick(Sender: TObject);
private
procedure Decompile;
***************
*** 278,281 ****
--- 282,286 ----
procedure WMFillForm(var M: TMessage); message WM_User + 78;
public
+ fConvertIds: Boolean;
DefDC: THandle;
dBmp: TBitmap;
***************
*** 292,295 ****
--- 297,301 ----
CurNames: TNamedStrIndex;
ShadowForm: TList;
+ NamesModified: Boolean;
procedure FillLanguage;
procedure FillForm;
***************
*** 1033,1036 ****
--- 1039,1043 ----
begin
+ I := 0;
F := GetNameRec;
repeat
***************
*** 1049,1058 ****
if T.ID = tidString then
begin
! if F.Names.IndexOfName(CP, True) >= 0 then
! begin
! F.Names.Add(CP, T.S, '');
! end else
! // Line numbers should start from "1", not from "0" (hence, "+1")
! Errors.Add(Format('Line %5.5d: ERROR: duplicate identifier "%s"', [LLine+1, CP]));
end else
// Line numbers should start from "1", not from "0" (hence, "+1")
--- 1056,1060 ----
if T.ID = tidString then
begin
! F.Names.Add(CP, T.S, '');
end else
// Line numbers should start from "1", not from "0" (hence, "+1")
***************
*** 1143,1147 ****
ctNames:
begin
! Errors.Add(Format('Line %5.5d: WARNING: the %s is not closed before the STRINGS definition', [aLine+1, Msg]));
AnalyzeTokens;
Collecting := 3;
--- 1145,1149 ----
ctNames:
begin
! Errors.Add(Format('Line %5.5d: WARNING: the %s is not closed before the NAMES definition', [aLine+1, Msg]));
AnalyzeTokens;
Collecting := 3;
***************
*** 1540,1544 ****
gNames.Rows[0][1] := 'English';
gNames.Rows[0][2] := 'National';
!
end;
--- 1542,1546 ----
gNames.Rows[0][1] := 'English';
gNames.Rows[0][2] := 'National';
! NamesModified := False;
end;
***************
*** 1962,1965 ****
--- 1964,1968 ----
eLngFile.Text := F.ReadString('Project', 'Language ID file', eLngFile.Text);
eLngFile.Text := F.ReadString('Project', 'Strings IDs file', eLngFile.Text);
+ fConvertIds := F.ReadBool('Project', 'Convert Names', False);
I := 1;
repeat
***************
*** 1970,1973 ****
--- 1973,1978 ----
for I := 0 to gStrings.ColCount-1 do
gStrings.ColWidths[I] := F.ReadInteger('Columns', Format('Strings #%d', [I+1]), gStrings.ColWidths[I]);
+ for I := 0 to gNames.ColCount-1 do
+ gNames.ColWidths[I] := F.ReadInteger('Columns', Format('Names #%d', [I+1]), gNames.ColWidths[I]);
N := F.ReadInteger('Language', 'Count', 0);
for I := 1 to N do
***************
*** 2029,2032 ****
--- 2034,2039 ----
for I := 0 to gStrings.ColCount-1 do
F.WriteInteger('Columns', Format('Strings #%d', [I+1]), gStrings.ColWidths[I]);
+ for I := 0 to gNames.ColCount-1 do
+ F.WriteInteger('Columns', Format('Names #%d', [I+1]), gNames.ColWidths[I]);
N := 0;
***************
*** 2381,2384 ****
--- 2388,2392 ----
LI, LLI: TLngString;
XX: Boolean;
+ NS, S, SS: String;
begin
OL := nil;
***************
*** 2390,2394 ****
begin
CF := CurLng[I];
! if (CF.Name = '') and (CF.Strings <> nil) then
begin
if XX then
--- 2398,2423 ----
begin
CF := CurLng[I];
! if (CF.Name = '') then
! begin
! if (CF.Names <> nil) then
! begin
! if NamesModified then
! begin
! CF.Names.Clear;
! for J := 1 to gNames.RowCount-1 do
! begin
! NS := Trim(gNames.Rows[J][0]);
! if NS <> '' then
! begin
! SS := gNames.Rows[J][2];
! if SS <> '' then
! CF.Names.Add(NS, SS, '');
! end;
! end;
! CF.Modified := True;
! NamesModified := False;
! end;
! end else
! if (CF.Strings <> nil) then
begin
if XX then
***************
*** 2428,2431 ****
--- 2457,2461 ----
end else FreeList(CF.Strings);
end;
+ end;
end;
finally
***************
*** 2506,2510 ****
var B: Boolean;
begin
! B := (pcBook.ActivePage = tsForms) or (pcBook.ActivePage = tsStrings);
mnNext.Enabled := B;
mnPrev.Enabled := B;
--- 2536,2540 ----
var B: Boolean;
begin
! B := (pcBook.ActivePage = tsForms) or (pcBook.ActivePage = tsStrings) or (pcBook.ActivePage = tsNames);
mnNext.Enabled := B;
mnPrev.Enabled := B;
***************
*** 2524,2535 ****
procedure TForm1.mnNextClick(Sender: TObject);
label 1;
! var {I,} _RStep, {_CStep,} _F, _R, _C, CI, CR, CC: Integer;
! Reverse: Boolean;
S: String;
begin
Reverse := TComponent(Sender).Tag < 0;
if Reverse then _RStep := -1
else _RStep := 1;
if pcBook.ActivePage = tsForms then
begin
--- 2554,2604 ----
procedure TForm1.mnNextClick(Sender: TObject);
label 1;
! var I, _RStep, {_CStep,} _F, _R, _C, CI, CR, CC: Integer;
! Reverse, OK: Boolean;
S: String;
+ function NameNotTranslated(Idx: Integer): Boolean;
+ var
+ I: Integer;
+ S, SS: String;
+ begin
+ S := gNames.Rows[Idx][2];
+ SS := gNames.Rows[Idx][1];
+ Result := (S = '') or (SS = S);
+ if Result then
+ begin
+ gNames.Row := Idx;
+ gNames.Invalidate;
+ OK := False;
+ end;
+ end;
+
+
+
begin
Reverse := TComponent(Sender).Tag < 0;
if Reverse then _RStep := -1
else _RStep := 1;
+ if pcBook.ActivePage = tsNames then
+ begin
+ OK := true;
+ if Reverse then
+ begin
+ for I := gNames.Row-1 downto 1 do
+ if NameNotTranslated(I) then Break;
+ if OK then
+ for I := gNames.RowCount-1 downto gNames.Row do
+ if NameNotTranslated(I) then Break;
+ end else
+ begin
+ for I := gNames.Row+1 to gNames.RowCount-1 do
+ if NameNotTranslated(I) then Break;
+ if OK then
+ for I := 1 to gNames.Row do
+ if NameNotTranslated(I) then Break;
+ end;
+ if OK then
+ MessageDlg('It seems like all items are translated...', mtInformation, [mbOk], 0);
+ end else
if pcBook.ActivePage = tsForms then
begin
***************
*** 2752,2756 ****
begin
LF := L[J];
! if (LF.Modified) then
begin
S := GetLng(L.LngID);
--- 2821,2825 ----
begin
LF := L[J];
! if (LF.Modified) or NamesModified then
begin
S := GetLng(L.LngID);
***************
*** 3006,3014 ****
X, Y: Integer;
begin
! X := pnNameButtons.Width div 2;
Y := (X - bAddName.Width) div 2;
if Y < 0 then Y := 0;
bAddName.Left := Y;
! bDelName.Left := X + Y;
end;
--- 3075,3151 ----
X, Y: Integer;
begin
! X := pnNameButtons.Width;// div 2;
Y := (X - bAddName.Width) div 2;
if Y < 0 then Y := 0;
bAddName.Left := Y;
! //bDelName.Left := X + Y;
! end;
!
! procedure TForm1.gNamesDrawCell(Sender: TObject; ACol, ARow: Integer;
! RR: TRect; State: TGridDrawState);
! var SS: Array[0..2] of String;
! BC, TC: TColor;
! S: String;
! R, R1: TRect;
! begin
! SS[0] := gNames.Rows[ARow][0];
! SS[1] := gNames.Rows[ARow][1];
! SS[2] := gNames.Rows[ARow][2];
! R := Rect(0,0,RR.Right-RR.Left,RR.Bottom-RR.Top);
! if dBmp.Width < R.Right then dBmp.Width := R.Right;
! if dBmp.Height < R.Bottom then dBmp.Height := R.Bottom;
! if ((SS[2] = '') or (SS[1] = SS[2])) and (State = []) then
! begin
! BC := clYellow;
! TC := clBlack;
! end else
! begin
! if gdSelected in State then
! begin
! BC := clHighlight;
! TC := clHighlightText;
! end else
! if gdFixed in State then
! begin
! BC := clBtnFace;
! TC := clBtnText;
! end else
! begin
! BC := clWindow;
! TC := clWindowText;
! end;
! end;
! with dBmp.Canvas do
! begin
! //InflateRect(Rect, 1, 1);
! Font.Assign(gStrings.Font);
!
! Brush.Color := BC;
! FillRect(R);
!
! Font.Color := TC;
!
! S := SS[ACol];
! if StrScan(PChar(S), #13) <> nil then
! S := AdjustLineBreaks(S);
!
! R1 := R;
! InflateRect(R1, -1, -1);
! DrawText(Handle, PChar(S), Length(S), R1, DT_NOPREFIX or DT_END_ELLIPSIS);
! end;
! gNames.Canvas.CopyRect(RR, dBmp.Canvas, R);
! end;
!
! procedure TForm1.gNamesSetEditText(Sender: TObject; ACol, ARow: Integer;
! const Value: String);
! begin
! gNames.Invalidate;
! NamesModified := True;
! end;
!
! procedure TForm1.bAddNameClick(Sender: TObject);
! begin
! gNames.RowCount := gNames.RowCount+1;
! gNames.Row := gNames.RowCount-1;
end;
|