Changeset 189 for branches/generator/Packages/Common
- Timestamp:
- May 16, 2019, 11:35:07 PM (6 years ago)
- Location:
- branches/generator/Packages/Common
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Packages/Common/Common.lpk
r167 r189 60 60 <Item5> 61 61 <Filename Value="UPrefixMultiplier.pas"/> 62 <HasRegisterProc Value="True"/> 62 63 <UnitName Value="UPrefixMultiplier"/> 63 64 </Item5> … … 144 145 <EnableI18NForLFM Value="True"/> 145 146 </i18n> 146 <RequiredPkgs Count=" 3">147 <RequiredPkgs Count="2"> 147 148 <Item1> 148 149 <PackageName Value="LCL"/> 149 150 </Item1> 150 151 <Item2> 151 <PackageName Value="TemplateGenerics"/>152 </Item2>153 <Item3>154 152 <PackageName Value="FCL"/> 155 153 <MinVersion Major="1" Valid="True"/> 156 </Item 3>154 </Item2> 157 155 </RequiredPkgs> 158 156 <UsageOptions> -
branches/generator/Packages/Common/Common.pas
r167 r189 20 20 begin 21 21 RegisterUnit('UDebugLog', @UDebugLog.Register); 22 RegisterUnit('UPrefixMultiplier', @UPrefixMultiplier.Register); 22 23 RegisterUnit('ULastOpenedList', @ULastOpenedList.Register); 23 24 RegisterUnit('UJobProgressView', @UJobProgressView.Register); -
branches/generator/Packages/Common/Languages/UJobProgressView.cs.po
r167 r189 24 24 msgstr "DokonÄené" 25 25 26 #: ujobprogressview.soperations27 #, fuzzy28 #| msgid "Operations"29 msgid "Operations:"30 msgstr "Operace"31 32 26 #: ujobprogressview.spleasewait 33 27 msgid "Please wait..." -
branches/generator/Packages/Common/Languages/UJobProgressView.po
r167 r189 14 14 msgstr "" 15 15 16 #: ujobprogressview.soperations17 msgid "Operations:"18 msgstr ""19 20 16 #: ujobprogressview.spleasewait 21 17 msgid "Please wait..." -
branches/generator/Packages/Common/Languages/UThreading.po
r114 r189 3 3 4 4 #: uthreading.scurrentthreadnotfound 5 #, fuzzy,badformat 5 6 msgid "Current thread ID %d not found in virtual thread list." 6 7 msgstr "Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8Content-Type: text/plain; charset=UTF-8" -
branches/generator/Packages/Common/UCommon.pas
r167 r189 28 28 unfDNSDomainName = 11); 29 29 30 TFilterMethodMethod = function (FileName: string): Boolean of object; 30 TFilterMethod = function (FileName: string): Boolean of object; 31 TFileNameMethod = procedure (FileName: string) of object; 32 31 33 var 32 34 ExceptionHandler: TExceptionEvent; … … 72 74 function MergeArray(A, B: array of string): TArrayOfString; 73 75 function LoadFileToStr(const FileName: TFileName): AnsiString; 76 procedure SaveStringToFile(S, FileName: string); 74 77 procedure SearchFiles(AList: TStrings; Dir: string; 75 FilterMethod: TFilterMethod Method = nil);78 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 76 79 function GetStringPart(var Text: string; Separator: string): string; 80 function StripTags(const S: string): string; 77 81 function PosFromIndex(SubStr: string; Text: string; 78 82 StartIndex: Integer): Integer; 79 83 function PosFromIndexReverse(SubStr: string; Text: string; 80 84 StartIndex: Integer): Integer; 85 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 81 86 82 87 … … 106 111 I: Integer; 107 112 begin 113 Result := ''; 108 114 for I := 1 to Length(Source) do begin 109 115 Result := Result + LowerCase(IntToHex(Ord(Source[I]), 2)); … … 527 533 end; 528 534 535 procedure SaveStringToFile(S, FileName: string); 536 var 537 F: TextFile; 538 begin 539 AssignFile(F, FileName); 540 try 541 ReWrite(F); 542 Write(F, S); 543 finally 544 CloseFile(F); 545 end; 546 end; 547 529 548 procedure SearchFiles(AList: TStrings; Dir: string; 530 FilterMethod: TFilterMethod Method = nil);549 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 531 550 var 532 551 SR: TSearchRec; … … 538 557 if (SR.Name = '.') or (SR.Name = '..') or (Assigned(FilterMethod) and (not FilterMethod(SR.Name) or 539 558 not FilterMethod(Copy(Dir, 3, Length(Dir)) + SR.Name))) then Continue; 559 if Assigned(FileNameMethod) then 560 FileNameMethod(Dir + SR.Name); 540 561 AList.Add(Dir + SR.Name); 541 562 if (SR.Attr and faDirectory) <> 0 then … … 561 582 Result := Trim(Result); 562 583 Text := Trim(Text); 584 end; 585 586 function StripTags(const S: string): string; 587 var 588 Len: Integer; 589 590 function ReadUntil(const ReadFrom: Integer; const C: Char): Integer; 591 var 592 J: Integer; 593 begin 594 for J := ReadFrom to Len do 595 if (S[j] = C) then 596 begin 597 Result := J; 598 Exit; 599 end; 600 Result := Len + 1; 601 end; 602 603 var 604 I, APos: Integer; 605 begin 606 Len := Length(S); 607 I := 0; 608 Result := ''; 609 while (I <= Len) do begin 610 Inc(I); 611 APos := ReadUntil(I, '<'); 612 Result := Result + Copy(S, I, APos - i); 613 I := ReadUntil(APos + 1, '>'); 614 end; 563 615 end; 564 616 … … 608 660 end; 609 661 662 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 663 var 664 I: Integer; 665 begin 666 SetLength(Dest, Length(Source)); 667 for I := 0 to Length(Dest) - 1 do 668 Dest[I] := Source[I]; 669 end; 670 671 610 672 initialization 611 673 -
branches/generator/Packages/Common/UDebugLog.pas
r167 r189 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, SpecializedList, SyncObjs;8 Classes, SysUtils, FileUtil, fgl, SyncObjs; 9 9 10 10 type … … 29 29 procedure SetMaxCount(const AValue: Integer); 30 30 public 31 Items: T ListObject;31 Items: TFPGObjectList<TDebugLogItem>; 32 32 Lock: TCriticalSection; 33 33 procedure Add(Text: string; Group: string = ''); … … 117 117 begin 118 118 inherited; 119 Items := T ListObject.Create;119 Items := TFPGObjectList<TDebugLogItem>.Create; 120 120 Lock := TCriticalSection.Create; 121 121 MaxCount := 100; -
branches/generator/Packages/Common/UJobProgressView.lfm
r167 r189 15 15 OnShow = FormShow 16 16 Position = poScreenCenter 17 LCLVersion = ' 1.8.2.0'17 LCLVersion = '2.0.2.0' 18 18 object PanelOperationsTitle: TPanel 19 19 Left = 0 … … 241 241 Interval = 100 242 242 OnTimer = TimerUpdateTimer 243 left = 264243 left = 320 244 244 top = 8 245 245 end -
branches/generator/Packages/Common/UJobProgressView.pas
r167 r189 175 175 STotalEstimatedTime = 'Total estimated time: %s'; 176 176 SFinished = 'Finished'; 177 SOperations = 'Operations:';178 177 179 178 procedure Register; -
branches/generator/Packages/Common/UListViewSort.pas
r167 r189 9 9 uses 10 10 {$IFDEF Windows}Windows, CommCtrl, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils, 11 Controls, DateUtils, Dialogs, SpecializedList, Forms, Grids, StdCtrls, ExtCtrls,12 LclIntf, L Messages, LclType, LResources;11 Controls, DateUtils, Dialogs, fgl, Forms, Grids, StdCtrls, ExtCtrls, 12 LclIntf, LclType, LResources; 13 13 14 14 type … … 52 52 {$ENDIF} 53 53 public 54 List: T ListObject;55 Source: T ListObject;54 List: TFPGObjectList<TObject>; 55 Source: TFPGObjectList<TObject>; 56 56 constructor Create(AOwner: TComponent); override; 57 57 destructor Destroy; override; … … 98 98 end; 99 99 100 { TListViewEx } 101 102 TListViewEx = class(TWinControl) 103 private 104 FFilter: TListViewFilter; 105 FListView: TListView; 106 FListViewSort: TListViewSort; 107 procedure ResizeHanlder; 108 public 109 constructor Create(TheOwner: TComponent); override; 110 destructor Destroy; override; 111 published 112 property ListView: TListView read FListView write FListView; 113 property ListViewSort: TListViewSort read FListViewSort write FListViewSort; 114 property Filter: TListViewFilter read FFilter write FFilter; 115 property Visible; 116 end; 117 100 118 procedure Register; 101 119 … … 105 123 procedure Register; 106 124 begin 107 RegisterComponents('Common', [TListViewSort, TListViewFilter]); 125 RegisterComponents('Common', [TListViewSort, TListViewFilter, TListViewEx]); 126 end; 127 128 { TListViewEx } 129 130 procedure TListViewEx.ResizeHanlder; 131 begin 132 end; 133 134 constructor TListViewEx.Create(TheOwner: TComponent); 135 begin 136 inherited Create(TheOwner); 137 Filter := TListViewFilter.Create(Self); 138 Filter.Parent := Self; 139 Filter.Align := alBottom; 140 ListView := TListView.Create(Self); 141 ListView.Parent := Self; 142 ListView.Align := alClient; 143 ListViewSort := TListViewSort.Create(Self); 144 ListViewSort.ListView := ListView; 145 end; 146 147 destructor TListViewEx.Destroy; 148 begin 149 inherited Destroy; 108 150 end; 109 151 … … 277 319 end; 278 320 321 var 322 ListViewSortCompare: TCompareEvent; 323 324 function ListViewCompare(const Item1, Item2: TObject): Integer; 325 begin 326 Result := ListViewSortCompare(Item1, Item2); 327 end; 328 279 329 procedure TListViewSort.Sort(Compare: TCompareEvent); 280 330 begin 331 // TODO: Because TFLGObjectList compare handler is not class method, 332 // it is necessary to use simple function compare handler with local variable 333 ListViewSortCompare := Compare; 281 334 if (List.Count > 0) then 282 List.Sort( Compare);335 List.Sort(ListViewCompare); 283 336 end; 284 337 … … 343 396 begin 344 397 inherited; 345 List := T ListObject.Create;346 List. OwnsObjects := False;398 List := TFPGObjectList<TObject>.Create; 399 List.FreeObjects := False; 347 400 end; 348 401 -
branches/generator/Packages/Common/UMemory.pas
r167 r189 112 112 procedure TMemory.WriteMemory(Position: Integer; Memory: TMemory); 113 113 begin 114 Move(Memory.FData, PByte( @FData+ Position)^, Memory.Size);114 Move(Memory.FData, PByte(PByte(@FData) + Position)^, Memory.Size); 115 115 end; 116 116 117 117 procedure TMemory.ReadMemory(Position: Integer; Memory: TMemory); 118 118 begin 119 Move(PByte( @FData+ Position)^, Memory.FData, Memory.Size);119 Move(PByte(PByte(@FData) + Position)^, Memory.FData, Memory.Size); 120 120 end; 121 121 -
branches/generator/Packages/Common/UPool.pas
r114 r189 6 6 7 7 uses 8 Classes, SysUtils, syncobjs, SpecializedList, UThreading;8 Classes, SysUtils, syncobjs, fgl, UThreading; 9 9 10 10 type … … 22 22 function NewItemObject: TObject; virtual; 23 23 public 24 Items: T ListObject;25 FreeItems: T ListObject;24 Items: TFPGObjectList<TObject>; 25 FreeItems: TFPGObjectList<TObject>; 26 26 function Acquire: TObject; virtual; 27 27 procedure Release(Item: TObject); virtual; … … 185 185 begin 186 186 inherited; 187 Items := T ListObject.Create;188 FreeItems := T ListObject.Create;189 FreeItems. OwnsObjects := False;187 Items := TFPGObjectList<TObject>.Create; 188 FreeItems := TFPGObjectList<TObject>.Create; 189 FreeItems.FreeObjects := False; 190 190 FReleaseEvent := TEvent.Create(nil, False, False, ''); 191 191 end; -
branches/generator/Packages/Common/UPrefixMultiplier.pas
r114 r189 21 21 { TPrefixMultiplier } 22 22 23 TPrefixMultiplier = class 23 TPrefixMultiplier = class(TComponent) 24 24 private 25 function TruncateDigits(Value: Double;Digits:Integer=3):Double;25 function TruncateDigits(Value: Double; Digits: Integer = 3): Double; 26 26 public 27 27 function Add(Value: Double; PrefixMultipliers: TPrefixMultiplierDef; … … 72 72 ); 73 73 74 procedure Register; 75 76 74 77 implementation 78 79 procedure Register; 80 begin 81 RegisterComponents('Common', [TPrefixMultiplier]); 82 end; 75 83 76 84 { TPrefixMultiplier } … … 92 100 end; 93 101 94 function TPrefixMultiplier.Add(Value: Double;PrefixMultipliers:TPrefixMultiplierDef95 ; UnitText:string;Digits:Integer):string;102 function TPrefixMultiplier.Add(Value: Double; PrefixMultipliers: TPrefixMultiplierDef 103 ; UnitText:string; Digits: Integer): string; 96 104 var 97 105 I: Integer; -
branches/generator/Packages/Common/URegistry.pas
r167 r189 29 29 procedure SetCurrentContext(AValue: TRegistryContext); 30 30 public 31 function ReadChar(const Name: string): Char; 32 procedure WriteChar(const Name: string; Value: Char); 31 33 function ReadBoolWithDefault(const Name: string; 32 34 DefaultValue: Boolean): Boolean; 33 35 function ReadIntegerWithDefault(const Name: string; DefaultValue: Integer): Integer; 34 36 function ReadStringWithDefault(const Name: string; DefaultValue: string): string; 37 function ReadCharWithDefault(const Name: string; DefaultValue: Char): Char; 35 38 function ReadFloatWithDefault(const Name: string; 36 39 DefaultValue: Double): Double; … … 89 92 end; 90 93 94 function TRegistryEx.ReadCharWithDefault(const Name: string; DefaultValue: Char 95 ): Char; 96 begin 97 if ValueExists(Name) then Result := ReadChar(Name) 98 else begin 99 WriteChar(Name, DefaultValue); 100 Result := DefaultValue; 101 end; 102 end; 103 91 104 function TRegistryEx.ReadFloatWithDefault(const Name: string; 92 105 DefaultValue: Double): Double; … … 137 150 end; 138 151 152 function TRegistryEx.ReadChar(const Name: string): Char; 153 var 154 S: string; 155 begin 156 S := ReadString(Name); 157 if Length(S) > 0 then Result := S[1] 158 else Result := #0; 159 end; 160 161 procedure TRegistryEx.WriteChar(const Name: string; Value: Char); 162 begin 163 WriteString(Name, Value); 164 end; 165 139 166 function TRegistryEx.ReadBoolWithDefault(const Name: string; 140 167 DefaultValue: Boolean): Boolean; -
branches/generator/Packages/Common/UScaleDPI.pas
r167 r189 289 289 //OldAutoSize: Boolean; 290 290 begin 291 //if not (Control is TCustomPage) then 292 // Resize childs first 293 if Control is TWinControl then begin 294 WinControl := TWinControl(Control); 295 if WinControl.ControlCount > 0 then begin 296 for I := 0 to WinControl.ControlCount - 1 do begin 297 if WinControl.Controls[I] is TControl then begin 298 ScaleControl(WinControl.Controls[I], FromDPI); 299 end; 300 end; 301 end; 302 end; 303 291 304 //if Control is TMemo then Exit; 292 305 //if Control is TForm then … … 340 353 end; 341 354 342 //if not (Control is TCustomPage) then343 if Control is TWinControl then begin344 WinControl := TWinControl(Control);345 if WinControl.ControlCount > 0 then begin346 for I := 0 to WinControl.ControlCount - 1 do begin347 if WinControl.Controls[I] is TControl then begin348 ScaleControl(WinControl.Controls[I], FromDPI);349 end;350 end;351 end;352 end;353 355 //if Control is TForm then 354 356 // Control.EnableAutoSizing; -
branches/generator/Packages/Common/UXMLUtils.pas
r167 r189 7 7 uses 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils, DOM, XMLRead;9 Classes, SysUtils, DateUtils, DOM, xmlread; 10 10 11 11 function XMLTimeToDateTime(XMLDateTime: string): TDateTime;
Note:
See TracChangeset
for help on using the changeset viewer.