Browse Source

* unicode conversion of the msgbox unit implementation, as well as the FormatStr function

git-svn-id: branches/unicodekvm@48613 -
nickysn 4 years ago
parent
commit
25cf57b085
2 changed files with 34 additions and 12 deletions
  1. 23 5
      packages/fv/src/drivers.inc
  2. 11 7
      packages/fv/src/msgbox.inc

+ 23 - 5
packages/fv/src/drivers.inc

@@ -581,7 +581,7 @@ specifiers and a list of parameters in Params, FormatStr produces a
 formatted output string in Result.
 18Feb99 LdB
 ---------------------------------------------------------------------}
-PROCEDURE FormatStr (Var Result: String; CONST Format: String; Var Params);
+PROCEDURE FormatStr (Var Result: Sw_String; CONST Format: Sw_String; Var Params);
 
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {                 >> NEW QUEUED EVENT HANDLER ROUTINES <<                   }
@@ -1553,17 +1553,17 @@ END;
 {---------------------------------------------------------------------------}
 {  FormatStr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 13Jul99 LdB         }
 {---------------------------------------------------------------------------}
-procedure FormatStr (Var Result: String; CONST Format: String; Var Params);
+procedure FormatStr (Var Result: Sw_String; CONST Format: Sw_String; Var Params);
 TYPE TLongArray = Array[0..0] Of PtrInt;
 VAR W, ResultLength : SmallInt;
     FormatIndex, Justify, Wth: Byte;
-    Fill: Char; S: String;
+    Fill: Char; S: Sw_String;
 
-   FUNCTION LongToStr (L: Longint; Radix: Byte): String;
+   FUNCTION LongToStr (L: Longint; Radix: Byte): Sw_String;
    CONST HexChars: Array[0..15] Of Char =
     ('0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
-   VAR I: LongInt; S: String; Sign: String[1];
+   VAR I: LongInt; S: Sw_String; Sign: String[1];
    begin
      LongToStr := '';                                 { Preset empty return }
      If (L < 0) Then begin                            { If L is negative }
@@ -1582,11 +1582,16 @@ VAR W, ResultLength : SmallInt;
    procedure HandleParameter (I : LongInt);
    begin
      While (FormatIndex <= Length(Format)) Do begin   { While length valid }
+{$ifndef FV_UNICODE}
        if ResultLength>=High(Result) then
          exit;
+{$endif FV_UNICODE}
        While (FormatIndex <= Length(Format)) and
              (Format[FormatIndex] <> '%')          { Param char not found }
         Do begin
+{$ifdef FV_UNICODE}
+         SetLength(Result,ResultLength+1);
+{$endif FV_UNICODE}
          Result[ResultLength+1] := Format[FormatIndex]; { Transfer character }
          Inc(ResultLength);                           { One character added }
          Inc(FormatIndex);                            { Next param char }
@@ -1620,7 +1625,12 @@ VAR W, ResultLength : SmallInt;
            '%': begin                               { Literal % }
              S := '%';
              Inc(FormatIndex);
+{$ifdef FV_UNICODE}
+             SetLength(Result,ResultLength+Length(S));
+             Move(S[1], Result[ResultLength+1], 2);
+{$else FV_UNICODE}
              Move(S[1], Result[ResultLength+1], 1);
+{$endif FV_UNICODE}
              Inc(ResultLength,Length(S));
              Continue;
            end;
@@ -1646,10 +1656,16 @@ VAR W, ResultLength : SmallInt;
              end;
            end;
            W:=Length(S);
+{$ifdef FV_UNICODE}
+           SetLength(Result,ResultLength+W);
+           Move(S[1], Result[ResultLength+1],
+             2*W);                                    { Move data to result }
+{$else FV_UNICODE}
            if W+ResultLength+1>High(Result) then
              W:=High(Result)-ResultLength;
            Move(S[1], Result[ResultLength+1],
              W);                                      { Move data to result }
+{$endif FV_UNICODE}
            Inc(ResultLength,W);                       { Adj result length }
            Inc(I);
          end;
@@ -1661,7 +1677,9 @@ begin
    ResultLength := 0;                                 { Zero result length }
    FormatIndex := 1;                                  { Format index to 1 }
    HandleParameter(0);                                { Handle parameter }
+{$ifndef FV_UNICODE}
    Result[0] := Chr(ResultLength);                    { Set string length }
+{$endif FV_UNICODE}
 end;
 
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

+ 11 - 7
packages/fv/src/msgbox.inc

@@ -195,7 +195,11 @@ const
   Commands: array[0..3] of word =
     (cmYes, cmNo, cmOK, cmCancel);
 var
+{$ifdef FV_UNICODE}
+  ButtonName: array[0..3] of Sw_String;
+{$else FV_UNICODE}
   ButtonName: array[0..3] of string[40];
+{$endif FV_UNICODE}
 
 resourcestring  sConfirm='Confirm';
                 sError='Error';
@@ -206,7 +210,7 @@ resourcestring  sConfirm='Confirm';
 {---------------------------------------------------------------------------}
 {  MessageBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB        }
 {---------------------------------------------------------------------------}
-FUNCTION MessageBox(Const Msg: String; Params: Pointer; AOptions: Word): Word;
+FUNCTION MessageBox(Const Msg: Sw_String; Params: Pointer; AOptions: Word): Word;
 VAR R: TRect;
 BEGIN
    R.Assign(0, 0, 40, 9);                             { Assign area }
@@ -219,9 +223,9 @@ BEGIN
      AOptions);                                       { Create message box }
 END;
 
-FUNCTION MessageBoxRectDlg (Dlg: PDialog; Var R: TRect; Const Msg: String;
+FUNCTION MessageBoxRectDlg (Dlg: PDialog; Var R: TRect; Const Msg: Sw_String;
   Params: Pointer; AOptions: Word): Word;
-VAR I, X, ButtonCount: SmallInt; S: String; Control: PView;
+VAR I, X, ButtonCount: SmallInt; S: Sw_String; Control: PView;
     ButtonList: Array[0..4] Of PView;
 BEGIN
    With Dlg^ Do Begin
@@ -258,7 +262,7 @@ end;
 {---------------------------------------------------------------------------}
 {  MessageBoxRect -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB    }
 {---------------------------------------------------------------------------}
-FUNCTION MessageBoxRect(Var R: TRect; Const Msg: String; Params: Pointer;
+FUNCTION MessageBoxRect(Var R: TRect; Const Msg: Sw_String; Params: Pointer;
   AOptions: Word): Word;
 var
   Dialog: PDialog;
@@ -274,7 +278,7 @@ END;
 {---------------------------------------------------------------------------}
 {  InputBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB          }
 {---------------------------------------------------------------------------}
-FUNCTION InputBox(Const Title, ALabel: String; Var S: String;
+FUNCTION InputBox(Const Title, ALabel: Sw_String; Var S: Sw_String;
   Limit: Byte): Word;
 VAR R: TRect;
 BEGIN
@@ -288,8 +292,8 @@ END;
 {---------------------------------------------------------------------------}
 {  InputBoxRect -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB      }
 {---------------------------------------------------------------------------}
-FUNCTION InputBoxRect(Var Bounds: TRect; Const Title, ALabel: String;
-  Var S: String; Limit: Byte): Word;
+FUNCTION InputBoxRect(Var Bounds: TRect; Const Title, ALabel: Sw_String;
+  Var S: Sw_String; Limit: Byte): Word;
 VAR C: Word; R: TRect; Control: PView; Dialog: PDialog;
 BEGIN
    Dialog := New(PDialog, Init(Bounds, Title));       { Create dialog }