Changeset 21 for trunk/Packages/Common
- Timestamp:
- May 8, 2019, 12:11:40 PM (6 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 3 added
- 1 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.lpk
r15 r21 40 40 <License Value="GNU/GPL"/> 41 41 <Version Minor="7"/> 42 <Files Count="2 1">42 <Files Count="22"> 43 43 <Item1> 44 44 <Filename Value="StopWatch.pas"/> … … 60 60 <Item5> 61 61 <Filename Value="UPrefixMultiplier.pas"/> 62 <HasRegisterProc Value="True"/> 62 63 <UnitName Value="UPrefixMultiplier"/> 63 64 </Item5> … … 134 135 <UnitName Value="UTheme"/> 135 136 </Item21> 137 <Item22> 138 <Filename Value="UStringTable.pas"/> 139 <UnitName Value="UStringTable"/> 140 </Item22> 136 141 </Files> 137 142 <i18n> … … 140 145 <EnableI18NForLFM Value="True"/> 141 146 </i18n> 142 <RequiredPkgs Count=" 3">147 <RequiredPkgs Count="2"> 143 148 <Item1> 144 149 <PackageName Value="LCL"/> 145 150 </Item1> 146 151 <Item2> 147 <PackageName Value="TemplateGenerics"/>148 </Item2>149 <Item3>150 152 <PackageName Value="FCL"/> 151 153 <MinVersion Major="1" Valid="True"/> 152 </Item 3>154 </Item2> 153 155 </RequiredPkgs> 154 156 <UsageOptions> -
trunk/Packages/Common/Common.pas
r15 r21 5 5 unit Common; 6 6 7 {$warn 5023 off : no warning about unused units} 7 8 interface 8 9 9 10 uses 10 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, UScaleDPI, UTheme, LazarusPackageIntf; 11 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 12 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 13 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 14 UPersistentForm, UFindFile, UScaleDPI, UTheme, UStringTable, 15 LazarusPackageIntf; 14 16 15 17 implementation … … 18 20 begin 19 21 RegisterUnit('UDebugLog', @UDebugLog.Register); 22 RegisterUnit('UPrefixMultiplier', @UPrefixMultiplier.Register); 20 23 RegisterUnit('ULastOpenedList', @ULastOpenedList.Register); 21 24 RegisterUnit('UJobProgressView', @UJobProgressView.Register); -
trunk/Packages/Common/Languages/UJobProgressView.cs.po
r1 r21 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 1.8.8\n"12 "X-Generator: Poedit 2.2\n" 13 13 14 14 #: ujobprogressview.sestimatedtime … … 24 24 msgstr "Dokončené" 25 25 26 #: ujobprogressview.soperations27 msgid "Operations"28 msgstr "Operace"29 30 26 #: ujobprogressview.spleasewait 31 27 msgid "Please wait..." -
trunk/Packages/Common/Languages/UJobProgressView.po
r1 r21 14 14 msgstr "" 15 15 16 #: ujobprogressview.soperations17 msgid "Operations"18 msgstr ""19 20 16 #: ujobprogressview.spleasewait 21 17 msgid "Please wait..." -
trunk/Packages/Common/Languages/UThreading.po
r1 r21 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" -
trunk/Packages/Common/UApplicationInfo.pas
r1 r21 6 6 7 7 uses 8 SysUtils, Registry, Classes, Forms, URegistry;8 SysUtils, Classes, Forms, URegistry, Controls; 9 9 10 10 type … … 14 14 TApplicationInfo = class(TComponent) 15 15 private 16 FDescription: string;16 FDescription: TCaption; 17 17 FIdentification: Byte; 18 18 FLicense: string; … … 57 57 58 58 implementation 59 59 60 60 procedure Register; 61 61 begin -
trunk/Packages/Common/UCommon.pas
r15 r21 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: TFilterMethodMethod); 78 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 79 function GetStringPart(var Text: string; Separator: string): string; 80 function StripTags(const S: string): string; 81 function PosFromIndex(SubStr: string; Text: string; 82 StartIndex: Integer): Integer; 83 function PosFromIndexReverse(SubStr: string; Text: string; 84 StartIndex: Integer): Integer; 85 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 76 86 77 87 … … 101 111 I: Integer; 102 112 begin 113 Result := ''; 103 114 for I := 1 to Length(Source) do begin 104 115 Result := Result + LowerCase(IntToHex(Ord(Source[I]), 2)); … … 522 533 end; 523 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 524 548 procedure SearchFiles(AList: TStrings; Dir: string; 525 FilterMethod: TFilterMethod Method);549 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 526 550 var 527 551 SR: TSearchRec; … … 531 555 try 532 556 repeat 533 if (SR.Name = '.') or (SR.Name = '..') or not FilterMethod(SR.Name) then Continue; 557 if (SR.Name = '.') or (SR.Name = '..') or (Assigned(FilterMethod) and (not FilterMethod(SR.Name) or 558 not FilterMethod(Copy(Dir, 3, Length(Dir)) + SR.Name))) then Continue; 559 if Assigned(FileNameMethod) then 560 FileNameMethod(Dir + SR.Name); 534 561 AList.Add(Dir + SR.Name); 535 562 if (SR.Attr and faDirectory) <> 0 then … … 541 568 end; 542 569 570 function GetStringPart(var Text: string; Separator: string): string; 571 var 572 P: Integer; 573 begin 574 P := Pos(Separator, Text); 575 if P > 0 then begin 576 Result := Copy(Text, 1, P - 1); 577 Delete(Text, 1, P - 1 + Length(Separator)); 578 end else begin 579 Result := Text; 580 Text := ''; 581 end; 582 Result := Trim(Result); 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; 615 end; 616 617 function PosFromIndex(SubStr: string; Text: string; 618 StartIndex: Integer): Integer; 619 var 620 I, MaxLen: SizeInt; 621 Ptr: PAnsiChar; 622 begin 623 Result := 0; 624 if (StartIndex < 1) or (StartIndex > Length(Text) - Length(SubStr)) then Exit; 625 if Length(SubStr) > 0 then begin 626 MaxLen := Length(Text) - Length(SubStr) + 1; 627 I := StartIndex; 628 Ptr := @Text[StartIndex]; 629 while (I <= MaxLen) do begin 630 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 631 Result := I; 632 Exit; 633 end; 634 Inc(I); 635 Inc(Ptr); 636 end; 637 end; 638 end; 639 640 function PosFromIndexReverse(SubStr: string; Text: string; 641 StartIndex: Integer): Integer; 642 var 643 I: SizeInt; 644 Ptr: PAnsiChar; 645 begin 646 Result := 0; 647 if (StartIndex < 1) or (StartIndex > Length(Text)) then Exit; 648 if Length(SubStr) > 0 then begin 649 I := StartIndex; 650 Ptr := @Text[StartIndex]; 651 while (I > 0) do begin 652 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 653 Result := I; 654 Exit; 655 end; 656 Dec(I); 657 Dec(Ptr); 658 end; 659 end; 660 end; 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 543 671 544 672 initialization -
trunk/Packages/Common/UDebugLog.pas
r1 r21 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 = ''); … … 104 104 if ExtractFileDir(FileName) <> '' then 105 105 ForceDirectories(ExtractFileDir(FileName)); 106 if FileExists(FileName) then LogFile := TFileStream.Create( UTF8Decode(FileName), fmOpenWrite)107 else LogFile := TFileStream.Create( UTF8Decode(FileName), fmCreate);106 if FileExists(FileName) then LogFile := TFileStream.Create(FileName, fmOpenWrite) 107 else LogFile := TFileStream.Create(FileName, fmCreate); 108 108 LogFile.Seek(0, soFromEnd); 109 109 Text := FormatDateTime('hh:nn:ss.zzz', Now) + ': ' + Text + LineEnding; … … 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; -
trunk/Packages/Common/UFindFile.pas
r1 r21 24 24 25 25 uses 26 SysUtils, Classes, Graphics, Controls, Forms, Dialogs , FileCtrl;26 SysUtils, Classes, Graphics, Controls, Forms, Dialogs; 27 27 28 28 type … … 117 117 Attr := 0; 118 118 if ffaReadOnly in FileAttr then Attr := Attr + faReadOnly; 119 if ffaHidden in FileAttr then Attr := Attr + faHidden;120 if ffaSysFile in FileAttr then Attr := Attr + faSysFile;121 if ffaVolumeID in FileAttr then Attr := Attr + faVolumeID;119 if ffaHidden in FileAttr then Attr := Attr + 2; //faHidden; use constant to avoid platform warning 120 if ffaSysFile in FileAttr then Attr := Attr + 4; //faSysFile; use constant to avoid platform warning 121 // Deprecated: if ffaVolumeID in FileAttr then Attr := Attr + faVolumeID; 122 122 if ffaDirectory in FileAttr then Attr := Attr + faDirectory; 123 123 if ffaArchive in FileAttr then Attr := Attr + faArchive; 124 124 if ffaAnyFile in FileAttr then Attr := Attr + faAnyFile; 125 125 126 if SysUtils.FindFirst( UTF8Decode(inPath + FileMask), Attr, Rec) = 0 then126 if SysUtils.FindFirst(inPath + FileMask, Attr, Rec) = 0 then 127 127 try 128 128 repeat 129 s.Add(inPath + UTF8Encode(Rec.Name));129 s.Add(inPath + Rec.Name); 130 130 until SysUtils.FindNext(Rec) <> 0; 131 131 finally … … 135 135 If not InSubFolders then Exit; 136 136 137 if SysUtils.FindFirst( UTF8Decode(inPath + FilterAll), faDirectory, Rec) = 0 then137 if SysUtils.FindFirst(inPath + FilterAll, faDirectory, Rec) = 0 then 138 138 try 139 139 repeat 140 140 if ((Rec.Attr and faDirectory) > 0) and (Rec.Name <> '.') 141 141 and (Rec.Name <> '..') then 142 FileSearch(IncludeTrailingBackslash(inPath + UTF8Encode(Rec.Name)));142 FileSearch(IncludeTrailingBackslash(inPath + Rec.Name)); 143 143 until SysUtils.FindNext(Rec) <> 0; 144 144 finally -
trunk/Packages/Common/UJobProgressView.lfm
r1 r21 1 1 object FormJobProgressView: TFormJobProgressView 2 Left = 6563 Height = 2464 Top = 3545 Width = 3282 Left = 467 3 Height = 345 4 Top = 252 5 Width = 539 6 6 BorderIcons = [biSystemMenu] 7 ClientHeight = 246 8 ClientWidth = 328 9 Font.Height = -11 10 Font.Name = 'MS Sans Serif' 7 ClientHeight = 345 8 ClientWidth = 539 9 DesignTimePPI = 120 11 10 OnClose = FormClose 12 11 OnCloseQuery = FormCloseQuery 13 12 OnCreate = FormCreate 14 13 OnDestroy = FormDestroy 14 OnHide = FormHide 15 OnShow = FormShow 15 16 Position = poScreenCenter 16 LCLVersion = ' 1.6.0.4'17 LCLVersion = '2.0.2.0' 17 18 object PanelOperationsTitle: TPanel 18 19 Left = 0 19 Height = 2420 Height = 32 20 21 Top = 0 21 Width = 32822 Align = alTop 23 BevelOuter = bvNone 24 ClientHeight = 2425 ClientWidth = 32822 Width = 539 23 Align = alTop 24 BevelOuter = bvNone 25 ClientHeight = 32 26 ClientWidth = 539 26 27 FullRepaint = False 27 28 TabOrder = 0 28 29 object LabelOperation: TLabel 29 30 Left = 8 30 Height = 1331 Height = 20 31 32 Top = 8 32 Width = 6633 Width = 76 33 34 Caption = 'Operations:' 34 Font.Height = -1135 Font.Name = 'MS Sans Serif'36 Font.Style = [fsBold]37 35 ParentColor = False 38 36 ParentFont = False … … 41 39 object PanelLog: TPanel 42 40 Left = 0 43 Height = 1 2244 Top = 12445 Width = 32841 Height = 133 42 Top = 212 43 Width = 539 46 44 Align = alClient 47 45 BevelOuter = bvSpace 48 ClientHeight = 1 2249 ClientWidth = 32846 ClientHeight = 133 47 ClientWidth = 539 50 48 TabOrder = 1 51 49 object MemoLog: TMemo 52 50 Left = 8 53 Height = 1 0651 Height = 117 54 52 Top = 8 55 Width = 31253 Width = 523 56 54 Anchors = [akTop, akLeft, akRight, akBottom] 57 55 ReadOnly = True … … 62 60 object PanelProgress: TPanel 63 61 Left = 0 64 Height = 3865 Top = 5066 Width = 32867 Align = alTop 68 BevelOuter = bvNone 69 ClientHeight = 3870 ClientWidth = 32862 Height = 54 63 Top = 106 64 Width = 539 65 Align = alTop 66 BevelOuter = bvNone 67 ClientHeight = 54 68 ClientWidth = 539 71 69 TabOrder = 2 72 70 object ProgressBarPart: TProgressBar 73 Left = 874 Height = 1775 Top = 1676 Width = 31271 Left = 10 72 Height = 24 73 Top = 24 74 Width = 523 77 75 Anchors = [akTop, akLeft, akRight] 78 76 TabOrder = 0 … … 80 78 object LabelEstimatedTimePart: TLabel 81 79 Left = 8 82 Height = 1380 Height = 20 83 81 Top = -2 84 Width = 7182 Width = 103 85 83 Caption = 'Estimated time:' 86 84 ParentColor = False … … 89 87 object PanelOperations: TPanel 90 88 Left = 0 91 Height = 2692 Top = 2493 Width = 32894 Align = alTop 95 BevelOuter = bvNone 96 ClientHeight = 2697 ClientWidth = 32889 Height = 42 90 Top = 64 91 Width = 539 92 Align = alTop 93 BevelOuter = bvNone 94 ClientHeight = 42 95 ClientWidth = 539 98 96 FullRepaint = False 99 97 TabOrder = 3 100 98 object ListViewJobs: TListView 101 99 Left = 8 102 Height = 16100 Height = 32 103 101 Top = 5 104 Width = 312102 Width = 523 105 103 Anchors = [akTop, akLeft, akRight, akBottom] 106 104 AutoWidthLastColumn = True … … 109 107 Columns = < 110 108 item 111 Width = 312109 Width = 523 112 110 end> 113 111 OwnerData = True … … 122 120 object PanelProgressTotal: TPanel 123 121 Left = 0 124 Height = 36125 Top = 88126 Width = 328127 Align = alTop 128 BevelOuter = bvNone 129 ClientHeight = 36130 ClientWidth = 328122 Height = 52 123 Top = 160 124 Width = 539 125 Align = alTop 126 BevelOuter = bvNone 127 ClientHeight = 52 128 ClientWidth = 539 131 129 TabOrder = 4 132 130 object LabelEstimatedTimeTotal: TLabel 133 131 Left = 8 134 Height = 13132 Height = 20 135 133 Top = 0 136 Width = 97134 Width = 141 137 135 Caption = 'Total estimated time:' 138 136 ParentColor = False … … 140 138 object ProgressBarTotal: TProgressBar 141 139 Left = 8 142 Height = 16143 Top = 16144 Width = 312140 Height = 24 141 Top = 24 142 Width = 523 145 143 Anchors = [akTop, akLeft, akRight] 146 144 TabOrder = 0 145 end 146 end 147 object PanelText: TPanel 148 Left = 0 149 Height = 32 150 Top = 32 151 Width = 539 152 Align = alTop 153 BevelOuter = bvNone 154 ClientHeight = 32 155 ClientWidth = 539 156 TabOrder = 5 157 object LabelText: TLabel 158 Left = 8 159 Height = 24 160 Top = 8 161 Width = 525 162 Anchors = [akTop, akLeft, akRight] 163 AutoSize = False 164 ParentColor = False 147 165 end 148 166 end … … 223 241 Interval = 100 224 242 OnTimer = TimerUpdateTimer 225 left = 264243 left = 320 226 244 top = 8 227 245 end -
trunk/Packages/Common/UJobProgressView.pas
r1 r21 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, Syncobjs, 9 Dialogs, ComCtrls, StdCtrls, ExtCtrls, Contnrs, UThreading, 9 Dialogs, ComCtrls, StdCtrls, ExtCtrls, Contnrs, UThreading, Math, 10 10 DateUtils; 11 11 … … 13 13 EstimatedTimeShowTreshold = 4; 14 14 EstimatedTimeShowTresholdTotal = 1; 15 MemoLogHeight = 200;16 15 UpdateInterval = 100; // ms 17 16 … … 24 23 FLock: TCriticalSection; 25 24 FOnChange: TNotifyEvent; 25 FText: string; 26 26 FValue: Integer; 27 27 FMax: Integer; 28 28 procedure SetMax(const AValue: Integer); 29 procedure SetText(AValue: string); 29 30 procedure SetValue(const AValue: Integer); 30 31 public … … 35 36 property Value: Integer read FValue write SetValue; 36 37 property Max: Integer read FMax write SetMax; 38 property Text: string read FText write SetText; 37 39 property OnChange: TNotifyEvent read FOnChange write FOnChange; 38 40 end; … … 69 71 end; 70 72 73 TJobs = class(TObjectList) 74 end; 75 71 76 TJobThread = class(TListedThread) 72 77 procedure Execute; override; … … 80 85 TFormJobProgressView = class(TForm) 81 86 ImageList1: TImageList; 87 LabelText: TLabel; 82 88 Label2: TLabel; 83 89 LabelOperation: TLabel; … … 86 92 ListViewJobs: TListView; 87 93 MemoLog: TMemo; 94 PanelText: TPanel; 88 95 PanelProgressTotal: TPanel; 89 96 PanelOperationsTitle: TPanel; … … 94 101 ProgressBarTotal: TProgressBar; 95 102 TimerUpdate: TTimer; 103 procedure FormHide(Sender: TObject); 104 procedure FormShow(Sender: TObject); 105 procedure ReloadJobList; 96 106 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 97 107 procedure FormDestroy(Sender: TObject); … … 100 110 procedure FormCreate(Sender: TObject); 101 111 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 112 procedure UpdateHeight; 102 113 public 103 114 JobProgressView: TJobProgressView; … … 118 129 TotalStartTime: TDateTime; 119 130 Log: TStringList; 131 FForm: TFormJobProgressView; 120 132 procedure SetTerminate(const AValue: Boolean); 121 133 procedure UpdateProgress; 122 procedure ReloadJobList;123 procedure StartJobs;124 procedure UpdateHeight;125 134 procedure JobProgressChange(Sender: TObject); 126 135 public 127 Form: TFormJobProgressView; 128 Jobs: TObjectList; // TListObject<TJob> 136 Jobs: TJobs; 129 137 CurrentJob: TJob; 130 138 CurrentJobIndex: Integer; … … 132 140 destructor Destroy; override; 133 141 procedure Clear; 134 procedureAddJob(Title: string; Method: TJobProgressViewMethod;135 NoThreaded: Boolean = False; WaitFor: Boolean = False) ;136 procedure Start (AAutoClose: Boolean = True);142 function AddJob(Title: string; Method: TJobProgressViewMethod; 143 NoThreaded: Boolean = False; WaitFor: Boolean = False): TJob; 144 procedure Start; 137 145 procedure Stop; 138 146 procedure TermSleep(Delay: Integer); 147 property Form: TFormJobProgressView read FForm; 139 148 property Terminate: Boolean read FTerminate write SetTerminate; 140 149 published … … 166 175 STotalEstimatedTime = 'Total estimated time: %s'; 167 176 SFinished = 'Finished'; 168 SOperations = 'Operations';169 177 170 178 procedure Register; … … 172 180 RegisterComponents('Common', [TJobProgressView]); 173 181 end; 182 183 { TJobThread } 174 184 175 185 procedure TJobThread.Execute; … … 190 200 end; 191 201 192 procedure TJobProgressView.AddJob(Title: string; Method: TJobProgressViewMethod; 193 NoThreaded: Boolean = False; WaitFor: Boolean = False); 202 { TFormJobProgressView } 203 204 procedure TFormJobProgressView.UpdateHeight; 194 205 var 195 NewJob: TJob; 196 begin 197 NewJob := TJob.Create; 198 NewJob.ProgressView := Self; 199 NewJob.Title := Title; 200 NewJob.Method := Method; 201 NewJob.NoThreaded := NoThreaded; 202 NewJob.WaitFor := WaitFor; 203 NewJob.Progress.Max := 100; 204 NewJob.Progress.Reset; 205 NewJob.Progress.OnChange := JobProgressChange; 206 Jobs.Add(NewJob); 206 H: Integer; 207 PanelOperationsVisible: Boolean; 208 PanelOperationsHeight: Integer; 209 PanelProgressVisible: Boolean; 210 PanelProgressTotalVisible: Boolean; 211 PanelLogVisible: Boolean; 212 MemoLogHeight: Integer = 200; 213 I: Integer; 214 ItemRect: TRect; 215 MaxH: Integer; 216 begin 217 H := PanelOperationsTitle.Height; 218 PanelOperationsVisible := JobProgressView.Jobs.Count > 0; 219 if PanelOperationsVisible <> PanelOperations.Visible then 220 PanelOperations.Visible := PanelOperationsVisible; 221 if ListViewJobs.Items.Count > 0 then begin 222 Maxh := 0; 223 for I := 0 to ListViewJobs.Items.Count - 1 do 224 begin 225 ItemRect := ListViewJobs.Items[i].DisplayRect(drBounds); 226 Maxh := Max(Maxh, ItemRect.Top + (ItemRect.Bottom - ItemRect.Top)); 227 end; 228 PanelOperationsHeight := Scale96ToScreen(12) + Maxh; 229 end else PanelOperationsHeight := Scale96ToScreen(8); 230 if PanelOperationsHeight <> PanelOperations.Height then 231 PanelOperations.Height := PanelOperationsHeight; 232 if PanelOperationsVisible then 233 H := H + PanelOperations.Height; 234 235 PanelProgressVisible := (JobProgressView.Jobs.Count > 0) and not JobProgressView.Finished; 236 if PanelProgressVisible <> PanelProgress.Visible then 237 PanelProgress.Visible := PanelProgressVisible; 238 if PanelProgressVisible then 239 H := H + PanelProgress.Height; 240 PanelProgressTotalVisible := (JobProgressView.Jobs.Count > 1) and not JobProgressView.Finished; 241 if PanelProgressTotalVisible <> PanelProgressTotal.Visible then 242 PanelProgressTotal.Visible := PanelProgressTotalVisible; 243 if PanelProgressTotalVisible then 244 H := H + PanelProgressTotal.Height; 245 Constraints.MinHeight := H; 246 PanelLogVisible := MemoLog.Lines.Count > 0; 247 if PanelLogVisible <> PanelLog.Visible then 248 PanelLog.Visible := PanelLogVisible; 249 if PanelLogVisible then 250 H := H + Scale96ToScreen(MemoLogHeight); 251 if PanelText.Visible then 252 H := H + PanelText.Height; 253 if Height <> H then begin 254 Height := H; 255 Top := (Screen.Height - H) div 2; 256 end; 257 end; 258 259 procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject); 260 var 261 ProgressBarPartVisible: Boolean; 262 ProgressBarTotalVisible: Boolean; 263 begin 264 JobProgressView.UpdateProgress; 265 if Visible and (not ProgressBarPart.Visible) and 266 Assigned(JobProgressView.CurrentJob) and 267 (JobProgressView.CurrentJob.Progress.Value > 0) then begin 268 ProgressBarPartVisible := True; 269 if ProgressBarPartVisible <> ProgressBarPart.Visible then 270 ProgressBarPart.Visible := ProgressBarPartVisible; 271 ProgressBarTotalVisible := True; 272 if ProgressBarTotalVisible <> ProgressBarTotal.Visible then 273 ProgressBarTotal.Visible := ProgressBarTotalVisible; 274 end; 275 if not Visible then begin 276 TimerUpdate.Interval := UpdateInterval; 277 if not JobProgressView.OwnerDraw then Show; 278 end; 279 if Assigned(JobProgressView.CurrentJob) then begin 280 LabelText.Caption := JobProgressView.CurrentJob.Progress.Text; 281 if LabelText.Caption <> '' then begin 282 PanelText.Visible := True; 283 UpdateHeight; 284 end; 285 end; 286 end; 287 288 procedure TFormJobProgressView.FormDestroy(Sender:TObject); 289 begin 290 end; 291 292 procedure TFormJobProgressView.ListViewJobsData(Sender: TObject; Item: TListItem); 293 begin 294 if (Item.Index >= 0) and (Item.Index < JobProgressView.Jobs.Count) then 295 with TJob(JobProgressView.Jobs[Item.Index]) do begin 296 Item.Caption := Title; 297 if Item.Index = JobProgressView.CurrentJobIndex then Item.ImageIndex := 1 298 else if Finished then Item.ImageIndex := 0 299 else Item.ImageIndex := 2; 300 Item.Data := JobProgressView.Jobs[Item.Index]; 301 end; 302 end; 303 304 procedure TFormJobProgressView.FormClose(Sender: TObject; 305 var CloseAction: TCloseAction); 306 begin 307 end; 308 309 procedure TFormJobProgressView.FormCreate(Sender: TObject); 310 begin 311 Caption := SPleaseWait; 312 try 313 //Animate1.FileName := ExtractFileDir(UTF8Encode(Application.ExeName)) + 314 // DirectorySeparator + 'horse.avi'; 315 //Animate1.Active := True; 316 except 317 318 end; 319 end; 320 321 procedure TFormJobProgressView.ReloadJobList; 322 begin 323 // Workaround for not showing first line 324 //Form.ListViewJobs.Items.Count := Jobs.Count + 1; 325 //Form.ListViewJobs.Refresh; 326 327 if ListViewJobs.Items.Count <> JobProgressView.Jobs.Count then 328 ListViewJobs.Items.Count := JobProgressView.Jobs.Count; 329 ListViewJobs.Refresh; 330 Application.ProcessMessages; 331 UpdateHeight; 332 end; 333 334 procedure TFormJobProgressView.FormShow(Sender: TObject); 335 begin 336 ReloadJobList; 337 end; 338 339 procedure TFormJobProgressView.FormHide(Sender: TObject); 340 begin 341 JobProgressView.Jobs.Clear; 342 ReloadJobList; 343 end; 344 345 procedure TFormJobProgressView.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 346 begin 347 CanClose := JobProgressView.Finished; 348 JobProgressView.Terminate := True; 349 Caption := SPleaseWait + STerminate; 350 end; 351 352 353 { TJobProgressView } 354 355 function TJobProgressView.AddJob(Title: string; Method: TJobProgressViewMethod; 356 NoThreaded: Boolean = False; WaitFor: Boolean = False): TJob; 357 begin 358 Result := TJob.Create; 359 Result.ProgressView := Self; 360 Result.Title := Title; 361 Result.Method := Method; 362 Result.NoThreaded := NoThreaded; 363 Result.WaitFor := WaitFor; 364 Result.Progress.Max := 100; 365 Result.Progress.Reset; 366 Result.Progress.OnChange := JobProgressChange; 367 Jobs.Add(Result); 207 368 //ReloadJobList; 208 369 end; 209 370 210 procedure TJobProgressView.Start(AAutoClose: Boolean = True); 211 begin 212 AutoClose := AAutoClose; 213 StartJobs; 214 end; 215 216 procedure TJobProgressView.StartJobs; 371 procedure TJobProgressView.Start; 217 372 var 218 373 I: Integer; … … 229 384 Form.MemoLog.Clear; 230 385 386 Form.PanelText.Visible := False; 231 387 Form.LabelEstimatedTimePart.Visible := False; 232 388 Form.LabelEstimatedTimeTotal.Visible := False; … … 258 414 Form.ProgressBarPart.Visible := False; 259 415 //Show; 260 ReloadJobList;416 Form.ReloadJobList; 261 417 Application.ProcessMessages; 262 418 if NoThreaded then begin … … 296 452 //if Visible then Hide; 297 453 Form.MemoLog.Lines.Assign(Log); 298 if (Form.MemoLog.Lines.Count = 0) and AutoClose then begin454 if (Form.MemoLog.Lines.Count = 0) and FAutoClose then begin 299 455 Form.Hide; 300 456 end; 301 Clear;457 if not Form.Visible then Clear; 302 458 Form.Caption := SFinished; 303 459 //LabelEstimatedTimePart.Visible := False; 304 460 Finished := True; 305 461 CurrentJobIndex := -1; 306 ReloadJobList; 307 end; 308 end; 309 310 procedure TJobProgressView.UpdateHeight; 311 var 312 H: Integer; 313 PanelOperationsVisible: Boolean; 314 PanelOperationsHeight: Integer; 315 PanelProgressVisible: Boolean; 316 PanelProgressTotalVisible: Boolean; 317 PanelLogVisible: Boolean; 318 begin 319 with Form do begin 320 H := PanelOperationsTitle.Height; 321 PanelOperationsVisible := Jobs.Count > 0; 322 if PanelOperationsVisible <> PanelOperations.Visible then 323 PanelOperations.Visible := PanelOperationsVisible; 324 PanelOperationsHeight := 8 + 18 * Jobs.Count; 325 if PanelOperationsHeight <> PanelOperations.Height then 326 PanelOperations.Height := PanelOperationsHeight; 327 if PanelOperationsVisible then 328 H := H + PanelOperations.Height; 329 330 PanelProgressVisible := (Jobs.Count > 0) and not Finished; 331 if PanelProgressVisible <> PanelProgress.Visible then 332 PanelProgress.Visible := PanelProgressVisible; 333 if PanelProgressVisible then 334 H := H + PanelProgress.Height; 335 PanelProgressTotalVisible := (Jobs.Count > 1) and not Finished; 336 if PanelProgressTotalVisible <> PanelProgressTotal.Visible then 337 PanelProgressTotal.Visible := PanelProgressTotalVisible; 338 if PanelProgressTotalVisible then 339 H := H + PanelProgressTotal.Height; 340 Constraints.MinHeight := H; 341 PanelLogVisible := MemoLog.Lines.Count > 0; 342 if PanelLogVisible <> PanelLog.Visible then 343 PanelLog.Visible := PanelLogVisible; 344 if PanelLogVisible then 345 H := H + MemoLogHeight; 346 if Height <> H then Height := H; 462 Form.ReloadJobList; 347 463 end; 348 464 end; … … 352 468 if Assigned(FOnOwnerDraw) then 353 469 FOnOwnerDraw(Self); 354 end;355 356 procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject);357 var358 ProgressBarPartVisible: Boolean;359 ProgressBarTotalVisible: Boolean;360 begin361 JobProgressView.UpdateProgress;362 if Visible and (not ProgressBarPart.Visible) and363 Assigned(JobProgressView.CurrentJob) and364 (JobProgressView.CurrentJob.Progress.Value > 0) then begin365 ProgressBarPartVisible := True;366 if ProgressBarPartVisible <> ProgressBarPart.Visible then367 ProgressBarPart.Visible := ProgressBarPartVisible;368 ProgressBarTotalVisible := True;369 if ProgressBarTotalVisible <> ProgressBarTotal.Visible then370 ProgressBarTotal.Visible := ProgressBarTotalVisible;371 end;372 if not Visible then begin373 TimerUpdate.Interval := UpdateInterval;374 if not JobProgressView.OwnerDraw then Show;375 end;376 end;377 378 procedure TFormJobProgressView.FormDestroy(Sender:TObject);379 begin380 end;381 382 procedure TFormJobProgressView.ListViewJobsData(Sender: TObject; Item: TListItem);383 begin384 if (Item.Index >= 0) and (Item.Index < JobProgressView.Jobs.Count) then385 with TJob(JobProgressView.Jobs[Item.Index]) do begin386 Item.Caption := Title;387 if Item.Index = JobProgressView.CurrentJobIndex then Item.ImageIndex := 1388 else if Finished then Item.ImageIndex := 0389 else Item.ImageIndex := 2;390 Item.Data := JobProgressView.Jobs[Item.Index];391 end;392 end;393 394 procedure TFormJobProgressView.FormClose(Sender: TObject;395 var CloseAction: TCloseAction);396 begin397 ListViewJobs.Clear;398 end;399 400 procedure TFormJobProgressView.FormCreate(Sender: TObject);401 begin402 Caption := SPleaseWait;403 try404 //Animate1.FileName := ExtractFileDir(UTF8Encode(Application.ExeName)) +405 // DirectorySeparator + 'horse.avi';406 //Animate1.Active := True;407 except408 409 end;410 470 end; 411 471 … … 426 486 Sleep(Quantum); 427 487 end; 428 end;429 430 procedure TFormJobProgressView.FormCloseQuery(Sender: TObject; var CanClose: Boolean);431 begin432 CanClose := JobProgressView.Finished;433 JobProgressView.Terminate := True;434 Caption := SPleaseWait + STerminate;435 488 end; 436 489 … … 490 543 end; 491 544 492 procedure TJobProgressView.ReloadJobList;493 begin494 UpdateHeight;495 // Workaround for not showing first line496 Form.ListViewJobs.Items.Count := Jobs.Count + 1;497 Form.ListViewJobs.Refresh;498 499 if Form.ListViewJobs.Items.Count <> Jobs.Count then500 Form.ListViewJobs.Items.Count := Jobs.Count;501 Form.ListViewJobs.Refresh;502 //Application.ProcessMessages;503 end;504 505 545 constructor TJobProgressView.Create(TheOwner: TComponent); 506 546 begin 507 547 inherited; 508 548 if not (csDesigning in ComponentState) then begin 509 F orm := TFormJobProgressView.Create(Self);510 F orm.JobProgressView := Self;511 end; 512 Jobs := T ObjectList.Create;549 FForm := TFormJobProgressView.Create(Self); 550 FForm.JobProgressView := Self; 551 end; 552 Jobs := TJobs.Create; 513 553 Log := TStringList.Create; 514 554 //PanelOperationsTitle.Height := 80; 515 ShowDelay := 0; //1000; // ms 555 AutoClose := True; 556 ShowDelay := 0; 516 557 end; 517 558 … … 519 560 begin 520 561 Jobs.Clear; 562 Log.Clear; 521 563 //ReloadJobList; 522 564 end; … … 528 570 inherited; 529 571 end; 572 573 { TProgress } 530 574 531 575 procedure TProgress.SetMax(const AValue: Integer); … … 536 580 if FMax < 1 then FMax := 1; 537 581 if FValue >= FMax then FValue := FMax; 582 finally 583 FLock.Release; 584 end; 585 end; 586 587 procedure TProgress.SetText(AValue: string); 588 begin 589 try 590 FLock.Acquire; 591 if FText = AValue then Exit; 592 FText := AValue; 538 593 finally 539 594 FLock.Release; … … 563 618 end; 564 619 565 { TProgress }566 567 620 procedure TProgress.Increment; 568 621 begin -
trunk/Packages/Common/ULastOpenedList.pas
r1 r21 6 6 7 7 uses 8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf ;8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf, DOM; 9 9 10 10 type … … 30 30 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 31 31 procedure AddItem(FileName: string); 32 function GetFirstFileName: string; 32 33 published 33 34 property MaxCount: Integer read FMaxCount write SetMaxCount; … … 139 140 OpenKey(Context.Key, True); 140 141 for I := 0 to Items.Count - 1 do 141 WriteString('File' + IntToStr(I), UTF8Decode(Items[I]));142 WriteString('File' + IntToStr(I), Items[I]); 142 143 finally 143 144 Free; … … 153 154 begin 154 155 with XMLConfig do begin 155 Count := GetValue( Path + '/Count', 0);156 Count := GetValue(DOMString(Path + '/Count'), 0); 156 157 if Count > MaxCount then Count := MaxCount; 157 158 Items.Clear; 158 159 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), '');160 Value := string(GetValue(DOMString(Path + '/File' + IntToStr(I)), '')); 160 161 if Trim(Value) <> '' then Items.Add(Value); 161 162 end; … … 170 171 begin 171 172 with XMLConfig do begin 172 SetValue( Path + '/Count', Items.Count);173 SetValue(DOMString(Path + '/Count'), Items.Count); 173 174 for I := 0 to Items.Count - 1 do 174 SetValue( Path + '/File' + IntToStr(I), Items[I]);175 SetValue(DOMString(Path + '/File' + IntToStr(I)), DOMString(Items[I])); 175 176 Flush; 176 177 end; … … 185 186 end; 186 187 188 function TLastOpenedList.GetFirstFileName: string; 189 begin 190 if Items.Count > 0 then Result := Items[0] 191 else Result := ''; 192 end; 193 187 194 end. 188 195 -
trunk/Packages/Common/UListViewSort.pas
r15 r21 9 9 uses 10 10 {$IFDEF Windows}Windows, CommCtrl, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils, 11 Controls, DateUtils, Dialogs, SpecializedList, Forms, Grids, StdCtrls, ExtCtrls,11 Controls, DateUtils, Dialogs, fgl, Forms, Grids, StdCtrls, ExtCtrls, 12 12 LclIntf, LMessages, LclType, LResources; 13 13 … … 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 … … 142 184 var 143 185 I: Integer; 186 R: TRect; 144 187 begin 145 188 with FStringGrid1 do begin 146 Options := Options - [goEditing, goAlwaysShowEditor];147 //Columns.Clear;148 189 while Columns.Count > ListView.Columns.Count do Columns.Delete(Columns.Count - 1); 149 190 while Columns.Count < ListView.Columns.Count do Columns.Add; 150 191 for I := 0 to ListView.Columns.Count - 1 do begin 151 192 Columns[I].Width := ListView.Columns[I].Width; 193 if Selection.Left = I then begin 194 R := CellRect(I, 0); 195 Editor.Left := R.Left + 2; 196 Editor.Width := R.Width - 4; 197 end; 152 198 end; 153 Options := Options + [goEditing, goAlwaysShowEditor];154 199 end; 155 200 end; … … 274 319 end; 275 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 276 329 procedure TListViewSort.Sort(Compare: TCompareEvent); 277 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; 278 334 if (List.Count > 0) then 279 List.Sort( Compare);335 List.Sort(ListViewCompare); 280 336 end; 281 337 … … 340 396 begin 341 397 inherited; 342 List := T ListObject.Create;343 List. OwnsObjects := False;398 List := TFPGObjectList<TObject>.Create; 399 List.FreeObjects := False; 344 400 end; 345 401 … … 381 437 ItemLeft := Item.Left; 382 438 ItemLeft := 23; // Windows 7 workaround 383 439 384 440 Rect1.Left := ItemLeft - CheckWidth - BiasLeft + 1 + XBias; 385 441 //ShowMessage(IntToStr(Tp1.Y) + ', ' + IntToStr(BiasTop) + ', ' + IntToStr(XBias)); … … 480 536 FHeaderHandle := ListView_GetHeader(FListView.Handle); 481 537 for I := 0 to FListView.Columns.Count - 1 do begin 538 {$push}{$warn 5057 off} 482 539 FillChar(Item, SizeOf(THDItem), 0); 540 {$pop} 483 541 Item.Mask := HDI_FORMAT; 484 542 Header_GetItem(FHeaderHandle, I, Item); -
trunk/Packages/Common/UMemory.pas
r1 r21 24 24 constructor Create; 25 25 destructor Destroy; override; 26 procedure WriteMemory(Position: Integer; Memory: TMemory); 27 procedure ReadMemory(Position: Integer; Memory: TMemory); 26 28 property Data: PByte read FData; 27 29 property Size: Integer read FSize write SetSize; … … 108 110 end; 109 111 112 procedure TMemory.WriteMemory(Position: Integer; Memory: TMemory); 113 begin 114 Move(Memory.FData, PByte(PByte(@FData) + Position)^, Memory.Size); 115 end; 116 117 procedure TMemory.ReadMemory(Position: Integer; Memory: TMemory); 118 begin 119 Move(PByte(PByte(@FData) + Position)^, Memory.FData, Memory.Size); 120 end; 121 110 122 end. 111 123 -
trunk/Packages/Common/UPersistentForm.pas
r1 r21 8 8 9 9 uses 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls; 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls, 11 ExtCtrls; 11 12 12 13 type … … 56 57 I: Integer; 57 58 WinControl: TWinControl; 58 Count: Integer;59 59 begin 60 60 if Control is TListView then begin … … 72 72 end; 73 73 74 if (Control is TPanel) then begin 75 with Form, TRegistryEx.Create do 76 try 77 RootKey := RegistryContext.RootKey; 78 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True); 79 if (TPanel(Control).Align = alRight) or (TPanel(Control).Align = alLeft) then begin 80 if ValueExists('Width') then 81 TPanel(Control).Width := ReadInteger('Width'); 82 end; 83 if (TPanel(Control).Align = alTop) or (TPanel(Control).Align = alBottom) then begin 84 if ValueExists('Height') then 85 TPanel(Control).Height := ReadInteger('Height'); 86 end; 87 finally 88 Free; 89 end; 90 end; 91 74 92 if Control is TWinControl then begin 75 93 WinControl := TWinControl(Control); … … 96 114 for I := 0 to TListView(Control).Columns.Count - 1 do begin 97 115 WriteInteger('ColWidth' + IntToStr(I), TListView(Control).Columns[I].Width); 116 end; 117 finally 118 Free; 119 end; 120 end; 121 122 if (Control is TPanel) then begin 123 with Form, TRegistryEx.Create do 124 try 125 RootKey := RegistryContext.RootKey; 126 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True); 127 if (TPanel(Control).Align = alRight) or (TPanel(Control).Align = alLeft) then begin 128 WriteInteger('Width', TPanel(Control).Width); 129 end; 130 if (TPanel(Control).Align = alTop) or (TPanel(Control).Align = alBottom) then begin 131 WriteInteger('Height', TPanel(Control).Height); 98 132 end; 99 133 finally … … 217 251 218 252 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False); 219 var220 LoadDefaults: Boolean;221 253 begin 222 254 Self.Form := Form; … … 230 262 231 263 if not EqualRect(FormNormalSize, FormRestoredSize) or 232 (LoadDefaults and DefaultMaximized)then begin264 DefaultMaximized then begin 233 265 // Restore to maximized state 234 266 Form.WindowState := wsNormal; -
trunk/Packages/Common/UPool.pas
r1 r21 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; -
trunk/Packages/Common/UPrefixMultiplier.pas
r1 r21 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; -
trunk/Packages/Common/URegistry.pas
r1 r21 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; -
trunk/Packages/Common/UResetableThread.pas
r1 r21 156 156 FThread.Name := 'ResetableThread'; 157 157 FThread.Parent := Self; 158 FThread. Resume;158 FThread.Start; 159 159 end; 160 160 -
trunk/Packages/Common/UScaleDPI.pas
r1 r21 215 215 I: Integer; 216 216 begin 217 ImgList.BeginUpdate; 217 218 NewWidth := ScaleX(ImgList.Width, FromDPI.X); 218 219 NewHeight := ScaleY(ImgList.Height, FromDPI.Y); … … 248 249 Temp[i].Free; 249 250 end; 251 ImgList.EndUpdate; 250 252 end; 251 253 … … 287 289 //OldAutoSize: Boolean; 288 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 289 304 //if Control is TMemo then Exit; 290 305 //if Control is TForm then … … 338 353 end; 339 354 340 //if not (Control is TCustomPage) then341 if Control is TWinControl then begin342 WinControl := TWinControl(Control);343 if WinControl.ControlCount > 0 then begin344 for I := 0 to WinControl.ControlCount - 1 do begin345 if WinControl.Controls[I] is TControl then begin346 ScaleControl(WinControl.Controls[I], FromDPI);347 end;348 end;349 end;350 end;351 355 //if Control is TForm then 352 356 // Control.EnableAutoSizing; -
trunk/Packages/Common/UTheme.pas
r15 r21 132 132 I: Integer; 133 133 begin 134 for I := 0 to Component.ComponentCount - 1 do 135 ApplyTheme(Component.Components[I]); 134 if Component is TWinControl then begin 135 for I := 0 to TWinControl(Component).ControlCount - 1 do 136 ApplyTheme(TWinControl(Component).Controls[I]); 137 end; 136 138 137 139 if Component is TControl then begin … … 139 141 if (Control is TEdit) or (Control is TSpinEdit) or (Control is TComboBox) and 140 142 (Control is TMemo) or (Control is TListView) or (Control is TCustomDrawGrid) or 141 (Control is TCheckBox) then begin143 (Control is TCheckBox) or (Control is TPageControl) or (Control is TRadioButton) then begin 142 144 Control.Color := FTheme.ColorWindow; 143 145 Control.Font.Color := FTheme.ColorWindowText; … … 150 152 (Control as TCustomDrawGrid).Editor.Color := FTheme.ColorWindow; 151 153 (Control as TCustomDrawGrid).Editor.Font.Color := FTheme.ColorWindowText; 154 end; 155 156 if Control is TPageControl then begin 157 for I := 0 to TPageControl(Component).PageCount - 1 do 158 ApplyTheme(TPageControl(Component).Pages[I]); 159 end; 160 161 if Control is TCoolBar then begin 162 (Control as TCoolBar).Themed := False; 152 163 end; 153 164 end; -
trunk/Packages/Common/UThreading.pas
r1 r21 30 30 Name: string; 31 31 procedure Execute; virtual; abstract; 32 procedure Resume; virtual; abstract;33 procedure Suspend; virtual; abstract;34 32 procedure Start; virtual; abstract; 35 33 procedure Terminate; virtual; abstract; … … 81 79 procedure Sleep(Delay: Integer); override; 82 80 procedure Execute; override; 83 procedure Resume; override;84 procedure Suspend; override;85 81 procedure Start; override; 86 82 procedure Terminate; override; … … 134 130 Thread.FreeOnTerminate := False; 135 131 Thread.Method := Method; 136 Thread. Resume;132 Thread.Start; 137 133 while (Thread.State = ttsRunning) or (Thread.State = ttsReady) do begin 138 134 if MainThreadID = ThreadID then Application.ProcessMessages; … … 155 151 Thread.Method := Method; 156 152 Thread.OnFinished := CallBack; 157 Thread. Resume;153 Thread.Start; 158 154 //if Thread.State = ttsExceptionOccured then 159 155 // raise Exception.Create(Thread.ExceptionMessage); … … 313 309 procedure TListedThread.Execute; 314 310 begin 315 end;316 317 procedure TListedThread.Resume;318 begin319 FThread.Resume;320 end;321 322 procedure TListedThread.Suspend;323 begin324 FThread.Suspend;325 311 end; 326 312 -
trunk/Packages/Common/UURI.pas
r1 r21 89 89 function LeftCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 90 90 var 91 I , J: Integer;91 I: Integer; 92 92 Matched: Boolean; 93 93 begin … … 113 113 function RightCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 114 114 var 115 I , J: Integer;115 I: Integer; 116 116 Matched: Boolean; 117 117 begin … … 202 202 203 203 procedure TURI.SetAsString(Value: string); 204 var205 HostAddr: string;206 HostPort: string;207 204 begin 208 205 LeftCutString(Value, Scheme, ':'); -
trunk/Packages/Common/UXMLUtils.pas
r1 r21 7 7 uses 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM;9 Classes, SysUtils, DateUtils, DOM, xmlread; 10 10 11 11 function XMLTimeToDateTime(XMLDateTime: string): TDateTime; 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 13 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); … … 21 21 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 22 22 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 23 procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string); 23 24 24 25 25 26 implementation 27 28 procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string); 29 var 30 Parser: TDOMParser; 31 Src: TXMLInputSource; 32 InFile: TFileStream; 33 begin 34 try 35 InFile := TFileStream.Create(FileName, fmOpenRead); 36 Src := TXMLInputSource.Create(InFile); 37 Parser := TDOMParser.Create; 38 Parser.Options.PreserveWhitespace := True; 39 Parser.Parse(Src, Doc); 40 finally 41 Src.Free; 42 Parser.Free; 43 InFile.Free; 44 end; 45 end; 26 46 27 47 function GetTimeZoneBias: Integer; … … 30 50 TimeZoneInfo: TTimeZoneInformation; 31 51 begin 52 {$push}{$warn 5057 off} 32 53 case GetTimeZoneInformation(TimeZoneInfo) of 33 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias;34 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias;54 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias; 55 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias; 35 56 else 36 57 Result := 0; 37 58 end; 59 {$pop} 38 60 end; 39 61 {$ELSE} … … 45 67 function LeftCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 46 68 var 47 I , J: Integer;69 I: Integer; 48 70 Matched: Boolean; 49 71 begin … … 99 121 if Pos('Z', XMLDateTime) > 0 then 100 122 LeftCutString(XMLDateTime, Part, 'Z'); 101 SecondFraction := StrToFloat('0' + De cimalSeparator + Part);123 SecondFraction := StrToFloat('0' + DefaultFormatSettings.DecimalSeparator + Part); 102 124 Millisecond := Trunc(SecondFraction * 1000); 103 125 end else begin … … 118 140 end; 119 141 120 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;142 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 121 143 const 122 144 Neg: array[Boolean] of string = ('+', '-'); … … 139 161 NewNode: TDOMNode; 140 162 begin 141 NewNode := Node.OwnerDocument.CreateElement( Name);142 NewNode.TextContent := IntToStr(Value);163 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 164 NewNode.TextContent := DOMString(IntToStr(Value)); 143 165 Node.AppendChild(NewNode); 144 166 end; … … 148 170 NewNode: TDOMNode; 149 171 begin 150 NewNode := Node.OwnerDocument.CreateElement( Name);151 NewNode.TextContent := IntToStr(Value);172 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 173 NewNode.TextContent := DOMString(IntToStr(Value)); 152 174 Node.AppendChild(NewNode); 153 175 end; … … 157 179 NewNode: TDOMNode; 158 180 begin 159 NewNode := Node.OwnerDocument.CreateElement( Name);160 NewNode.TextContent := BoolToStr(Value);181 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 182 NewNode.TextContent := DOMString(BoolToStr(Value)); 161 183 Node.AppendChild(NewNode); 162 184 end; … … 166 188 NewNode: TDOMNode; 167 189 begin 168 NewNode := Node.OwnerDocument.CreateElement( Name);169 NewNode.TextContent := Value;190 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 191 NewNode.TextContent := DOMString(Value); 170 192 Node.AppendChild(NewNode); 171 193 end; … … 175 197 NewNode: TDOMNode; 176 198 begin 177 NewNode := Node.OwnerDocument.CreateElement( Name);178 NewNode.TextContent := D ateTimeToXMLTime(Value);199 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 200 NewNode.TextContent := DOMString(DateTimeToXMLTime(Value)); 179 201 Node.AppendChild(NewNode); 180 202 end; … … 185 207 begin 186 208 Result := DefaultValue; 187 NewNode := Node.FindNode( Name);188 if Assigned(NewNode) then 189 Result := StrToInt( NewNode.TextContent);209 NewNode := Node.FindNode(DOMString(Name)); 210 if Assigned(NewNode) then 211 Result := StrToInt(string(NewNode.TextContent)); 190 212 end; 191 213 … … 195 217 begin 196 218 Result := DefaultValue; 197 NewNode := Node.FindNode( Name);198 if Assigned(NewNode) then 199 Result := StrToInt64( NewNode.TextContent);219 NewNode := Node.FindNode(DOMString(Name)); 220 if Assigned(NewNode) then 221 Result := StrToInt64(string(NewNode.TextContent)); 200 222 end; 201 223 … … 205 227 begin 206 228 Result := DefaultValue; 207 NewNode := Node.FindNode( Name);208 if Assigned(NewNode) then 209 Result := StrToBool( NewNode.TextContent);229 NewNode := Node.FindNode(DOMString(Name)); 230 if Assigned(NewNode) then 231 Result := StrToBool(string(NewNode.TextContent)); 210 232 end; 211 233 … … 215 237 begin 216 238 Result := DefaultValue; 217 NewNode := Node.FindNode( Name);218 if Assigned(NewNode) then 219 Result := NewNode.TextContent;239 NewNode := Node.FindNode(DOMString(Name)); 240 if Assigned(NewNode) then 241 Result := string(NewNode.TextContent); 220 242 end; 221 243 … … 226 248 begin 227 249 Result := DefaultValue; 228 NewNode := Node.FindNode( Name);229 if Assigned(NewNode) then 230 Result := XMLTimeToDateTime( NewNode.TextContent);250 NewNode := Node.FindNode(DOMString(Name)); 251 if Assigned(NewNode) then 252 Result := XMLTimeToDateTime(string(NewNode.TextContent)); 231 253 end; 232 254
Note:
See TracChangeset
for help on using the changeset viewer.