Browse Source

Unicode Free Vision.

Margers 1 month ago
parent
commit
523c2c206a

+ 86 - 6
packages/fv/src/asciitab.inc

@@ -24,7 +24,11 @@
 {                                                          }
 {                                                          }
 
 
 {$IFNDEF FPC_DOTTEDUNITS}
 {$IFNDEF FPC_DOTTEDUNITS}
+{$ifdef FV_UNICODE}
+UNIT UAsciiTab;
+{$else FV_UNICODE}
 UNIT AsciiTab;
 UNIT AsciiTab;
+{$endif FV_UNICODE}
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
@@ -47,9 +51,21 @@ UNIT AsciiTab;
 {====================================================================}
 {====================================================================}
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
-USES FreeVision.Fvconsts, System.Objects, FreeVision.Drivers, FreeVision.Views, FreeVision.App;      { Standard GFV units }
+USES System.Objects,
+   {$ifdef FV_UNICODE}
+   FreeVision.Ufvcommon,FreeVision.Udrivers,FreeVision.Uviews,FreeVision.Uapp,
+   {$else}
+   FreeVision.Fvcommon,FreeVision.Drivers,FreeVision.Views, FreeVision.App,
+   {$endif}
+   FreeVision.Fvconsts,System.Console.Video;
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
-USES FVConsts, Objects, Drivers, Views, App;      { Standard GFV units }
+USES Objects,
+    {$ifdef FV_UNICODE}
+    UFvcommon, UDrivers, UViews, UApp,
+    {$else}
+    Fvcommon, Drivers, Views, App,          { Standard GFV units }
+    {$endif}
+    FVConsts,Video;
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {***************************************************************************}
 {***************************************************************************}
@@ -76,6 +92,7 @@ type
   PReport = ^TReport;
   PReport = ^TReport;
   TReport = object(TView)
   TReport = object(TView)
     ASCIIChar: LongInt;
     ASCIIChar: LongInt;
+    constructor Init (Var Bounds: TRect);
     constructor Load(var S: TStream);
     constructor Load(var S: TStream);
     procedure Draw; virtual;
     procedure Draw; virtual;
     procedure HandleEvent(var Event:TEvent); virtual;
     procedure HandleEvent(var Event:TEvent); virtual;
@@ -145,6 +162,26 @@ procedure RegisterASCIITab;
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {                          TTable OBJECT METHODS                            }
 {                          TTable OBJECT METHODS                            }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
+{$ifdef FV_UNICODE}
+const cAsciiTable : array[0..255] of WideChar = ( { cp437, except for NUL char }
+  #$0020, #$263A, #$263B, #$2665, #$2666, #$2663, #$2660, #$2022, #$25D8, #$25CB, #$25D9, #$2642, #$2640, #$266A, #$266B, #$263C
+, #$25BA, #$25C4, #$2195, #$203C, #$00B6, #$00A7, #$25AC, #$21A8, #$2191, #$2193, #$2192, #$2190, #$221F, #$2194, #$25B2, #$25BC
+, #$0020, #$0021, #$0022, #$0023, #$0024, #$0025, #$0026, #$0027, #$0028, #$0029, #$002A, #$002B, #$002C, #$002D, #$002E, #$002F
+, #$0030, #$0031, #$0032, #$0033, #$0034, #$0035, #$0036, #$0037, #$0038, #$0039, #$003A, #$003B, #$003C, #$003D, #$003E, #$003F
+, #$0040, #$0041, #$0042, #$0043, #$0044, #$0045, #$0046, #$0047, #$0048, #$0049, #$004A, #$004B, #$004C, #$004D, #$004E, #$004F
+, #$0050, #$0051, #$0052, #$0053, #$0054, #$0055, #$0056, #$0057, #$0058, #$0059, #$005A, #$005B, #$005C, #$005D, #$005E, #$005F
+, #$0060, #$0061, #$0062, #$0063, #$0064, #$0065, #$0066, #$0067, #$0068, #$0069, #$006A, #$006B, #$006C, #$006D, #$006E, #$006F
+, #$0070, #$0071, #$0072, #$0073, #$0074, #$0075, #$0076, #$0077, #$0078, #$0079, #$007A, #$007B, #$007C, #$007D, #$007E, #$2302 {#$007F is not displayable put #$2302}
+, #$00C7, #$00FC, #$00E9, #$00E2, #$00E4, #$00E0, #$00E5, #$00E7, #$00EA, #$00EB, #$00E8, #$00EF, #$00EE, #$00EC, #$00C4, #$00C5
+, #$00C9, #$00E6, #$00C6, #$00F4, #$00F6, #$00F2, #$00FB, #$00F9, #$00FF, #$00D6, #$00DC, #$00A2, #$00A3, #$00A5, #$20A7, #$0192
+, #$00E1, #$00ED, #$00F3, #$00FA, #$00F1, #$00D1, #$00AA, #$00BA, #$00BF, #$2310, #$00AC, #$00BD, #$00BC, #$00A1, #$00AB, #$00BB
+, #$2591, #$2592, #$2593, #$2502, #$2524, #$2561, #$2562, #$2556, #$2555, #$2563, #$2551, #$2557, #$255D, #$255C, #$255B, #$2510
+, #$2514, #$2534, #$252C, #$251C, #$2500, #$253C, #$255E, #$255F, #$255A, #$2554, #$2569, #$2566, #$2560, #$2550, #$256C, #$2567
+, #$2568, #$2564, #$2565, #$2559, #$2558, #$2552, #$2553, #$256B, #$256A, #$2518, #$250C, #$2588, #$2584, #$258C, #$2590, #$2580
+, #$03B1, #$00DF, #$0393, #$03C0, #$03A3, #$03C3, #$00B5, #$03C4, #$03A6, #$0398, #$03A9, #$03B4, #$221E, #$03C6, #$03B5, #$2229
+, #$2261, #$00B1, #$2265, #$2264, #$2320, #$2321, #$00F7, #$2248, #$00B0, #$2219, #$00B7, #$221A, #$207F, #$00B2, #$25A0, #$00A0
+);
+{$endif}
 
 
 procedure TTable.Draw;
 procedure TTable.Draw;
 var
 var
@@ -155,7 +192,14 @@ begin
   NormColor:=GetColor(1);
   NormColor:=GetColor(1);
   For y:=0 to size.Y-1 do begin
   For y:=0 to size.Y-1 do begin
     For x:=0 to size.X-1 do
     For x:=0 to size.X-1 do
+{$ifdef FV_UNICODE}
+      begin
+        B[x].Attribute:=NormColor;
+        B[x].ExtendedGraphemeCluster:=cAsciiTable[(y*Size.X+x) and $ff];
+      end;
+{$else}
       B[x]:=(NormColor shl 8) or ((y*Size.X+x) and $ff);
       B[x]:=(NormColor shl 8) or ((y*Size.X+x) and $ff);
+{$endif}
     WriteLine(0,Y,Size.X,1,B);
     WriteLine(0,Y,Size.X,1,B);
   end;
   end;
   DrawCurPos(true);
   DrawCurPos(true);
@@ -164,13 +208,22 @@ end;
 procedure TTable.DrawCurPos(enable : boolean);
 procedure TTable.DrawCurPos(enable : boolean);
 var
 var
   Color : byte;
   Color : byte;
+{$ifdef FV_UNICODE}
+  B : TEnhancedVideoCell;
+{$else}
   B : word;
   B : word;
+{$endif}
 begin
 begin
   Color:=GetColor(1);
   Color:=GetColor(1);
   { add blinking if enable }
   { add blinking if enable }
   If Enable then
   If Enable then
     Color:=((Color and $F) shl 4) or (Color shr 4);
     Color:=((Color and $F) shl 4) or (Color shr 4);
+{$ifdef FV_UNICODE}
+  B.Attribute:=Color;
+  B.ExtendedGraphemeCluster:=cAsciiTable[(Cursor.Y*Size.X+Cursor.X) and $ff];
+{$else}
   B:=(Color shl 8) or ((Cursor.Y*Size.X+Cursor.X) and $ff);
   B:=(Color shl 8) or ((Cursor.Y*Size.X+Cursor.X) and $ff);
+{$endif}
   WriteLine(Cursor.X,Cursor.Y,1,1,B);
   WriteLine(Cursor.X,Cursor.Y,1,1,B);
 end;
 end;
 
 
@@ -183,7 +236,11 @@ var
   var
   var
     newchar : ptrint;
     newchar : ptrint;
   begin
   begin
+{$ifdef FV_UNICODE}
+    newchar:=ptrint(cAsciiTable[(ypos*size.X+xpos) and $ff]);
+{$else}
     newchar:=(ypos*size.X+xpos) and $ff;
     newchar:=(ypos*size.X+xpos) and $ff;
+{$endif}
     DrawCurPos(false);
     DrawCurPos(false);
     SetCursor(xpos,ypos);
     SetCursor(xpos,ypos);
     Message(Owner,evCommand,AsciiTableCommandBase,
     Message(Owner,evCommand,AsciiTableCommandBase,
@@ -236,6 +293,18 @@ end;
 {                        TReport OBJECT METHODS                             }
 {                        TReport OBJECT METHODS                             }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 
 
+
+constructor TReport.Init (Var Bounds: TRect);
+begin
+  Inherited Init (Bounds);
+{$ifdef FV_UNICODE}
+  AsciiChar:=longint(cAsciiTable[0]);
+{$else}
+  AsciiChar:=0;
+{$endif}
+end;
+
+
 constructor TReport.Load(var S: TStream);
 constructor TReport.Load(var S: TStream);
 begin
 begin
   Inherited Load(S);
   Inherited Load(S);
@@ -244,16 +313,27 @@ end;
 
 
 procedure TReport.Draw;
 procedure TReport.Draw;
   var
   var
-    stHex,stDec : string[3];
-    s : string;
+    stHex,stDec : string[5];
+    s : sw_string;
 begin
 begin
   Str(AsciiChar,StDec);
   Str(AsciiChar,StDec);
   while length(stDec)<3 do
   while length(stDec)<3 do
     stDec:=' '+stDec;
     stDec:=' '+stDec;
+{$ifdef FV_UNICODE}
+  if length(stDec)<4 then
+    stDec:=' '+stDec;
+  if length(stDec)<5 then
+    stDec:=stDec+' ';
+  stHex:=hexstr(AsciiChar,4);
+  s:='WChar "'+widechar(Word(AsciiChar))+'" Decimal:'+
+     StDec+'Hex:$'+StHex+
+     ''; // //{!ss:fill gap. FormatStr function using be better}
+{$else}
   stHex:=hexstr(AsciiChar,2);
   stHex:=hexstr(AsciiChar,2);
-  s:='AnsiChar "'+chr(AsciiChar)+'" Decimal: '+
-     StDec+' Hex: $'+StHex+
+  s:='AnsiChar "'+chr(AsciiChar)+'" Decimal:'+
+     StDec+' Hex:$'+StHex+
      '  '; // //{!ss:fill gap. FormatStr function using be better}
      '  '; // //{!ss:fill gap. FormatStr function using be better}
+{$endif}
   WriteStr(0,0,S,1);
   WriteStr(0,0,S,1);
 end;
 end;
 
 

+ 87 - 28
packages/fv/src/colorsel.inc

@@ -21,7 +21,11 @@
  ****************************************************************************}
  ****************************************************************************}
 
 
 {$IFNDEF FPC_DOTTEDUNITS}
 {$IFNDEF FPC_DOTTEDUNITS}
+{$ifdef FV_UNICODE}
+unit UColorSel;
+{$else FV_UNICODE}
 unit ColorSel;
 unit ColorSel;
+{$endif FV_UNICODE}
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 {====Include file to sort compiler platform out =====================}
 {====Include file to sort compiler platform out =====================}
 {$I platform.inc}
 {$I platform.inc}
@@ -29,11 +33,24 @@ interface
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
 uses
 uses
-  System.Objects, FreeVision.Drivers, FreeVision.Dialogs, FreeVision.Views, 
+  System.Objects,
+{$ifdef FV_UNICODE}
+  FreeVision.Ufvcommon,
+  FreeVision.Udrivers, FreeVision.Udialogs, FreeVision.Uviews,
+{$else}
+  FreeVision.Fvcommon,
+  FreeVision.Drivers, FreeVision.Dialogs, FreeVision.Views,
+{$endif}
   FreeVision.Fvconsts;
   FreeVision.Fvconsts;
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
 uses
 uses
-  Objects, Drivers, Dialogs, Views, fvconsts;
+  Objects,
+{$ifdef FV_UNICODE}
+  UFVCommon,UDrivers, UDialogs, UViews,
+{$else}
+  FVCommon,Drivers, Dialogs, Views,
+{$endif}
+  FVConsts;
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 const dialog_colorsel_colors        = 'Colors';
 const dialog_colorsel_colors        = 'Colors';
@@ -95,14 +112,14 @@ type
 
 
   PColorItem = ^TColorItem;
   PColorItem = ^TColorItem;
   TColorItem = record
   TColorItem = record
-    Name: PString;
+    Name: Sw_PString;
     Index: Byte;
     Index: Byte;
     Next: PColorItem;
     Next: PColorItem;
   end;
   end;
 
 
   PColorGroup = ^TColorGroup;
   PColorGroup = ^TColorGroup;
   TColorGroup = record
   TColorGroup = record
-    Name: PString;
+    Name: Sw_PString;
     Index: Byte;
     Index: Byte;
     Items: PColorItem;
     Items: PColorItem;
     Next: PColorGroup;
     Next: PColorGroup;
@@ -122,7 +139,7 @@ type
     constructor Load(var S: TStream);
     constructor Load(var S: TStream);
     procedure Store(var S: TStream);
     procedure Store(var S: TStream);
     procedure FocusItem(Item: Sw_Integer); virtual;
     procedure FocusItem(Item: Sw_Integer); virtual;
-    function GetText(Item: Sw_Integer; MaxLen: Sw_Integer): String; virtual;
+    function GetText(Item: Sw_Integer; MaxLen: Sw_Integer): Sw_String; virtual;
     procedure HandleEvent(var Event: TEvent); virtual;
     procedure HandleEvent(var Event: TEvent); virtual;
     procedure SetGroupIndex(GroupNum, ItemNum: Byte);
     procedure SetGroupIndex(GroupNum, ItemNum: Byte);
     function GetGroup(GroupNum: Byte): PColorGroup;
     function GetGroup(GroupNum: Byte): PColorGroup;
@@ -136,7 +153,7 @@ type
     Items: PColorItem;
     Items: PColorItem;
     constructor Init(var Bounds: TRect; AScrollBar: PScrollBar; AItems: PColorItem);
     constructor Init(var Bounds: TRect; AScrollBar: PScrollBar; AItems: PColorItem);
     procedure FocusItem(Item: Sw_Integer); virtual;
     procedure FocusItem(Item: Sw_Integer); virtual;
-    function GetText(Item: Sw_Integer; MaxLen: Sw_Integer): String; virtual;
+    function GetText(Item: Sw_Integer; MaxLen: Sw_Integer): Sw_String; virtual;
     procedure HandleEvent(var Event: TEvent); virtual;
     procedure HandleEvent(var Event: TEvent); virtual;
     procedure SetItems(AItems: PColorItem);
     procedure SetItems(AItems: PColorItem);
     function GetColorIndex(Item: Sw_integer): Sw_integer;
     function GetColorIndex(Item: Sw_integer): Sw_integer;
@@ -156,8 +173,8 @@ type
   PColorDisplay = ^TColorDisplay;
   PColorDisplay = ^TColorDisplay;
   TColorDisplay = object(TView)
   TColorDisplay = object(TView)
     Color: PByte;
     Color: PByte;
-    Text: PString;
-    constructor Init(var Bounds: TRect; AText: PString);
+    Text: Sw_PString;
+    constructor Init(var Bounds: TRect; AText: Sw_PString);
     constructor Load(var S: TStream);
     constructor Load(var S: TStream);
     procedure Store(var S: TStream);
     procedure Store(var S: TStream);
     procedure HandleEvent(var Event: TEvent); virtual;
     procedure HandleEvent(var Event: TEvent); virtual;
@@ -195,8 +212,8 @@ const ColorIndexes : PColorIndex = nil;
 
 
 procedure RegisterColorsel;
 procedure RegisterColorsel;
 
 
-function ColorGroup(Name: string; Items: PColorItem; Next: PColorGroup): PColorGroup;
-function ColorItem(Name: string; Index: Byte; Next: PColorItem): PColorItem;
+function ColorGroup(Name: Sw_String; Items: PColorItem; Next: PColorGroup): PColorGroup;
+function ColorItem(Name: Sw_String; Index: Byte; Next: PColorItem): PColorItem;
 
 
 procedure LoadIndexes(var S: TStream);
 procedure LoadIndexes(var S: TStream);
 procedure StoreIndexes(var S: TStream);
 procedure StoreIndexes(var S: TStream);
@@ -261,22 +278,22 @@ begin
 end;
 end;
 
 
 
 
-function ColorGroup(Name: string; Items: PColorItem; Next: PColorGroup): PColorGroup;
+function ColorGroup(Name: Sw_String; Items: PColorItem; Next: PColorGroup): PColorGroup;
 var
 var
   R: PColorGroup;
   R: PColorGroup;
 begin
 begin
   New(R);
   New(R);
-  R^.Name := NewStr(Name);
+  R^.Name := Sw_NewStr(Name);
   R^.Items := Items;
   R^.Items := Items;
   R^.Next := Next;
   R^.Next := Next;
   ColorGroup := R;
   ColorGroup := R;
 end;
 end;
 
 
-function ColorItem(Name: string; Index: Byte; Next: PColorItem): PColorItem;
+function ColorItem(Name: Sw_String; Index: Byte; Next: PColorItem): PColorItem;
 var R: PColorItem;
 var R: PColorItem;
 begin
 begin
   New(R);
   New(R);
-  R^.Name := NewStr(Name);
+  R^.Name := Sw_NewStr(Name);
   R^.Index := Index;
   R^.Index := Index;
   R^.Next := Next;
   R^.Next := Next;
   ColorItem := R
   ColorItem := R
@@ -426,17 +443,25 @@ var
 
 
 procedure DrawColorLine (LineNr : sw_word);
 procedure DrawColorLine (LineNr : sw_word);
 var k: sw_integer;
 var k: sw_integer;
+const
+{$ifdef FV_UNICODE}
+      ccBlock = WideChar(9608);
+      ccPoint = WideChar(9689); {#$25D9}
+{$else}
+      ccBlock = AnsiChar(#219);
+      ccPoint = AnsiChar(#8);
+{$endif}
 begin
 begin
   for k:=0 to 3 do
   for k:=0 to 3 do
   begin
   begin
-    MoveChar (B[0+k*3], #219, SelColor, 3);
+    MoveChar (B[0+k*3], ccBlock, SelColor, 3);
     if CurColor = Color then
     if CurColor = Color then
     begin
     begin
       if ((k = 0) or (k = 1)) and (CurColor<2) then
       if ((k = 0) or (k = 1)) and (CurColor<2) then
         SelColor:=SelColor or $70
         SelColor:=SelColor or $70
       else
       else
         SelColor:=SelColor and $f;
         SelColor:=SelColor and $f;
-      MoveChar (B[0+k*3+1], #8, SelColor, 1);
+      MoveChar (B[0+k*3+1], ccPoint, SelColor, 1);
       SelColor:=SelColor or $10;
       SelColor:=SelColor or $10;
       SelColor:=SelColor and $1f;
       SelColor:=SelColor and $1f;
     end;
     end;
@@ -464,7 +489,7 @@ end;
 {                      TColorDisplay                                 }
 {                      TColorDisplay                                 }
 {--------------------------------------------------------------------}
 {--------------------------------------------------------------------}
 
 
-constructor TColorDisplay.Init(var Bounds: TRect; AText: PString);
+constructor TColorDisplay.Init(var Bounds: TRect; AText: Sw_PString);
 begin
 begin
   inherited init(Bounds);
   inherited init(Bounds);
   EventMask := EventMask OR evBroadcast;
   EventMask := EventMask OR evBroadcast;
@@ -477,7 +502,11 @@ begin
   if not Assigned(Color) then
   if not Assigned(Color) then
     GetMem(Color,1);
     GetMem(Color,1);
   S.Read(Color^, SizeOf(Color^));
   S.Read(Color^, SizeOf(Color^));
-  Text:=S.ReadStr;
+{$ifdef FV_UNICODE}
+  Text:=S.ReadUnicodeString;                      { Read title }
+{$else FV_UNICODE}
+  Text:=S.ReadStr;                                { Read title }
+{$endif FV_UNICODE}
 end;
 end;
 
 
 procedure TColorDisplay.Store(var S: TStream);
 procedure TColorDisplay.Store(var S: TStream);
@@ -487,7 +516,11 @@ begin
   vColor:=0;
   vColor:=0;
   if Assigned(Color) then vColor:=Color^;
   if Assigned(Color) then vColor:=Color^;
   S.Write(vColor, SizeOf(vColor));
   S.Write(vColor, SizeOf(vColor));
+{$ifdef FV_UNICODE}
+  S.WriteUnicodeString(Text);
+{$else FV_UNICODE}
   S.WriteStr(Text);
   S.WriteStr(Text);
+{$endif FV_UNICODE}
 end;
 end;
 
 
 procedure TColorDisplay.HandleEvent(var Event: TEvent);
 procedure TColorDisplay.HandleEvent(var Event: TEvent);
@@ -521,7 +554,7 @@ procedure TColorDisplay.Draw;
 var
 var
   FColor : Byte;
   FColor : Byte;
   Y      : sw_integer;
   Y      : sw_integer;
-  S      : String;
+  S      : Sw_String;
   B      : TDrawBuffer;
   B      : TDrawBuffer;
 begin
 begin
   if Assigned(Color) then
   if Assigned(Color) then
@@ -532,8 +565,8 @@ begin
   end else
   end else
     FColor := GetColor (2);
     FColor := GetColor (2);
   MoveChar (B, ' ', FColor, Size.X);
   MoveChar (B, ' ', FColor, Size.X);
-  if Assigned(Text) then
-    S:=Text^
+  if (Text <> Sw_PString_Empty) then
+    S:=Text Sw_PString_DeRef
   else
   else
     S:='';
     S:='';
   if length(S) < Size.X then
   if length(S) < Size.X then
@@ -549,10 +582,12 @@ end;
 
 
 destructor TColorDisplay.Done;
 destructor TColorDisplay.Done;
 begin
 begin
-  if assigned(Text) then
+  if (Text <> Sw_PString_Empty) then
   begin
   begin
+{$ifndef FV_UNICODE}
     Dispose(Text);
     Dispose(Text);
-    Text:=nil;
+{$endif}
+    Text:=Sw_PString_Empty;
   end;
   end;
   inherited Done;
   inherited Done;
 end;
 end;
@@ -598,7 +633,11 @@ begin
     for iI:=1 to numItems do
     for iI:=1 to numItems do
     begin
     begin
       New(R);
       New(R);
+{$ifdef FV_UNICODE}
+      R^.Name:=S.ReadUnicodeString;
+{$else FV_UNICODE}
       R^.Name:=S.ReadStr;
       R^.Name:=S.ReadStr;
+{$endif FV_UNICODE}
       S.Read(R^.Index, SizeOf(R^.Index));
       S.Read(R^.Index, SizeOf(R^.Index));
       R^.Next:=nil;
       R^.Next:=nil;
       if assigned(Q) then
       if assigned(Q) then
@@ -607,7 +646,11 @@ begin
       if iI=1 then x^.Items:=R;
       if iI=1 then x^.Items:=R;
     end;
     end;
     {read group}
     {read group}
+{$ifdef FV_UNICODE}
+    x^.Name:=S.ReadUnicodeString;
+{$else FV_UNICODE}
     x^.Name:=S.ReadStr;
     x^.Name:=S.ReadStr;
+{$endif FV_UNICODE}
     S.Read(x^.Index, SizeOf(x^.Index));
     S.Read(x^.Index, SizeOf(x^.Index));
     x^.Next:=nil;
     x^.Next:=nil;
     if assigned(z) then
     if assigned(z) then
@@ -640,12 +683,20 @@ begin
     S.Write(numItems,Sizeof(numItems)); {  write Item count }
     S.Write(numItems,Sizeof(numItems)); {  write Item count }
     {write items}
     {write items}
     while Assigned(R) do begin
     while Assigned(R) do begin
+{$ifdef FV_UNICODE}
+      S.WriteUnicodeString(R^.Name);
+{$else FV_UNICODE}
       S.WriteStr(R^.Name);
       S.WriteStr(R^.Name);
+{$endif FV_UNICODE}
       S.Write(R^.Index,Sizeof(R^.Index));
       S.Write(R^.Index,Sizeof(R^.Index));
       R := R^.Next;
       R := R^.Next;
     end;
     end;
     {write gropu}
     {write gropu}
+{$ifdef FV_UNICODE}
+    S.WriteUnicodeString(x^.Name);
+{$else FV_UNICODE}
     S.WriteStr(x^.Name);
     S.WriteStr(x^.Name);
+{$endif FV_UNICODE}
     S.Write(x^.Index,Sizeof(x^.Index));
     S.Write(x^.Index,Sizeof(x^.Index));
     x := x^.Next;
     x := x^.Next;
   end;
   end;
@@ -663,7 +714,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TColorGroupList.GetText(Item: Sw_Integer; MaxLen: Sw_Integer): String;
+function TColorGroupList.GetText(Item: Sw_Integer; MaxLen: Sw_Integer): Sw_String;
 var x: PColorGroup;
 var x: PColorGroup;
     Num : sw_integer;
     Num : sw_integer;
 begin
 begin
@@ -673,7 +724,7 @@ begin
   while Assigned(x) do begin
   while Assigned(x) do begin
     if Num = Item then
     if Num = Item then
     begin
     begin
-      GetText:=x^.Name^;
+      GetText:=x^.Name Sw_PString_DeRef;
       exit;
       exit;
     end;
     end;
     inc(Num);
     inc(Num);
@@ -754,12 +805,20 @@ begin
   while Assigned(x) do begin
   while Assigned(x) do begin
     R:=x^.Items;
     R:=x^.Items;
     while Assigned(R) do begin
     while Assigned(R) do begin
+{$ifdef FV_UNICODE}
+      R^.Name:=Sw_PString_Empty;
+{$else}
       Dispose(R^.Name);
       Dispose(R^.Name);
+{$endif}
       Q:=R;
       Q:=R;
       R := R^.Next;
       R := R^.Next;
       Dispose(Q);
       Dispose(Q);
     end;
     end;
+{$ifdef FV_UNICODE}
+    x^.Name:=Sw_PString_Empty;
+{$else}
     Dispose(x^.Name);
     Dispose(x^.Name);
+{$endif}
     z:=x;
     z:=x;
     x := x^.Next;
     x := x^.Next;
     Dispose(z);
     Dispose(z);
@@ -793,7 +852,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TColorItemList.GetText(Item: Sw_Integer; MaxLen: Sw_Integer): String;
+function TColorItemList.GetText(Item: Sw_Integer; MaxLen: Sw_Integer): Sw_String;
 var count : sw_integer;
 var count : sw_integer;
     x :PColorItem;
     x :PColorItem;
 begin
 begin
@@ -806,7 +865,7 @@ begin
     begin
     begin
       if count=Item then
       if count=Item then
       begin
       begin
-        GetText:=x^.Name^;
+        GetText:=x^.Name Sw_PString_DeRef;
         {SetLength(GetText,Min(Length(GetText),MaxLen));}
         {SetLength(GetText,Min(Length(GetText),MaxLen));}
         exit;
         exit;
       end;
       end;
@@ -936,7 +995,7 @@ begin
   Insert(BakLabel);
   Insert(BakLabel);
   {-- Color Display --}
   {-- Color Display --}
   R.Assign(45, 12, 59, 15);
   R.Assign(45, 12, 59, 15);
-  Display:=New(PColorDisplay,Init(R,NewStr(label_colorsel_displaytext)));
+  Display:=New(PColorDisplay,Init(R,Sw_NewStr(label_colorsel_displaytext)));
   Insert(Display);
   Insert(Display);
   {-- Buttons --}
   {-- Buttons --}
   R.Assign(37, 16, 47, 18);
   R.Assign(37, 16, 47, 18);

+ 27 - 8
packages/fv/src/colortxt.inc

@@ -1,6 +1,3 @@
-{$IFNDEF FPC_DOTTEDUNITS}
-unit ColorTxt;
-{$ENDIF FPC_DOTTEDUNITS}
 {
 {
     This file is part of the Free Vision package
     This file is part of the Free Vision package
 
 
@@ -24,6 +21,14 @@ unit ColorTxt;
   the constructor has an extra Byte parameter specifying the attribute
   the constructor has an extra Byte parameter specifying the attribute
   desired.  (Do not use a 0 attribute, black on black).
   desired.  (Do not use a 0 attribute, black on black).
 }
 }
+{$IFNDEF FPC_DOTTEDUNITS}
+{$ifdef FV_UNICODE}
+unit UColorTxt;
+{$else FV_UNICODE}
+unit ColorTxt;
+{$endif FV_UNICODE}
+{$ENDIF FPC_DOTTEDUNITS}
+
 
 
 {$i platform.inc}
 {$i platform.inc}
 
 
@@ -41,17 +46,31 @@ interface
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
 uses
 uses
-  System.Objects, FreeVision.Drivers, FreeVision.Views, FreeVision.Dialogs, FreeVision.App, FreeVision.Fvconsts;
+  System.Objects,
+{$ifdef FV_UNICODE}
+  FreeVision.Ufvcommon, FreeVision.Udrivers, FreeVision.Uviews,
+  FreeVision.Udialogs, FreeVision.Uapp,
+{$else}
+  FreeVision.Fvcommon, FreeVision.Drivers, FreeVision.Views,
+  FreeVision.Dialogs, FreeVision.App,
+{$endif}
+  FreeVision.Fvconsts;
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
 uses
 uses
-  objects, drivers, views, dialogs, app, fvconsts;
+  Objects,
+{$ifdef FV_UNICODE}
+  UFvcommon, UDrivers, UViews, Udialogs, UApp,
+{$else}
+  Fvcommon, Drivers, Views, Dialogs, App,
+{$endif}
+  Fvconsts;
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 type
 type
   PColoredText = ^TColoredText;
   PColoredText = ^TColoredText;
   TColoredText = object(TStaticText)
   TColoredText = object(TStaticText)
     Attr : Byte;
     Attr : Byte;
-    constructor Init(var Bounds: TRect; const AText: String; Attribute : Byte);
+    constructor Init(var Bounds: TRect; const AText: Sw_String; Attribute : Byte);
     constructor Load(var S: TStream);
     constructor Load(var S: TStream);
     function GetTheColor : byte; virtual;
     function GetTheColor : byte; virtual;
     procedure Draw; virtual;
     procedure Draw; virtual;
@@ -68,7 +87,7 @@ const
 
 
 implementation
 implementation
 
 
-constructor TColoredText.Init(var Bounds: TRect; const AText: String;
+constructor TColoredText.Init(var Bounds: TRect; const AText: Sw_String;
                                   Attribute : Byte);
                                   Attribute : Byte);
 begin
 begin
 TStaticText.Init(Bounds, AText);
 TStaticText.Init(Bounds, AText);
@@ -101,7 +120,7 @@ var
   Center: Boolean;
   Center: Boolean;
   I, J, L, P, Y: Sw_Integer;
   I, J, L, P, Y: Sw_Integer;
   B: TDrawBuffer;
   B: TDrawBuffer;
-  S: String;
+  S: Sw_String;
 begin
 begin
   Color := GetTheColor;
   Color := GetTheColor;
   GetText(S);
   GetText(S);

File diff suppressed because it is too large
+ 651 - 29
packages/fv/src/editors.inc


+ 30 - 10
packages/fv/src/gadgets.inc

@@ -64,7 +64,11 @@
 {**********************************************************}
 {**********************************************************}
 
 
 {$IFNDEF FPC_DOTTEDUNITS}
 {$IFNDEF FPC_DOTTEDUNITS}
+{$ifdef FV_UNICODE}
+UNIT UGadgets;
+{$else FV_UNICODE}
 UNIT Gadgets;
 UNIT Gadgets;
+{$endif FV_UNICODE}
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
@@ -99,9 +103,21 @@ UNIT Gadgets;
 {====================================================================}
 {====================================================================}
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
-USES FreeVision.Fvconsts, FreeVision.Time, System.Objects,FreeVision.Drivers, FreeVision.Views, FreeVision.App;      { Standard GFV units }
+USES FreeVision.Fvconsts,  System.Objects,
+  {$ifdef FV_UNICODE}
+  FreeVision.Ufvcommon,FreeVision.Udrivers,FreeVision.Uviews,FreeVision.Uapp,     { Standard GFV units }
+  {$else}
+  FreeVision.fvcommon, FreeVision.Drivers, FreeVision.Views, FreeVision.App,      { Standard GFV units }
+  {$endif}
+  FreeVision.Time;
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
-USES FVConsts, Time, Objects, Drivers, Views, App;      { Standard GFV units }
+USES FVConsts, Objects,
+  {$ifdef FV_UNICODE}
+  ufvcommon, uDrivers, uViews, uApp,     { Standard GFV units }
+  {$else}
+  fvcommon, Drivers, Views, App,         { Standard GFV units }
+  {$endif}
+  Time;
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {***************************************************************************}
 {***************************************************************************}
@@ -123,7 +139,7 @@ TYPE
       constructor InitMb(var Bounds: TRect);
       constructor InitMb(var Bounds: TRect);
       PROCEDURE Update;
       PROCEDURE Update;
       PROCEDURE Draw; Virtual;
       PROCEDURE Draw; Virtual;
-      Function  Comma ( N : LongInt ) : String;
+      Function  Comma ( N : LongInt ) : Sw_String;
    END;
    END;
    PHeapView = ^THeapView;                            { Heapview pointer }
    PHeapView = ^THeapView;                            { Heapview pointer }
 
 
@@ -135,9 +151,13 @@ TYPE
          am : AnsiChar;
          am : AnsiChar;
          Refresh : Byte;                              { Refresh rate }
          Refresh : Byte;                              { Refresh rate }
          LastTime: Longint;                           { Last time displayed }
          LastTime: Longint;                           { Last time displayed }
+{$ifdef FV_UNICODE}
+         TimeStr : Sw_String;                         { Time string }
+{$else}
          TimeStr : String[10];                        { Time string }
          TimeStr : String[10];                        { Time string }
+{$endif}
       CONSTRUCTOR Init (Var Bounds: TRect);
       CONSTRUCTOR Init (Var Bounds: TRect);
-      FUNCTION FormatTimeStr (H, M, S: Word): String; Virtual;
+      FUNCTION FormatTimeStr (H, M, S: Word): Sw_String; Virtual;
       PROCEDURE Update; Virtual;
       PROCEDURE Update; Virtual;
       PROCEDURE Draw; Virtual;
       PROCEDURE Draw; Virtual;
    END;
    END;
@@ -226,7 +246,7 @@ END;
 PROCEDURE THeapView.Draw;
 PROCEDURE THeapView.Draw;
 VAR
 VAR
   C : Byte;
   C : Byte;
-  S : String;
+  S : Sw_String;
   B : TDrawBuffer;
   B : TDrawBuffer;
 begin
 begin
   case mode of
   case mode of
@@ -251,11 +271,11 @@ begin
   WriteLine(0,0,Size.X,1,B);
   WriteLine(0,0,Size.X,1,B);
 END;
 END;
 
 
-Function THeapView.Comma ( n : LongInt) : String;
+Function THeapView.Comma ( n : LongInt) : Sw_String;
 Var
 Var
   num, loc : Byte;
   num, loc : Byte;
-  s : String;
-  t : String;
+  s : Sw_String;
+  t : Sw_String;
 Begin
 Begin
   Str (n,s);
   Str (n,s);
   Str (n:Size.X,t);
   Str (n:Size.X,t);
@@ -294,8 +314,8 @@ END;
 {--TClockView---------------------------------------------------------------}
 {--TClockView---------------------------------------------------------------}
 {  FormatTimeStr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Nov99 LdB     }
 {  FormatTimeStr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Nov99 LdB     }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
-FUNCTION TClockView.FormatTimeStr (H, M, S: Word): String;
-VAR Hs, Ms, Ss: String;
+FUNCTION TClockView.FormatTimeStr (H, M, S: Word): Sw_String;
+VAR Hs, Ms, Ss: String[7];
 BEGIN
 BEGIN
    Str(H, Hs);                                        { Convert hour string }
    Str(H, Hs);                                        { Convert hour string }
    While (Length(Hs) < 2) Do Hs := '0' + Hs;          { Add lead zero's }
    While (Length(Hs) < 2) Do Hs := '0' + Hs;          { Add lead zero's }

+ 44 - 9
packages/fv/src/statuses.inc

@@ -1,6 +1,10 @@
 {$V-}
 {$V-}
 {$IFNDEF FPC_DOTTEDUNITS}
 {$IFNDEF FPC_DOTTEDUNITS}
+{$ifdef FV_UNICODE}
+unit UStatuses;
+{$else FV_UNICODE}
 unit Statuses;
 unit Statuses;
+{$endif FV_UNICODE}
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {$CODEPAGE cp437}
 {$CODEPAGE cp437}
@@ -68,11 +72,24 @@ interface
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
 uses
 uses
-  FreeVision.Fvcommon, FreeVision.Fvconsts, System.Objects, FreeVision.Drivers, 
-  FreeVision.Views, FreeVision.Dialogs;
+  System.Objects,
+{$ifdef FV_UNICODE}
+  FreeVision.Ufvcommon, FreeVision.Udrivers, FreeVision.Udialogs,
+  FreeVision.Uviews,
+{$else}
+  FreeVision.Fvcommon, FreeVision.Drivers, FreeVision.Dialogs,
+  FreeVision.Views,
+{$endif}
+  FreeVision.Fvconsts;
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
 uses
 uses
-  FVCommon, FVConsts, Objects, Drivers, Views, Dialogs;
+  Objects,
+{$ifdef FV_UNICODE}
+  UFVCommon,UDrivers, UDialogs, UViews,
+{$else}
+  FVCommon,Drivers, Dialogs, Views,
+{$endif}
+  FVConsts;
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 {  Resource;}
 {  Resource;}
 
 
@@ -207,7 +224,7 @@ type
         the status view receives an evStatus event it checks the value of the
         the status view receives an evStatus event it checks the value of the
         Event.Command field against Command before handling the event. }
         Event.Command field against Command before handling the event. }
       {#X HandleEvent }
       {#X HandleEvent }
-    constructor Init (R : TRect; ACommand : Word; AText : String;
+    constructor Init (R : TRect; ACommand : Word; AText : Sw_String;
                       AParamCount : SmallInt);
                       AParamCount : SmallInt);
       { Init calls the inherited constructor then sets #Command# to ACommand.
       { Init calls the inherited constructor then sets #Command# to ACommand.
 
 
@@ -338,7 +355,7 @@ type
       All status views that are to be inserted into a window or dialog should
       All status views that are to be inserted into a window or dialog should
       descend from #TStatus# for proper color mapping. }
       descend from #TStatus# for proper color mapping. }
     constructor Init (ATitle : TTitleStr; AStatus : PStatus; AFlags : Word;
     constructor Init (ATitle : TTitleStr; AStatus : PStatus; AFlags : Word;
-                      AMessage : String);
+                      AMessage : Sw_String);
       { Init calls the inherited constructor then inserts a TStaticText view
       { Init calls the inherited constructor then inserts a TStaticText view
         containing AMessage at the top line of the dialog.
         containing AMessage at the top line of the dialog.
 
 
@@ -689,10 +706,18 @@ implementation
 
 
 {$IFDEF FPC_DOTTEDUNITS}
 {$IFDEF FPC_DOTTEDUNITS}
 uses
 uses
+{$ifdef FV_UNICODE}
+  FreeVision.Umsgbox, FreeVision.Uapp;
+{$else}
   FreeVision.Msgbox, FreeVision.App;
   FreeVision.Msgbox, FreeVision.App;
+{$endif}
 {$ELSE FPC_DOTTEDUNITS}
 {$ELSE FPC_DOTTEDUNITS}
 uses
 uses
+{$ifdef FV_UNICODE}
+  uMsgBox, uApp;
+{$else}
   MsgBox, App;
   MsgBox, App;
+{$endif}
 {$ENDIF FPC_DOTTEDUNITS}
 {$ENDIF FPC_DOTTEDUNITS}
 
 
 {****************************************************************************}
 {****************************************************************************}
@@ -803,7 +828,12 @@ var
   C : Word;
   C : Word;
   FillSize : Word;
   FillSize : Word;
   PercentDone : PtrInt;
   PercentDone : PtrInt;
+{$ifdef FV_UNICODE}
+  S : Sw_String;
+{$else}
   S : String[4];
   S : String[4];
+{$endif}
+
 begin
 begin
   { fill entire view }
   { fill entire view }
   MoveChar(B,' ',GetColor(4),Size.X);
   MoveChar(B,' ',GetColor(4),Size.X);
@@ -868,7 +898,7 @@ end;
 {****************************************************************************}
 {****************************************************************************}
 procedure TGauge.Draw;
 procedure TGauge.Draw;
 var
 var
-  S : String;
+  S : Sw_String;
   B : TDrawBuffer;
   B : TDrawBuffer;
 begin
 begin
   { Blank the gauge }
   { Blank the gauge }
@@ -1006,7 +1036,7 @@ procedure TPercentGauge.Draw;
 var
 var
   B : TDrawBuffer;
   B : TDrawBuffer;
   C : Word;
   C : Word;
-  S : String;
+  S : Sw_String;
   PercentDone : LongInt;
   PercentDone : LongInt;
   FillSize : SmallInt;
   FillSize : SmallInt;
 begin
 begin
@@ -1083,7 +1113,7 @@ end;
 {****************************************************************************}
 {****************************************************************************}
 { TStatus.Init                                                               }
 { TStatus.Init                                                               }
 {****************************************************************************}
 {****************************************************************************}
-constructor TStatus.Init (R : TRect; ACommand : Word; AText : String;
+constructor TStatus.Init (R : TRect; ACommand : Word; AText : Sw_String;
                           AParamCount : SmallInt);
                           AParamCount : SmallInt);
 begin
 begin
   if (not TParamText.Init(R,AText,AParamCount)) then
   if (not TParamText.Init(R,AText,AParamCount)) then
@@ -1207,8 +1237,13 @@ end;
 {****************************************************************************}
 {****************************************************************************}
 procedure TStatus.Update (Data : Pointer);
 procedure TStatus.Update (Data : Pointer);
 begin
 begin
+{$ifdef FV_UNICODE}
+  Text := Sw_PString_Empty;
+  Text := UnicodeString(Data);
+{$else}
   DisposeStr(Text);
   DisposeStr(Text);
   Text := NewStr(String(Data^));
   Text := NewStr(String(Data^));
+{$endif}
   DrawView;
   DrawView;
 end;
 end;
 
 
@@ -1368,7 +1403,7 @@ end;
 { TStatusMessageDlg.Init                                                     }
 { TStatusMessageDlg.Init                                                     }
 {****************************************************************************}
 {****************************************************************************}
 constructor TStatusMessageDlg.Init (ATitle : TTitleStr; AStatus : PStatus;
 constructor TStatusMessageDlg.Init (ATitle : TTitleStr; AStatus : PStatus;
-                                    AFlags : Word; AMessage : String);
+                                    AFlags : Word; AMessage : Sw_String);
 var
 var
   P : PStaticText;
   P : PStaticText;
   X, Y : SmallInt;
   X, Y : SmallInt;

File diff suppressed because it is too large
+ 331 - 89
packages/fv/src/stddlg.inc


Some files were not shown because too many files changed in this diff