Changeset 21
- Timestamp:
- Apr 3, 2025, 10:49:00 PM (8 days ago)
- Location:
- trunk
- Files:
-
- 64 added
- 11 deleted
- 8 edited
- 1 copied
- 27 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Backends/Subversion/USubversion.pas
r18 r21 6 6 7 7 uses 8 Classes, SysUtils, UVCS, UBackend, XMLRead, DOM, UXMLUtils;8 Classes, SysUtils, UVCS, UBackend, XMLRead, DOM, XML; 9 9 10 10 type -
trunk/Forms/UFormBrowse.pas
r19 r21 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ExtCtrls, Menus, ActnList, UFindFile, UVCS, Contnrs, LazFileUtils;9 ExtCtrls, Menus, ActnList, FindFile, UVCS, Contnrs, LazFileUtils; 10 10 11 11 type -
trunk/Packages/Common/ApplicationInfo.pas
r20 r21 1 unit UApplicationInfo; 2 3 {$mode delphi} 1 unit ApplicationInfo; 4 2 5 3 interface 6 4 7 5 uses 8 SysUtils, Registry, Classes, Forms, URegistry;6 SysUtils, Classes, Forms, RegistryEx, Controls, Graphics, LCLType; 9 7 10 8 type … … 14 12 TApplicationInfo = class(TComponent) 15 13 private 14 FDescription: TTranslateString; 15 FIcon: TBitmap; 16 16 FIdentification: Byte; 17 17 FLicense: string; … … 32 32 public 33 33 constructor Create(AOwner: TComponent); override; 34 destructor Destroy; override; 34 35 property Version: string read GetVersion; 36 function GetRegistryContext: TRegistryContext; 35 37 published 36 38 property Identification: Byte read FIdentification write FIdentification; … … 45 47 property EmailContact: string read FEmailContact write FEmailContact; 46 48 property AppName: string read FAppName write FAppName; 49 property Description: TTranslateString read FDescription write FDescription; 47 50 property ReleaseDate: TDateTime read FReleaseDate write FReleaseDate; 48 51 property RegistryKey: string read FRegistryKey write FRegistryKey; 49 52 property RegistryRoot: TRegistryRoot read FRegistryRoot write FRegistryRoot; 50 53 property License: string read FLicense write FLicense; 54 property Icon: TBitmap read FIcon write FIcon; 51 55 end; 52 56 53 57 procedure Register; 54 58 59 55 60 implementation 56 61 57 62 procedure Register; 58 63 begin … … 71 76 constructor TApplicationInfo.Create(AOwner: TComponent); 72 77 begin 73 inherited Create(AOwner);78 inherited; 74 79 FVersionMajor := 1; 75 80 FIdentification := 1; … … 77 82 FRegistryKey := '\Software\' + FAppName; 78 83 FRegistryRoot := rrKeyCurrentUser; 84 FIcon := TBitmap.Create; 85 end; 86 87 destructor TApplicationInfo.Destroy; 88 begin 89 FreeAndNil(FIcon); 90 inherited; 91 end; 92 93 function TApplicationInfo.GetRegistryContext: TRegistryContext; 94 begin 95 Result := TRegistryContext.Create(RegistryRoot, RegistryKey); 79 96 end; 80 97 -
trunk/Packages/Common/Common.Delay.pas
r20 r21 1 unit UDelay; 2 3 {$mode delphi} 1 unit Common.Delay; 4 2 5 3 interface … … 73 71 74 72 end. 75 -
trunk/Packages/Common/Common.lpk
r19 r21 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <CONFIG> 3 <Package Version=" 4">3 <Package Version="5"> 4 4 <PathDelim Value="\"/> 5 5 <Name Value="Common"/> … … 11 11 <PathDelim Value="\"/> 12 12 <SearchPaths> 13 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 13 <OtherUnitFiles Value="Forms"/> 14 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 14 15 </SearchPaths> 16 <Parsing> 17 <SyntaxOptions> 18 <SyntaxMode Value="Delphi"/> 19 <CStyleOperator Value="False"/> 20 <AllowLabel Value="False"/> 21 <CPPInline Value="False"/> 22 </SyntaxOptions> 23 </Parsing> 24 <CodeGeneration> 25 <Optimizations> 26 <OptimizationLevel Value="0"/> 27 </Optimizations> 28 </CodeGeneration> 29 <Linking> 30 <Debugging> 31 <GenerateDebugInfo Value="False"/> 32 </Debugging> 33 </Linking> 34 <Other> 35 <CompilerMessages> 36 <IgnoredMessages idx6058="True" idx5071="True" idx5024="True" idx3124="True" idx3123="True"/> 37 </CompilerMessages> 38 </Other> 15 39 </CompilerOptions> 16 <Description Value="Various libraries"/> 17 <License Value="GNU/GPL"/> 18 <Version Minor="7"/> 19 <Files Count="20"> 40 <Description Value="Common package with various useful units. 41 42 Source: https://svn.zdechov.net/PascalClassLibrary/Common/"/> 43 <License Value="Copy left."/> 44 <Version Minor="12"/> 45 <Files Count="40"> 20 46 <Item1> 21 47 <Filename Value="StopWatch.pas"/> … … 23 49 </Item1> 24 50 <Item2> 25 <Filename Value=" UCommon.pas"/>26 <UnitName Value=" UCommon"/>51 <Filename Value="Common.pas"/> 52 <UnitName Value="Common"/> 27 53 </Item2> 28 54 <Item3> 29 <Filename Value=" UDebugLog.pas"/>30 <HasRegisterProc Value="True"/> 31 <UnitName Value=" UDebugLog"/>55 <Filename Value="DebugLog.pas"/> 56 <HasRegisterProc Value="True"/> 57 <UnitName Value="DebugLog"/> 32 58 </Item3> 33 59 <Item4> 34 <Filename Value=" UDelay.pas"/>35 <UnitName Value=" UDelay"/>60 <Filename Value="Common.Delay.pas"/> 61 <UnitName Value="Common.Delay"/> 36 62 </Item4> 37 63 <Item5> 38 <Filename Value="UPrefixMultiplier.pas"/> 39 <UnitName Value="UPrefixMultiplier"/> 64 <Filename Value="PrefixMultiplier.pas"/> 65 <HasRegisterProc Value="True"/> 66 <UnitName Value="PrefixMultiplier"/> 40 67 </Item5> 41 68 <Item6> 42 <Filename Value="U URI.pas"/>43 <UnitName Value="U URI"/>69 <Filename Value="URI.pas"/> 70 <UnitName Value="URI"/> 44 71 </Item6> 45 72 <Item7> 46 <Filename Value=" UThreading.pas"/>47 <UnitName Value=" UThreading"/>73 <Filename Value="Threading.pas"/> 74 <UnitName Value="Threading"/> 48 75 </Item7> 49 76 <Item8> 50 <Filename Value=" UMemory.pas"/>51 <UnitName Value=" UMemory"/>77 <Filename Value="Memory.pas"/> 78 <UnitName Value="Memory"/> 52 79 </Item8> 53 80 <Item9> 54 <Filename Value=" UResetableThread.pas"/>55 <UnitName Value=" UResetableThread"/>81 <Filename Value="ResetableThread.pas"/> 82 <UnitName Value="ResetableThread"/> 56 83 </Item9> 57 84 <Item10> 58 <Filename Value=" UPool.pas"/>59 <UnitName Value=" UPool"/>85 <Filename Value="Pool.pas"/> 86 <UnitName Value="Pool"/> 60 87 </Item10> 61 88 <Item11> 62 <Filename Value=" ULastOpenedList.pas"/>63 <HasRegisterProc Value="True"/> 64 <UnitName Value=" ULastOpenedList"/>89 <Filename Value="LastOpenedList.pas"/> 90 <HasRegisterProc Value="True"/> 91 <UnitName Value="LastOpenedList"/> 65 92 </Item11> 66 93 <Item12> 67 <Filename Value=" URegistry.pas"/>68 <UnitName Value=" URegistry"/>94 <Filename Value="RegistryEx.pas"/> 95 <UnitName Value="RegistryEx"/> 69 96 </Item12> 70 97 <Item13> 71 <Filename Value=" UJobProgressView.pas"/>72 <HasRegisterProc Value="True"/> 73 <UnitName Value=" UJobProgressView"/>98 <Filename Value="JobProgressView.pas"/> 99 <HasRegisterProc Value="True"/> 100 <UnitName Value="JobProgressView"/> 74 101 </Item13> 75 102 <Item14> 76 <Filename Value=" UXMLUtils.pas"/>77 <UnitName Value=" UXMLUtils"/>103 <Filename Value="XML.pas"/> 104 <UnitName Value="XML"/> 78 105 </Item14> 79 106 <Item15> 80 <Filename Value=" UApplicationInfo.pas"/>81 <HasRegisterProc Value="True"/> 82 <UnitName Value=" UApplicationInfo"/>107 <Filename Value="ApplicationInfo.pas"/> 108 <HasRegisterProc Value="True"/> 109 <UnitName Value="ApplicationInfo"/> 83 110 </Item15> 84 111 <Item16> 85 <Filename Value=" USyncCounter.pas"/>86 <UnitName Value=" USyncCounter"/>112 <Filename Value="SyncCounter.pas"/> 113 <UnitName Value="SyncCounter"/> 87 114 </Item16> 88 115 <Item17> 89 <Filename Value=" UListViewSort.pas"/>90 <HasRegisterProc Value="True"/> 91 <UnitName Value=" UListViewSort"/>116 <Filename Value="ListViewSort.pas"/> 117 <HasRegisterProc Value="True"/> 118 <UnitName Value="ListViewSort"/> 92 119 </Item17> 93 120 <Item18> 94 <Filename Value=" UPersistentForm.pas"/>95 <HasRegisterProc Value="True"/> 96 <UnitName Value=" UPersistentForm"/>121 <Filename Value="PersistentForm.pas"/> 122 <HasRegisterProc Value="True"/> 123 <UnitName Value="PersistentForm"/> 97 124 </Item18> 98 125 <Item19> 99 <Filename Value=" UFindFile.pas"/>100 <HasRegisterProc Value="True"/> 101 <UnitName Value=" UFindFile"/>126 <Filename Value="FindFile.pas"/> 127 <HasRegisterProc Value="True"/> 128 <UnitName Value="FindFile"/> 102 129 </Item19> 103 130 <Item20> 104 <Filename Value=" UScaleDPI.pas"/>105 <HasRegisterProc Value="True"/> 106 <UnitName Value=" UScaleDPI"/>131 <Filename Value="ScaleDPI.pas"/> 132 <HasRegisterProc Value="True"/> 133 <UnitName Value="ScaleDPI"/> 107 134 </Item20> 135 <Item21> 136 <Filename Value="Theme.pas"/> 137 <HasRegisterProc Value="True"/> 138 <UnitName Value="Theme"/> 139 </Item21> 140 <Item22> 141 <Filename Value="StringTable.pas"/> 142 <UnitName Value="StringTable"/> 143 </Item22> 144 <Item23> 145 <Filename Value="MetaCanvas.pas"/> 146 <UnitName Value="MetaCanvas"/> 147 </Item23> 148 <Item24> 149 <Filename Value="Geometric.pas"/> 150 <UnitName Value="Geometric"/> 151 </Item24> 152 <Item25> 153 <Filename Value="Translator.pas"/> 154 <HasRegisterProc Value="True"/> 155 <UnitName Value="Translator"/> 156 </Item25> 157 <Item26> 158 <Filename Value="Languages.pas"/> 159 <UnitName Value="Languages"/> 160 </Item26> 161 <Item27> 162 <Filename Value="PixelPointer.pas"/> 163 <UnitName Value="PixelPointer"/> 164 </Item27> 165 <Item28> 166 <Filename Value="DataFile.pas"/> 167 <UnitName Value="DataFile"/> 168 </Item28> 169 <Item29> 170 <Filename Value="TestCase.pas"/> 171 <UnitName Value="TestCase"/> 172 </Item29> 173 <Item30> 174 <Filename Value="Generics.pas"/> 175 <UnitName Value="Generics"/> 176 </Item30> 177 <Item31> 178 <Filename Value="CommonPackage.pas"/> 179 <Type Value="Main Unit"/> 180 <UnitName Value="CommonPackage"/> 181 </Item31> 182 <Item32> 183 <Filename Value="Table.pas"/> 184 <UnitName Value="Table"/> 185 </Item32> 186 <Item33> 187 <Filename Value="FormEx.pas"/> 188 <HasRegisterProc Value="True"/> 189 <UnitName Value="FormEx"/> 190 </Item33> 191 <Item34> 192 <Filename Value="Forms\FormTests.pas"/> 193 <UnitName Value="FormTests"/> 194 </Item34> 195 <Item35> 196 <Filename Value="Forms\FormTest.pas"/> 197 <UnitName Value="FormTest"/> 198 </Item35> 199 <Item36> 200 <Filename Value="Forms\FormAbout.pas"/> 201 <UnitName Value="FormAbout"/> 202 </Item36> 203 <Item37> 204 <Filename Value="Forms\FormKeyShortcuts.pas"/> 205 <UnitName Value="FormKeyShortcuts"/> 206 </Item37> 207 <Item38> 208 <Filename Value="ItemList.pas"/> 209 <UnitName Value="ItemList"/> 210 </Item38> 211 <Item39> 212 <Filename Value="Forms\FormItem.pas"/> 213 <UnitName Value="FormItem"/> 214 </Item39> 215 <Item40> 216 <Filename Value="Forms\FormList.pas"/> 217 <UnitName Value="FormList"/> 218 </Item40> 108 219 </Files> 220 <CompatibilityMode Value="True"/> 109 221 <i18n> 110 222 <EnableI18N Value="True"/> … … 112 224 <EnableI18NForLFM Value="True"/> 113 225 </i18n> 114 <RequiredPkgs Count=" 3">226 <RequiredPkgs Count="2"> 115 227 <Item1> 116 228 <PackageName Value="LCL"/> 117 229 </Item1> 118 230 <Item2> 119 <PackageName Value="TemplateGenerics"/>120 </Item2>121 <Item3>122 231 <PackageName Value="FCL"/> 123 232 <MinVersion Major="1" Valid="True"/> 124 </Item 3>233 </Item2> 125 234 </RequiredPkgs> 126 235 <UsageOptions> -
trunk/Packages/Common/Common.pas
r20 r21 1 unit UCommon; 2 3 {$mode delphi} 1 unit Common; 4 2 5 3 interface 6 4 7 5 uses 8 {$ ifdef Windows}Windows,{$endif}9 {$ ifdef Linux}baseunix,{$endif}10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 11 FileUtil ; //, ShFolder, ShellAPI;6 {$IFDEF WINDOWS}Windows,{$ENDIF} 7 {$IFDEF UNIX}baseunix,{$ENDIF} 8 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, Graphics, 9 FileUtil, Generics.Collections; //, ShFolder, ShellAPI; 12 10 13 11 type 14 12 TArrayOfByte = array of Byte; 15 TArrayOfString = array of string;16 13 TExceptionEvent = procedure(Sender: TObject; E: Exception) of object; 17 14 … … 28 25 unfDNSDomainName = 11); 29 26 27 TFilterMethod = function (FileName: string): Boolean of object; 28 TFileNameMethod = procedure (FileName: string) of object; 29 30 30 var 31 31 ExceptionHandler: TExceptionEvent; 32 32 DLLHandle1: HModule; 33 33 34 {$IFDEF Windows} 35 GetUserNameEx: procedure (NameFormat: DWORD; 36 lpNameBuffer: LPSTR; nSize: PULONG); stdcall; 37 {$ENDIF} 38 39 function IntToBin(Data: Int64; Count: Byte): string; 34 {$IFDEF WINDOWS} 35 GetUserNameEx: procedure (NameFormat: DWORD; 36 lpNameBuffer: LPSTR; nSize: PULONG); stdcall; 37 {$ENDIF} 38 39 const 40 clLightBlue = TColor($FF8080); 41 clLightGreen = TColor($80FF80); 42 clLightRed = TColor($8080FF); 43 44 function AddLeadingZeroes(const aNumber, Length : integer) : string; 40 45 function BinToInt(BinStr: string): Int64; 41 function TryHexToInt(Data: string; var Value: Integer): Boolean;42 function TryBinToInt(Data: string; var Value: Integer): Boolean;43 46 function BinToHexString(Source: AnsiString): string; 44 47 //function DelTree(DirName : string): Boolean; … … 46 49 function BCDToInt(Value: Byte): Byte; 47 50 function CompareByteArray(Data1, Data2: TArrayOfByte): Boolean; 51 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 52 function CombinePaths(Path1, Path2: string): string; 53 function ComputerName: string; 54 procedure DeleteFiles(APath, AFileSpec: string); 55 function EndsWith(Text, What: string): Boolean; 56 function Explode(Separator: Char; Data: string): TStringArray; 57 procedure ExecuteProgram(Executable: string; Parameters: array of string; 58 Environment: array of string; CurrentDirectory: string = ''); 59 procedure ExecuteProgramOutput(Executable: string; Parameters: array of string; 60 Environment: array of string; out Output, Error: string; 61 out ExitCode: Integer; CurrentDirectory: string = ''); 62 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); 63 procedure FreeThenNil(var Obj); 64 function GetDirCount(Dir: string): Integer; 48 65 function GetUserName: string; 49 function LoggedOnUserNameEx(Format: TUserNameFormat): string;50 function SplitString(var Text: string; Count: Word): string;51 66 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 52 67 function GetBit(Variable: QWord; Index: Byte): Boolean; 68 function GetStringPart(var Text: string; Separator: string): string; 69 function GetEnvironmentVariables: TStringArray; 70 function GenerateNewName(OldName: string): string; 71 function GetFileFilterItemExt(Filter: string; Index: Integer): string; 72 function IntToBin(Data: Int64; Count: Byte): string; 73 function Implode(Separator: string; List: TList<string>): string; overload; 74 function Implode(Separator: string; List: array of string): string; overload; 75 function Implode(Separator: string; List: TStringList; Around: string = ''): string; overload; 76 function LastPos(const SubStr: String; const S: String): Integer; 77 function LoadFileToStr(const FileName: TFileName): AnsiString; 78 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 79 function MergeArray(A, B: array of string): TStringArray; 80 function OccurenceOfChar(What: Char; Where: string): Integer; 81 procedure OpenWebPage(URL: string); 82 procedure OpenEmail(Email: string); 83 procedure OpenFileInShell(FileName: string); 84 function PosFromIndex(SubStr: string; Text: string; 85 StartIndex: Integer): Integer; 86 function PosFromIndexReverse(SubStr: string; Text: string; 87 StartIndex: Integer): Integer; 88 function RemoveQuotes(Text: string): string; 89 procedure SaveStringToFile(S, FileName: string); 53 90 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload; 54 91 procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload; 55 92 procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload; 56 93 procedure SetBit(var Variable: Word; Index: Byte; State: Boolean); overload; 57 function AddLeadingZeroes(const aNumber, Length : integer) : string; 58 function LastPos(const SubStr: String; const S: String): Integer; 59 function GenerateNewName(OldName: string): string; 60 function GetFileFilterItemExt(Filter: string; Index: Integer): string; 61 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); 62 procedure DeleteFiles(APath, AFileSpec: string); 63 procedure OpenWebPage(URL: string); 64 procedure OpenFileInShell(FileName: string); 65 procedure ExecuteProgram(CommandLine: string); 66 procedure FreeThenNil(var Obj); 67 function RemoveQuotes(Text: string): string; 68 function ComputerName: string; 69 function OccurenceOfChar(What: Char; Where: string): Integer; 70 function GetDirCount(Dir: string): Integer; 71 function MergeArray(A, B: array of string): TArrayOfString; 72 function LoadFileToStr(const FileName: TFileName): AnsiString; 94 procedure SearchFiles(AList: TStrings; Dir: string; 95 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 96 procedure SortStrings(Strings: TStrings); 97 function SplitString(var Text: string; Count: Word): string; 98 function StripTags(const S: string): string; 99 function StartsWith(Text, What: string): Boolean; 100 function TryHexToInt(Data: string; out Value: Integer): Boolean; 101 function TryBinToInt(Data: string; out Value: Integer): Boolean; 73 102 74 103 75 104 implementation 76 105 77 function BinToInt(BinStr : string) : Int64; 78 var 79 i : byte; 80 RetVar : Int64; 106 resourcestring 107 SExecutionError = 'Excution error: %s (exit code: %d)'; 108 109 function StartsWith(Text, What: string): Boolean; 110 begin 111 Result := Copy(Text, 1, Length(Text)) = What; 112 end; 113 114 function EndsWith(Text, What: string): Boolean; 115 begin 116 Result := Copy(Text, Length(Text) - Length(What) + 1, MaxInt) = What; 117 end; 118 119 function BinToInt(BinStr: string): Int64; 120 var 121 I: Byte; 122 RetVar: Int64; 81 123 begin 82 124 BinStr := UpperCase(BinStr); 83 if BinStr[length(BinStr)] = 'B' then Delete(BinStr, length(BinStr),1);125 if BinStr[length(BinStr)] = 'B' then Delete(BinStr, Length(BinStr), 1); 84 126 RetVar := 0; 85 for i := 1 to length(BinStr) do begin86 if not (BinStr[ i] in ['0','1']) then begin127 for I := 1 to Length(BinStr) do begin 128 if not (BinStr[I] in ['0','1']) then begin 87 129 RetVar := 0; 88 130 Break; 89 131 end; 90 RetVar := (RetVar shl 1) + ( byte(BinStr[i]) and 1);132 RetVar := (RetVar shl 1) + (Byte(BinStr[I]) and 1); 91 133 end; 92 134 … … 98 140 I: Integer; 99 141 begin 142 Result := ''; 100 143 for I := 1 to Length(Source) do begin 101 144 Result := Result + LowerCase(IntToHex(Ord(Source[I]), 2)); 102 145 end; 103 146 end; 104 105 147 106 148 procedure DeleteFiles(APath, AFileSpec: string); … … 112 154 Path := IncludeTrailingPathDelimiter(APath); 113 155 114 Find := FindFirst( UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec);156 Find := FindFirst(Path + AFileSpec, faAnyFile xor faDirectory, SearchRec); 115 157 while Find = 0 do begin 116 DeleteFile(Path + UTF8Encode(SearchRec.Name));158 DeleteFile(Path + SearchRec.Name); 117 159 118 160 Find := SysUtils.FindNext(SearchRec); … … 120 162 FindClose(SearchRec); 121 163 end; 122 123 164 124 165 function GetFileFilterItemExt(Filter: string; Index: Integer): string; … … 143 184 if FileExt <> '.*' then 144 185 FileDialog.FileName := ChangeFileExt(FileDialog.FileName, FileExt) 186 end; 187 188 function GetEnvironmentVariables: TStringArray; 189 var 190 I: Integer; 191 begin 192 Result := Default(TStringArray); 193 SetLength(Result, GetEnvironmentVariableCount); 194 for I := 0 to GetEnvironmentVariableCount - 1 do 195 Result[I] := GetEnvironmentString(I); 145 196 end; 146 197 … … 185 236 end;*) 186 237 238 function Implode(Separator: string; List: array of string): string; 239 var 240 I: Integer; 241 begin 242 Result := ''; 243 for I := 0 to Length(List) - 1 do begin 244 Result := Result + List[I]; 245 if I < Length(List) - 1 then Result := Result + Separator; 246 end; 247 end; 248 249 function Implode(Separator: string; List: TStringList; Around: string = ''): string; 250 var 251 I: Integer; 252 begin 253 Result := ''; 254 for I := 0 to List.Count - 1 do begin 255 Result := Result + Around + List[I] + Around; 256 if I < List.Count - 1 then Result := Result + Separator; 257 end; 258 end; 259 187 260 function LastPos(const SubStr: String; const S: String): Integer; 188 261 begin … … 230 303 end; 231 304 232 function TryHexToInt(Data: string; varValue: Integer): Boolean;305 function TryHexToInt(Data: string; out Value: Integer): Boolean; 233 306 var 234 307 I: Integer; … … 246 319 end; 247 320 248 function TryBinToInt(Data: string; varValue: Integer): Boolean;321 function TryBinToInt(Data: string; out Value: Integer): Boolean; 249 322 var 250 323 I: Integer; … … 274 347 end; 275 348 276 function Explode(Separator: char; Data: string): TArrayOfString; 277 begin 278 SetLength(Result, 0); 279 while Pos(Separator, Data) > 0 do begin 349 function Explode(Separator: Char; Data: string): TStringArray; 350 var 351 Index: Integer; 352 begin 353 Result := Default(TStringArray); 354 repeat 355 Index := Pos(Separator, Data); 356 if Index > 0 then begin 357 SetLength(Result, Length(Result) + 1); 358 Result[High(Result)] := Copy(Data, 1, Index - 1); 359 Delete(Data, 1, Index); 360 end else Break; 361 until False; 362 if Data <> '' then begin 280 363 SetLength(Result, Length(Result) + 1); 281 Result[High(Result)] := Copy(Data, 1, Pos(Separator, Data) - 1); 282 Delete(Data, 1, Pos(Separator, Data)); 283 end; 284 SetLength(Result, Length(Result) + 1); 285 Result[High(Result)] := Data; 286 end; 287 288 {$IFDEF Windows} 364 Result[High(Result)] := Data; 365 end; 366 end; 367 368 function Implode(Separator: string; List: TList<string>): string; 369 var 370 I: Integer; 371 begin 372 Result := ''; 373 for I := 0 to List.Count - 1 do begin 374 Result := Result + List[I]; 375 if I < List.Count - 1 then Result := Result + Separator; 376 end; 377 end; 378 379 {$IFDEF WINDOWS} 289 380 function GetUserName: string; 290 381 const … … 294 385 begin 295 386 L := MAX_USERNAME_LENGTH + 2; 387 Result := Default(string); 296 388 SetLength(Result, L); 297 389 if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin … … 307 399 end; 308 400 end; 309 {$ endif}401 {$ENDIF} 310 402 311 403 function ComputerName: string; 312 {$ ifdef mswindows}404 {$IFDEF WINDOWS} 313 405 const 314 406 INFO_BUFFER_SIZE = 32767; … … 325 417 end; 326 418 end; 327 {$ endif}328 {$ ifdef unix}419 {$ENDIF} 420 {$IFDEF UNIX} 329 421 var 330 422 Name: UtsName; 331 423 begin 424 Name := Default(UtsName); 332 425 fpuname(Name); 333 426 Result := Name.Nodename; 334 427 end; 335 {$ endif}336 337 {$ ifdef windows}428 {$ENDIF} 429 430 {$IFDEF WINDOWS} 338 431 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 339 432 const … … 413 506 procedure LoadLibraries; 414 507 begin 415 {$IFDEF W indows}508 {$IFDEF WINDOWS} 416 509 DLLHandle1 := LoadLibrary('secur32.dll'); 417 510 if DLLHandle1 <> 0 then … … 424 517 procedure FreeLibraries; 425 518 begin 426 {$IFDEF W indows}519 {$IFDEF WINDOWS} 427 520 if DLLHandle1 <> 0 then FreeLibrary(DLLHandle1); 428 521 {$ENDIF} 429 522 end; 430 523 431 procedure ExecuteProgram(CommandLine: string); 524 procedure ExecuteProgram(Executable: string; Parameters: array of string; 525 Environment: array of string; CurrentDirectory: string = ''); 432 526 var 433 527 Process: TProcess; 434 begin 528 I: Integer; 529 begin 530 Process := TProcess.Create(nil); 435 531 try 436 Process := TProcess.Create(nil); 437 Process.CommandLine := CommandLine; 532 Process.Executable := Executable; 533 for I := 0 to Length(Parameters) - 1 do 534 Process.Parameters.Add(Parameters[I]); 535 for I := 0 to Length(Environment) - 1 do 536 Process.Environment.Add(Environment[I]); 537 Process.CurrentDirectory := CurrentDirectory; 538 Process.ShowWindow := swoHIDE; 438 539 Process.Options := [poNoConsole]; 439 540 Process.Execute; … … 443 544 end; 444 545 546 procedure ExecuteProgramOutput(Executable: string; Parameters: array of string; 547 Environment: array of string; out Output, Error: string; out ExitCode: Integer; 548 CurrentDirectory: string); 549 var 550 Process: TProcess; 551 I: Integer; 552 ReadCount: Integer; 553 Buffer: string; 554 const 555 BufferSize = 1000; 556 begin 557 Process := TProcess.Create(nil); 558 try 559 Process.Executable := Executable; 560 for I := 0 to Length(Parameters) - 1 do 561 Process.Parameters.Add(Parameters[I]); 562 for I := 0 to Length(Environment) - 1 do 563 Process.Environment.Add(Environment[I]); 564 Process.CurrentDirectory := CurrentDirectory; 565 Process.ShowWindow := swoHIDE; 566 Process.Options := [poNoConsole, poUsePipes]; 567 Process.Execute; 568 569 Output := ''; 570 Error := ''; 571 Buffer := ''; 572 SetLength(Buffer, BufferSize); 573 while Process.Running do begin 574 if Process.Output.NumBytesAvailable > 0 then begin 575 ReadCount := Process.Output.Read(Buffer[1], Length(Buffer)); 576 Output := Output + Copy(Buffer, 1, ReadCount); 577 end; 578 579 if Process.Stderr.NumBytesAvailable > 0 then begin 580 ReadCount := Process.Stderr.Read(Buffer[1], Length(Buffer)); 581 Error := Error + Copy(Buffer, 1, ReadCount) 582 end; 583 584 Sleep(10); 585 end; 586 587 if Process.Output.NumBytesAvailable > 0 then begin 588 ReadCount := Process.Output.Read(Buffer[1], Length(Buffer)); 589 Output := Output + Copy(Buffer, 1, ReadCount); 590 end; 591 592 if Process.Stderr.NumBytesAvailable > 0 then begin 593 ReadCount := Process.Stderr.Read(Buffer[1], Length(Buffer)); 594 Error := Error + Copy(Buffer, 1, ReadCount); 595 end; 596 597 ExitCode := Process.ExitCode; 598 599 if (ExitCode <> 0) or (Error <> '') then 600 raise Exception.Create(Format(SExecutionError, [Output + Error, ExitCode])); 601 finally 602 Process.Free; 603 end; 604 end; 605 445 606 procedure FreeThenNil(var Obj); 446 607 begin … … 454 615 end; 455 616 617 procedure OpenEmail(Email: string); 618 begin 619 OpenURL('mailto:' + Email); 620 end; 621 456 622 procedure OpenFileInShell(FileName: string); 457 623 begin 458 ExecuteProgram('cmd.exe /c start "' + FileName + '"');624 ExecuteProgram('cmd.exe', ['/c', 'start', FileName], []); 459 625 end; 460 626 … … 482 648 end; 483 649 484 function MergeArray(A, B: array of string): TArrayOfString; 485 var 486 I: Integer; 487 begin 650 function MergeArray(A, B: array of string): TStringArray; 651 var 652 I: Integer; 653 begin 654 Result := Default(TStringArray); 488 655 SetLength(Result, Length(A) + Length(B)); 489 656 for I := 0 to Length(A) - 1 do … … 511 678 end; 512 679 680 function DefaultSearchFilter(const FileName: string): Boolean; 681 begin 682 Result := True; 683 end; 684 685 procedure SaveStringToFile(S, FileName: string); 686 var 687 F: TextFile; 688 begin 689 AssignFile(F, FileName); 690 try 691 ReWrite(F); 692 Write(F, S); 693 finally 694 CloseFile(F); 695 end; 696 end; 697 698 procedure SearchFiles(AList: TStrings; Dir: string; 699 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 700 var 701 SR: TSearchRec; 702 begin 703 Dir := IncludeTrailingPathDelimiter(Dir); 704 if FindFirst(Dir + '*', faAnyFile, SR) = 0 then 705 try 706 repeat 707 if (SR.Name = '.') or (SR.Name = '..') or (Assigned(FilterMethod) and (not FilterMethod(SR.Name) or 708 not FilterMethod(Copy(Dir, 3, Length(Dir)) + SR.Name))) then Continue; 709 if Assigned(FileNameMethod) then 710 FileNameMethod(Dir + SR.Name); 711 AList.Add(Dir + SR.Name); 712 if (SR.Attr and faDirectory) <> 0 then 713 SearchFiles(AList, Dir + SR.Name, FilterMethod); 714 until FindNext(SR) <> 0; 715 finally 716 FindClose(SR); 717 end; 718 end; 719 720 function GetStringPart(var Text: string; Separator: string): string; 721 var 722 P: Integer; 723 begin 724 P := Pos(Separator, Text); 725 if P > 0 then begin 726 Result := Copy(Text, 1, P - 1); 727 Delete(Text, 1, P - 1 + Length(Separator)); 728 end else begin 729 Result := Text; 730 Text := ''; 731 end; 732 Result := Trim(Result); 733 Text := Trim(Text); 734 end; 735 736 function StripTags(const S: string): string; 737 var 738 Len: Integer; 739 740 function ReadUntil(const ReadFrom: Integer; const C: Char): Integer; 741 var 742 J: Integer; 743 begin 744 for J := ReadFrom to Len do 745 if (S[j] = C) then 746 begin 747 Result := J; 748 Exit; 749 end; 750 Result := Len + 1; 751 end; 752 753 var 754 I, APos: Integer; 755 begin 756 Len := Length(S); 757 I := 0; 758 Result := ''; 759 while (I <= Len) do begin 760 Inc(I); 761 APos := ReadUntil(I, '<'); 762 Result := Result + Copy(S, I, APos - i); 763 I := ReadUntil(APos + 1, '>'); 764 end; 765 end; 766 767 function PosFromIndex(SubStr: string; Text: string; 768 StartIndex: Integer): Integer; 769 var 770 I, MaxLen: SizeInt; 771 Ptr: PAnsiChar; 772 begin 773 Result := 0; 774 if (StartIndex < 1) or (StartIndex > Length(Text) - Length(SubStr)) then Exit; 775 if Length(SubStr) > 0 then begin 776 MaxLen := Length(Text) - Length(SubStr) + 1; 777 I := StartIndex; 778 Ptr := @Text[StartIndex]; 779 while (I <= MaxLen) do begin 780 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 781 Result := I; 782 Exit; 783 end; 784 Inc(I); 785 Inc(Ptr); 786 end; 787 end; 788 end; 789 790 function PosFromIndexReverse(SubStr: string; Text: string; 791 StartIndex: Integer): Integer; 792 var 793 I: SizeInt; 794 Ptr: PAnsiChar; 795 begin 796 Result := 0; 797 if (StartIndex < 1) or (StartIndex > Length(Text)) then Exit; 798 if Length(SubStr) > 0 then begin 799 I := StartIndex; 800 Ptr := @Text[StartIndex]; 801 while (I > 0) do begin 802 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 803 Result := I; 804 Exit; 805 end; 806 Dec(I); 807 Dec(Ptr); 808 end; 809 end; 810 end; 811 812 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 813 var 814 I: Integer; 815 begin 816 SetLength(Dest, Length(Source)); 817 for I := 0 to Length(Dest) - 1 do 818 Dest[I] := Source[I]; 819 end; 820 821 function CombinePaths(Path1, Path2: string): string; 822 begin 823 Result := Path1; 824 if Result <> '' then Result := Result + DirectorySeparator + Path2 825 else Result := Path2; 826 end; 827 828 procedure SortStrings(Strings: TStrings); 829 var 830 Tmp: TStringList; 831 begin 832 Strings.BeginUpdate; 833 try 834 if Strings is TStringList then begin 835 TStringList(Strings).Sort; 836 end else begin 837 Tmp := TStringList.Create; 838 try 839 Tmp.Assign(Strings); 840 Tmp.Sort; 841 Strings.Assign(Tmp); 842 finally 843 Tmp.Free; 844 end; 845 end; 846 finally 847 Strings.EndUpdate; 848 end; 849 end; 513 850 514 851 -
trunk/Packages/Common/CommonPackage.pas
r20 r21 3 3 } 4 4 5 unit Common ;5 unit CommonPackage; 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, LazarusPackageIntf; 11 StopWatch, Common, DebugLog, Common.Delay, PrefixMultiplier, URI, Threading, 12 Memory, ResetableThread, Pool, LastOpenedList, RegistryEx, JobProgressView, 13 XML, ApplicationInfo, SyncCounter, ListViewSort, PersistentForm, FindFile, 14 ScaleDPI, Theme, StringTable, MetaCanvas, Geometric, Translator, Languages, 15 PixelPointer, DataFile, TestCase, Generics, Table, FormEx, FormTests, 16 FormTest, FormAbout, FormKeyShortcuts, ItemList, FormItem, FormList, 17 LazarusPackageIntf; 14 18 15 19 implementation … … 17 21 procedure Register; 18 22 begin 19 RegisterUnit('UDebugLog', @UDebugLog.Register); 20 RegisterUnit('ULastOpenedList', @ULastOpenedList.Register); 21 RegisterUnit('UJobProgressView', @UJobProgressView.Register); 22 RegisterUnit('UApplicationInfo', @UApplicationInfo.Register); 23 RegisterUnit('UListViewSort', @UListViewSort.Register); 24 RegisterUnit('UPersistentForm', @UPersistentForm.Register); 25 RegisterUnit('UFindFile', @UFindFile.Register); 26 RegisterUnit('UScaleDPI', @UScaleDPI.Register); 23 RegisterUnit('DebugLog', @DebugLog.Register); 24 RegisterUnit('PrefixMultiplier', @PrefixMultiplier.Register); 25 RegisterUnit('LastOpenedList', @LastOpenedList.Register); 26 RegisterUnit('JobProgressView', @JobProgressView.Register); 27 RegisterUnit('ApplicationInfo', @ApplicationInfo.Register); 28 RegisterUnit('ListViewSort', @ListViewSort.Register); 29 RegisterUnit('PersistentForm', @PersistentForm.Register); 30 RegisterUnit('FindFile', @FindFile.Register); 31 RegisterUnit('ScaleDPI', @ScaleDPI.Register); 32 RegisterUnit('Theme', @Theme.Register); 33 RegisterUnit('Translator', @Translator.Register); 34 RegisterUnit('FormEx', @FormEx.Register); 27 35 end; 28 36 -
trunk/Packages/Common/DebugLog.pas
r20 r21 1 unit UDebugLog; 2 3 {$mode delphi} 1 unit DebugLog; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, FileUtil, SpecializedList, SyncObjs;6 Classes, SysUtils, FileUtil, Generics.Collections, SyncObjs; 9 7 10 8 type … … 15 13 Group: string; 16 14 Text: string; 15 end; 16 17 TDebugLogItems = class(TObjectList<TDebugLogItem>) 17 18 end; 18 19 … … 29 30 procedure SetMaxCount(const AValue: Integer); 30 31 public 31 Items: T ListObject;32 Items: TDebugLogItems; 32 33 Lock: TCriticalSection; 33 34 procedure Add(Text: string; Group: string = ''); … … 44 45 45 46 procedure Register; 47 46 48 47 49 implementation … … 104 106 if ExtractFileDir(FileName) <> '' then 105 107 ForceDirectories(ExtractFileDir(FileName)); 106 if FileExists(FileName) then LogFile := TFileStream.Create( UTF8Decode(FileName), fmOpenWrite)107 else LogFile := TFileStream.Create( UTF8Decode(FileName), fmCreate);108 if FileExists(FileName) then LogFile := TFileStream.Create(FileName, fmOpenWrite) 109 else LogFile := TFileStream.Create(FileName, fmCreate); 108 110 LogFile.Seek(0, soFromEnd); 109 111 Text := FormatDateTime('hh:nn:ss.zzz', Now) + ': ' + Text + LineEnding; … … 117 119 begin 118 120 inherited; 119 Items := T ListObject.Create;121 Items := TDebugLogItems.Create; 120 122 Lock := TCriticalSection.Create; 121 123 MaxCount := 100; … … 126 128 destructor TDebugLog.Destroy; 127 129 begin 128 Items.Free;129 Lock.Free;130 FreeAndNil(Items); 131 FreeAndNil(Lock); 130 132 inherited; 131 133 end; 132 134 133 135 end. 134 -
trunk/Packages/Common/FindFile.pas
r20 r21 19 19 } 20 20 21 unit UFindFile;21 unit FindFile; 22 22 23 23 interface 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 … … 35 35 private 36 36 s : TStringList; 37 38 37 fSubFolder : boolean; 39 38 fAttr: TFileAttrib; 40 39 fPath : string; 41 40 fFileMask : string; 42 43 41 procedure SetPath(Value: string); 44 42 procedure FileSearch(const inPath : string); … … 46 44 constructor Create(AOwner: TComponent); override; 47 45 destructor Destroy; override; 48 49 46 function SearchForFiles: TStringList; 50 47 published … … 59 56 FilterAll = '*.*'; 60 57 {$ENDIF} 61 {$IFDEF LINUX}58 {$IFDEF UNIX} 62 59 FilterAll = '*'; 63 60 {$ENDIF} 64 61 65 62 procedure Register; 63 66 64 67 65 implementation … … 77 75 constructor TFindFile.Create(AOwner: TComponent); 78 76 begin 79 inherited Create(AOwner);77 inherited; 80 78 Path := IncludeTrailingBackslash(UTF8Encode(GetCurrentDir)); 81 79 FileMask := FilterAll; … … 87 85 begin 88 86 s.Free; 89 inherited Destroy;87 inherited; 90 88 end; 91 89 … … 117 115 Attr := 0; 118 116 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;117 if ffaHidden in FileAttr then Attr := Attr + 2; //faHidden; use constant to avoid platform warning 118 if ffaSysFile in FileAttr then Attr := Attr + 4; //faSysFile; use constant to avoid platform warning 119 // Deprecated: if ffaVolumeID in FileAttr then Attr := Attr + faVolumeID; 122 120 if ffaDirectory in FileAttr then Attr := Attr + faDirectory; 123 121 if ffaArchive in FileAttr then Attr := Attr + faArchive; 124 122 if ffaAnyFile in FileAttr then Attr := Attr + faAnyFile; 125 123 126 if SysUtils.FindFirst( UTF8Decode(inPath + FileMask), Attr, Rec) = 0 then124 if SysUtils.FindFirst(inPath + FileMask, Attr, Rec) = 0 then 127 125 try 128 126 repeat 129 s.Add(inPath + UTF8Encode(Rec.Name));127 s.Add(inPath + Rec.Name); 130 128 until SysUtils.FindNext(Rec) <> 0; 131 129 finally … … 135 133 If not InSubFolders then Exit; 136 134 137 if SysUtils.FindFirst( UTF8Decode(inPath + FilterAll), faDirectory, Rec) = 0 then135 if SysUtils.FindFirst(inPath + FilterAll, faDirectory, Rec) = 0 then 138 136 try 139 137 repeat 140 138 if ((Rec.Attr and faDirectory) > 0) and (Rec.Name <> '.') 141 139 and (Rec.Name <> '..') then 142 FileSearch(IncludeTrailingBackslash(inPath + UTF8Encode(Rec.Name)));140 FileSearch(IncludeTrailingBackslash(inPath + Rec.Name)); 143 141 until SysUtils.FindNext(Rec) <> 0; 144 142 finally 145 143 SysUtils.FindClose(Rec); 146 144 end; 147 end; 145 end; 148 146 149 147 end. 150 -
trunk/Packages/Common/JobProgressView.lfm
r20 r21 1 1 object FormJobProgressView: TFormJobProgressView 2 2 Left = 467 3 Height = 2463 Height = 414 4 4 Top = 252 5 Width = 3285 Width = 647 6 6 BorderIcons = [biSystemMenu] 7 ClientHeight = 246 8 ClientWidth = 328 9 Font.Height = -11 10 Font.Name = 'MS Sans Serif' 7 ClientHeight = 414 8 ClientWidth = 647 9 DesignTimePPI = 144 11 10 OnClose = FormClose 12 11 OnCloseQuery = FormCloseQuery 13 12 OnCreate = FormCreate 14 OnDestroy = FormDestroy 13 OnHide = FormHide 14 OnShow = FormShow 15 15 Position = poScreenCenter 16 LCLVersion = ' 1.6.0.4'16 LCLVersion = '2.2.0.4' 17 17 object PanelOperationsTitle: TPanel 18 18 Left = 0 19 Height = 2419 Height = 38 20 20 Top = 0 21 Width = 32821 Width = 647 22 22 Align = alTop 23 23 BevelOuter = bvNone 24 ClientHeight = 2425 ClientWidth = 32824 ClientHeight = 38 25 ClientWidth = 647 26 26 FullRepaint = False 27 27 TabOrder = 0 28 28 object LabelOperation: TLabel 29 Left = 830 Height = 1331 Top = 832 Width = 6629 Left = 10 30 Height = 26 31 Top = 10 32 Width = 99 33 33 Caption = 'Operations:' 34 Font.Height = -1135 Font.Name = 'MS Sans Serif'36 Font.Style = [fsBold]37 ParentColor = False38 34 ParentFont = False 39 35 end … … 41 37 object PanelLog: TPanel 42 38 Left = 0 43 Height = 1 2244 Top = 12445 Width = 32839 Height = 161 40 Top = 253 41 Width = 647 46 42 Align = alClient 47 43 BevelOuter = bvSpace 48 ClientHeight = 1 2249 ClientWidth = 32844 ClientHeight = 161 45 ClientWidth = 647 50 46 TabOrder = 1 51 47 object MemoLog: TMemo 52 Left = 853 Height = 1 0654 Top = 855 Width = 31248 Left = 10 49 Height = 141 50 Top = 10 51 Width = 627 56 52 Anchors = [akTop, akLeft, akRight, akBottom] 57 53 ReadOnly = True … … 62 58 object PanelProgress: TPanel 63 59 Left = 0 64 Height = 3865 Top = 5066 Width = 32860 Height = 65 61 Top = 126 62 Width = 647 67 63 Align = alTop 68 64 BevelOuter = bvNone 69 ClientHeight = 3870 ClientWidth = 32865 ClientHeight = 65 66 ClientWidth = 647 71 67 TabOrder = 2 72 68 object ProgressBarPart: TProgressBar 73 Left = 874 Height = 1775 Top = 1676 Width = 31269 Left = 12 70 Height = 29 71 Top = 29 72 Width = 628 77 73 Anchors = [akTop, akLeft, akRight] 78 74 TabOrder = 0 79 75 end 80 76 object LabelEstimatedTimePart: TLabel 81 Left = 882 Height = 1377 Left = 10 78 Height = 26 83 79 Top = -2 84 Width = 7180 Width = 132 85 81 Caption = 'Estimated time:' 86 ParentColor = False87 82 end 88 83 end 89 84 object PanelOperations: TPanel 90 85 Left = 0 91 Height = 2692 Top = 2493 Width = 32886 Height = 50 87 Top = 76 88 Width = 647 94 89 Align = alTop 95 90 BevelOuter = bvNone 96 ClientHeight = 2697 ClientWidth = 32891 ClientHeight = 50 92 ClientWidth = 647 98 93 FullRepaint = False 99 94 TabOrder = 3 100 95 object ListViewJobs: TListView 101 Left = 8102 Height = 16103 Top = 5104 Width = 31296 Left = 10 97 Height = 38 98 Top = 6 99 Width = 627 105 100 Anchors = [akTop, akLeft, akRight, akBottom] 106 101 AutoWidthLastColumn = True … … 109 104 Columns = < 110 105 item 111 Width = 312106 Width = 614 112 107 end> 113 108 OwnerData = True … … 122 117 object PanelProgressTotal: TPanel 123 118 Left = 0 124 Height = 36125 Top = 88126 Width = 328119 Height = 62 120 Top = 191 121 Width = 647 127 122 Align = alTop 128 123 BevelOuter = bvNone 129 ClientHeight = 36130 ClientWidth = 328124 ClientHeight = 62 125 ClientWidth = 647 131 126 TabOrder = 4 132 127 object LabelEstimatedTimeTotal: TLabel 133 Left = 8134 Height = 13128 Left = 10 129 Height = 26 135 130 Top = 0 136 Width = 97131 Width = 178 137 132 Caption = 'Total estimated time:' 138 ParentColor = False139 133 end 140 134 object ProgressBarTotal: TProgressBar 141 Left = 8142 Height = 16143 Top = 16144 Width = 312135 Left = 10 136 Height = 29 137 Top = 29 138 Width = 627 145 139 Anchors = [akTop, akLeft, akRight] 146 140 TabOrder = 0 147 141 end 148 142 end 143 object PanelText: TPanel 144 Left = 0 145 Height = 38 146 Top = 38 147 Width = 647 148 Align = alTop 149 BevelOuter = bvNone 150 ClientHeight = 38 151 ClientWidth = 647 152 TabOrder = 5 153 object LabelText: TLabel 154 Left = 10 155 Height = 29 156 Top = 10 157 Width = 630 158 Anchors = [akTop, akLeft, akRight] 159 AutoSize = False 160 end 161 end 149 162 object ImageList1: TImageList 150 BkColor = clForeground 151 left = 200 152 top = 8 163 Left = 240 164 Top = 10 153 165 Bitmap = { 154 4C69020000001000000010000000FF00FF00FF00FF00FF00FF00FF00FF00FF00 155 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 156 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 157 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 158 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 159 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 160 FF00000000FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 161 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000 162 00FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 163 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF0000 164 00FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 165 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF0000 166 00FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 167 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF0000 168 00FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FFFF00FF00FF00 169 FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF000000FFFF00 170 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FFFF00 171 FF00FF00FF00FF00FF00000000FF000000FF000000FF000000FFFF00FF00FF00 172 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF0000 173 00FFFF00FF00000000FF000000FF000000FF000000FFFF00FF00FF00FF00FF00 174 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF0000 175 00FF000000FF000000FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00 176 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF0000 177 00FF000000FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00 178 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF000000 179 00FF000000FF000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 180 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 181 FF00000000FFFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 182 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 183 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 184 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 185 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 186 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 187 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 188 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 189 FF00FF00FF00FF00FF00FF00FF00000000FFFF00FF00FF00FF00FF00FF00FF00 190 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 191 FF00FF00FF00FF00FF00FF00FF00000000FF000000FFFF00FF00FF00FF00FF00 192 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 193 FF00FF00FF00FF00FF00FF00FF00000000FF000084FF000000FFFF00FF00FF00 194 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF0000 195 00FF000000FF000000FF000000FF000000FF0000FFFF000084FF000000FFFF00 196 FF00FF00FF00FF00FF00FF00FF00FF00FF00000000FF0000FFFF0000FFFF0000 197 FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF000084FF0000 198 00FFFF00FF00FF00FF00FF00FF00FF00FF00000000FF0000FFFF0000FFFF0000 199 FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 200 84FF000000FFFF00FF00FF00FF00FF00FF00000000FF0000FFFF0000FFFF0000 201 FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 202 FFFF000084FF000000FFFF00FF00FF00FF00000000FF0000FFFF0000FFFF0000 203 FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000 204 84FF000000FFFF00FF00FF00FF00FF00FF00000000FF0000FFFF0000FFFF0000 205 FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF000084FF0000 206 00FFFF00FF00FF00FF00FF00FF00FF00FF00000000FF000000FF000000FF0000 207 00FF000000FF000000FF000000FF000000FF0000FFFF000084FF000000FFFF00 208 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 209 FF00FF00FF00FF00FF00FF00FF00000000FF000084FF000000FFFF00FF00FF00 210 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 211 FF00FF00FF00FF00FF00FF00FF00000000FF000000FFFF00FF00FF00FF00FF00 212 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 213 FF00FF00FF00FF00FF00FF00FF00000000FFFF00FF00FF00FF00FF00FF00FF00 214 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 215 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 216 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 217 FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00 218 FF00FF00FF00FF00FF00FF00FF00 166 4C7A0200000010000000100000006A0000000000000078DAE593490E00100C45 167 7B78F72E5684A63A1142C382BE4F0708F89C955117F4B016BE67B5FC6E96DB97 168 B0D4B9F4CD949F36DED1DF922B0F1BD11FAB5AFC68DE5C44D40220A9FA779EC8 169 6A349FD5A435E43CADA1E3678D73F773F1DBF3EFADFFEEFEBBF97F6696BE9D36 219 170 } 220 171 end … … 223 174 Interval = 100 224 175 OnTimer = TimerUpdateTimer 225 left = 264226 top = 8176 Left = 384 177 Top = 10 227 178 end 228 179 end -
trunk/Packages/Common/JobProgressView.pas
r20 r21 1 unit UJobProgressView; 2 3 {$MODE Delphi} 1 unit JobProgressView; 4 2 5 3 interface … … 7 5 uses 8 6 SysUtils, Variants, Classes, Graphics, Controls, Forms, Syncobjs, 9 Dialogs, ComCtrls, StdCtrls, ExtCtrls, Contnrs, UThreading,7 Dialogs, ComCtrls, StdCtrls, ExtCtrls, Generics.Collections, Threading, Math, 10 8 DateUtils; 11 9 … … 13 11 EstimatedTimeShowTreshold = 4; 14 12 EstimatedTimeShowTresholdTotal = 1; 15 MemoLogHeight = 200;16 13 UpdateInterval = 100; // ms 17 14 … … 24 21 FLock: TCriticalSection; 25 22 FOnChange: TNotifyEvent; 23 FText: string; 26 24 FValue: Integer; 27 25 FMax: Integer; 28 26 procedure SetMax(const AValue: Integer); 27 procedure SetText(AValue: string); 29 28 procedure SetValue(const AValue: Integer); 30 29 public … … 35 34 property Value: Integer read FValue write SetValue; 36 35 property Max: Integer read FMax write SetMax; 36 property Text: string read FText write SetText; 37 37 property OnChange: TNotifyEvent read FOnChange write FOnChange; 38 38 end; … … 69 69 end; 70 70 71 TJobs = class(TObjectList<TJob>) 72 end; 73 71 74 TJobThread = class(TListedThread) 72 75 procedure Execute; override; … … 80 83 TFormJobProgressView = class(TForm) 81 84 ImageList1: TImageList; 85 LabelText: TLabel; 82 86 Label2: TLabel; 83 87 LabelOperation: TLabel; … … 86 90 ListViewJobs: TListView; 87 91 MemoLog: TMemo; 92 PanelText: TPanel; 88 93 PanelProgressTotal: TPanel; 89 94 PanelOperationsTitle: TPanel; … … 94 99 ProgressBarTotal: TProgressBar; 95 100 TimerUpdate: TTimer; 101 procedure FormHide(Sender: TObject); 102 procedure FormShow(Sender: TObject); 103 procedure ReloadJobList; 96 104 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 97 procedure FormDestroy(Sender: TObject);98 105 procedure ListViewJobsData(Sender: TObject; Item: TListItem); 99 106 procedure TimerUpdateTimer(Sender: TObject); 100 107 procedure FormCreate(Sender: TObject); 101 108 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 109 procedure UpdateHeight; 102 110 public 103 111 JobProgressView: TJobProgressView; … … 118 126 TotalStartTime: TDateTime; 119 127 Log: TStringList; 128 FForm: TFormJobProgressView; 120 129 procedure SetTerminate(const AValue: Boolean); 121 130 procedure UpdateProgress; 122 procedure ReloadJobList;123 procedure StartJobs;124 procedure UpdateHeight;125 131 procedure JobProgressChange(Sender: TObject); 126 132 public 127 Form: TFormJobProgressView; 128 Jobs: TObjectList; // TListObject<TJob> 133 Jobs: TJobs; 129 134 CurrentJob: TJob; 130 135 CurrentJobIndex: Integer; … … 132 137 destructor Destroy; override; 133 138 procedure Clear; 134 procedureAddJob(Title: string; Method: TJobProgressViewMethod;135 NoThreaded: Boolean = False; WaitFor: Boolean = False) ;136 procedure Start (AAutoClose: Boolean = True);139 function AddJob(Title: string; Method: TJobProgressViewMethod; 140 NoThreaded: Boolean = False; WaitFor: Boolean = False): TJob; 141 procedure Start; 137 142 procedure Stop; 138 143 procedure TermSleep(Delay: Integer); 144 property Form: TFormJobProgressView read FForm; 139 145 property Terminate: Boolean read FTerminate write SetTerminate; 140 146 published … … 148 154 end; 149 155 150 //var151 // FormJobProgressView: TFormJobProgressView;152 153 156 procedure Register; 154 157 155 158 resourcestring 156 159 SExecuted = 'Executed'; 160 157 161 158 162 implementation … … 166 170 STotalEstimatedTime = 'Total estimated time: %s'; 167 171 SFinished = 'Finished'; 168 SOperations = 'Operations';169 172 170 173 procedure Register; … … 173 176 end; 174 177 178 { TJobThread } 179 175 180 procedure TJobThread.Execute; 176 181 begin 177 182 try 178 183 try 179 //raise Exception.Create('Exception in job');180 184 ProgressView.CurrentJob.Method(Job); 181 185 except … … 190 194 end; 191 195 192 procedure TJobProgressView.AddJob(Title: string; Method: TJobProgressViewMethod; 193 NoThreaded: Boolean = False; WaitFor: Boolean = False); 196 { TFormJobProgressView } 197 198 procedure TFormJobProgressView.UpdateHeight; 194 199 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); 200 H: Integer; 201 PanelOperationsVisible: Boolean; 202 PanelOperationsHeight: Integer; 203 PanelProgressVisible: Boolean; 204 PanelProgressTotalVisible: Boolean; 205 PanelLogVisible: Boolean; 206 MemoLogHeight: Integer = 200; 207 I: Integer; 208 ItemRect: TRect; 209 MaxH: Integer; 210 begin 211 H := PanelOperationsTitle.Height; 212 PanelOperationsVisible := JobProgressView.Jobs.Count > 0; 213 if PanelOperationsVisible <> PanelOperations.Visible then 214 PanelOperations.Visible := PanelOperationsVisible; 215 if ListViewJobs.Items.Count > 0 then begin 216 Maxh := 0; 217 for I := 0 to ListViewJobs.Items.Count - 1 do 218 begin 219 ItemRect := ListViewJobs.Items[i].DisplayRect(drBounds); 220 Maxh := Max(Maxh, ItemRect.Top + (ItemRect.Bottom - ItemRect.Top)); 221 end; 222 PanelOperationsHeight := Scale96ToScreen(12) + Maxh; 223 end else PanelOperationsHeight := Scale96ToScreen(8); 224 if PanelOperationsHeight <> PanelOperations.Height then 225 PanelOperations.Height := PanelOperationsHeight; 226 if PanelOperationsVisible then 227 H := H + PanelOperations.Height; 228 229 PanelProgressVisible := (JobProgressView.Jobs.Count > 0) and not JobProgressView.Finished; 230 if PanelProgressVisible <> PanelProgress.Visible then 231 PanelProgress.Visible := PanelProgressVisible; 232 if PanelProgressVisible then 233 H := H + PanelProgress.Height; 234 PanelProgressTotalVisible := (JobProgressView.Jobs.Count > 1) and not JobProgressView.Finished; 235 if PanelProgressTotalVisible <> PanelProgressTotal.Visible then 236 PanelProgressTotal.Visible := PanelProgressTotalVisible; 237 if PanelProgressTotalVisible then 238 H := H + PanelProgressTotal.Height; 239 Constraints.MinHeight := H; 240 PanelLogVisible := MemoLog.Lines.Count > 0; 241 if PanelLogVisible <> PanelLog.Visible then 242 PanelLog.Visible := PanelLogVisible; 243 if PanelLogVisible then 244 H := H + Scale96ToScreen(MemoLogHeight); 245 if PanelText.Visible then 246 H := H + PanelText.Height; 247 if Height <> H then begin 248 Height := H; 249 Top := (Screen.Height - H) div 2; 250 end; 251 end; 252 253 procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject); 254 var 255 ProgressBarPartVisible: Boolean; 256 ProgressBarTotalVisible: Boolean; 257 begin 258 JobProgressView.UpdateProgress; 259 if Visible and (not ProgressBarPart.Visible) and 260 Assigned(JobProgressView.CurrentJob) and 261 (JobProgressView.CurrentJob.Progress.Value > 0) then begin 262 ProgressBarPartVisible := True; 263 if ProgressBarPartVisible <> ProgressBarPart.Visible then 264 ProgressBarPart.Visible := ProgressBarPartVisible; 265 ProgressBarTotalVisible := True; 266 if ProgressBarTotalVisible <> ProgressBarTotal.Visible then 267 ProgressBarTotal.Visible := ProgressBarTotalVisible; 268 end; 269 if not Visible then begin 270 TimerUpdate.Interval := UpdateInterval; 271 if not JobProgressView.OwnerDraw then Show; 272 end; 273 if Assigned(JobProgressView.CurrentJob) then begin 274 LabelText.Caption := JobProgressView.CurrentJob.Progress.Text; 275 if LabelText.Caption <> '' then begin 276 PanelText.Visible := True; 277 UpdateHeight; 278 end; 279 end; 280 end; 281 282 procedure TFormJobProgressView.ListViewJobsData(Sender: TObject; Item: TListItem); 283 begin 284 if (Item.Index >= 0) and (Item.Index < JobProgressView.Jobs.Count) then 285 with JobProgressView.Jobs[Item.Index] do begin 286 Item.Caption := Title; 287 if Item.Index = JobProgressView.CurrentJobIndex then Item.ImageIndex := 1 288 else if Finished then Item.ImageIndex := 0 289 else Item.ImageIndex := 2; 290 Item.Data := JobProgressView.Jobs[Item.Index]; 291 end; 292 end; 293 294 procedure TFormJobProgressView.FormClose(Sender: TObject; 295 var CloseAction: TCloseAction); 296 begin 297 end; 298 299 procedure TFormJobProgressView.FormCreate(Sender: TObject); 300 begin 301 Caption := SPleaseWait; 302 try 303 //Animate1.FileName := ExtractFileDir(UTF8Encode(Application.ExeName)) + 304 // DirectorySeparator + 'horse.avi'; 305 //Animate1.Active := True; 306 except 307 308 end; 309 end; 310 311 procedure TFormJobProgressView.ReloadJobList; 312 begin 313 // Workaround for not showing first line 314 //Form.ListViewJobs.Items.Count := Jobs.Count + 1; 315 //Form.ListViewJobs.Refresh; 316 317 if ListViewJobs.Items.Count <> JobProgressView.Jobs.Count then 318 ListViewJobs.Items.Count := JobProgressView.Jobs.Count; 319 ListViewJobs.Refresh; 320 Application.ProcessMessages; 321 UpdateHeight; 322 end; 323 324 procedure TFormJobProgressView.FormShow(Sender: TObject); 325 begin 326 ReloadJobList; 327 end; 328 329 procedure TFormJobProgressView.FormHide(Sender: TObject); 330 begin 331 JobProgressView.Jobs.Clear; 332 ReloadJobList; 333 end; 334 335 procedure TFormJobProgressView.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 336 begin 337 CanClose := JobProgressView.Finished; 338 JobProgressView.Terminate := True; 339 Caption := SPleaseWait + STerminate; 340 end; 341 342 343 { TJobProgressView } 344 345 function TJobProgressView.AddJob(Title: string; Method: TJobProgressViewMethod; 346 NoThreaded: Boolean = False; WaitFor: Boolean = False): TJob; 347 begin 348 Result := TJob.Create; 349 Result.ProgressView := Self; 350 Result.Title := Title; 351 Result.Method := Method; 352 Result.NoThreaded := NoThreaded; 353 Result.WaitFor := WaitFor; 354 Result.Progress.Max := 100; 355 Result.Progress.Reset; 356 Result.Progress.OnChange := JobProgressChange; 357 Jobs.Add(Result); 207 358 //ReloadJobList; 208 359 end; 209 360 210 procedure TJobProgressView.Start(AAutoClose: Boolean = True); 211 begin 212 AutoClose := AAutoClose; 213 StartJobs; 214 end; 215 216 procedure TJobProgressView.StartJobs; 361 procedure TJobProgressView.Start; 217 362 var 218 363 I: Integer; … … 229 374 Form.MemoLog.Clear; 230 375 376 Form.PanelText.Visible := False; 231 377 Form.LabelEstimatedTimePart.Visible := False; 232 378 Form.LabelEstimatedTimeTotal.Visible := False; … … 249 395 I := 0; 250 396 while I < Jobs.Count do 251 with TJob(Jobs[I])do begin397 with Jobs[I] do begin 252 398 CurrentJobIndex := I; 253 CurrentJob := TJob(Jobs[I]);399 CurrentJob := Jobs[I]; 254 400 JobProgressChange(Self); 255 401 StartTime := Now; … … 258 404 Form.ProgressBarPart.Visible := False; 259 405 //Show; 260 ReloadJobList;406 Form.ReloadJobList; 261 407 Application.ProcessMessages; 262 408 if NoThreaded then begin … … 264 410 Method(CurrentJob); 265 411 end else begin 412 Thread := TJobThread.Create(True); 266 413 try 267 Thread := TJobThread.Create(True);268 414 with Thread do begin 269 415 FreeOnTerminate := False; … … 296 442 //if Visible then Hide; 297 443 Form.MemoLog.Lines.Assign(Log); 298 if (Form.MemoLog.Lines.Count = 0) and AutoClose then begin444 if (Form.MemoLog.Lines.Count = 0) and FAutoClose then begin 299 445 Form.Hide; 300 446 end; 301 Clear;447 if not Form.Visible then Clear; 302 448 Form.Caption := SFinished; 303 449 //LabelEstimatedTimePart.Visible := False; 304 450 Finished := True; 305 451 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; 452 Form.ReloadJobList; 347 453 end; 348 454 end; … … 352 458 if Assigned(FOnOwnerDraw) then 353 459 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 460 end; 411 461 … … 428 478 end; 429 479 430 procedure TFormJobProgressView.FormCloseQuery(Sender: TObject; var CanClose: Boolean);431 begin432 CanClose := JobProgressView.Finished;433 JobProgressView.Terminate := True;434 Caption := SPleaseWait + STerminate;435 end;436 437 480 procedure TJobProgressView.SetTerminate(const AValue: Boolean); 438 481 var … … 441 484 if AValue = FTerminate then Exit; 442 485 for I := 0 to Jobs.Count - 1 do 443 TJob(Jobs[I]).Terminate := AValue;486 Jobs[I].Terminate := AValue; 444 487 FTerminate := AValue; 445 488 end; … … 490 533 end; 491 534 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 535 constructor TJobProgressView.Create(TheOwner: TComponent); 506 536 begin 507 537 inherited; 508 538 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;539 FForm := TFormJobProgressView.Create(Self); 540 FForm.JobProgressView := Self; 541 end; 542 Jobs := TJobs.Create; 513 543 Log := TStringList.Create; 514 544 //PanelOperationsTitle.Height := 80; 515 ShowDelay := 0; //1000; // ms 545 AutoClose := True; 546 ShowDelay := 0; 516 547 end; 517 548 … … 519 550 begin 520 551 Jobs.Clear; 552 Log.Clear; 521 553 //ReloadJobList; 522 554 end; … … 528 560 inherited; 529 561 end; 562 563 { TProgress } 530 564 531 565 procedure TProgress.SetMax(const AValue: Integer); … … 536 570 if FMax < 1 then FMax := 1; 537 571 if FValue >= FMax then FValue := FMax; 572 finally 573 FLock.Release; 574 end; 575 end; 576 577 procedure TProgress.SetText(AValue: string); 578 begin 579 try 580 FLock.Acquire; 581 if FText = AValue then Exit; 582 FText := AValue; 538 583 finally 539 584 FLock.Release; … … 563 608 end; 564 609 565 { TProgress }566 567 610 procedure TProgress.Increment; 568 611 begin 569 try570 FLock.Acquire;612 FLock.Acquire; 613 try 571 614 Value := Value + 1; 572 615 finally … … 577 620 procedure TProgress.Reset; 578 621 begin 579 try580 FLock.Acquire;622 FLock.Acquire; 623 try 581 624 FValue := 0; 582 625 finally … … 594 637 begin 595 638 FLock.Free; 596 inherited Destroy;639 inherited; 597 640 end; 598 641 … … 625 668 destructor TJob.Destroy; 626 669 begin 627 Progress.Free;670 FreeAndNil(Progress); 628 671 inherited; 629 672 end; -
trunk/Packages/Common/Languages/DebugLog.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: JiÅÃ Hajda <robie@centrum.cz>\n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.0.1\n" 11 13 12 #: udebuglog.sfilenamenotdefined 14 #: debuglog.sfilenamenotdefined 15 msgctxt "debuglog.sfilenamenotdefined" 13 16 msgid "Filename not defined" 14 17 msgstr "NeurÄen soubor" -
trunk/Packages/Common/Languages/FindFile.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: \n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 11 "Language: cs\n" 12 "X-Generator: Poedit 1.8.9\n" 12 "X-Generator: Poedit 3.0.1\n" 13 13 14 #: ufindfile.sdirnotfound 14 #: findfile.sdirnotfound 15 msgctxt "findfile.sdirnotfound" 15 16 msgid "Directory not found" 16 17 msgstr "AdresáŠnenalezen" -
trunk/Packages/Common/Languages/JobProgressView.cs.po
r20 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 3.0.1\n" 13 13 14 #: ujobprogressview.sestimatedtime14 #: jobprogressview.sestimatedtime 15 15 #, object-pascal-format 16 msgctxt "jobprogressview.sestimatedtime" 16 17 msgid "Estimated time: %s" 17 18 msgstr "OdhadovanÃœ Äas: %s" 18 19 19 #: ujobprogressview.sexecuted 20 #: jobprogressview.sexecuted 21 msgctxt "jobprogressview.sexecuted" 20 22 msgid "Executed" 21 23 msgstr "Vykonané" 22 24 23 #: ujobprogressview.sfinished 25 #: jobprogressview.sfinished 26 msgctxt "jobprogressview.sfinished" 24 27 msgid "Finished" 25 28 msgstr "DokonÄené" 26 29 27 #: ujobprogressview.soperations 28 msgid "Operations" 29 msgstr "Operace" 30 31 #: ujobprogressview.spleasewait 30 #: jobprogressview.spleasewait 31 msgctxt "jobprogressview.spleasewait" 32 32 msgid "Please wait..." 33 33 msgstr "ProsÃm Äekejte..." 34 34 35 #: ujobprogressview.sterminate 35 #: jobprogressview.sterminate 36 msgctxt "jobprogressview.sterminate" 36 37 msgid "Termination" 37 38 msgstr "PÅeruÅ¡enÃ" 38 39 39 #: ujobprogressview.stotalestimatedtime40 #: jobprogressview.stotalestimatedtime 40 41 #, object-pascal-format 42 msgctxt "jobprogressview.stotalestimatedtime" 41 43 msgid "Total estimated time: %s" 42 44 msgstr "CelkovÃœ odhadovanÃœ Äas: %s" -
trunk/Packages/Common/Languages/Pool.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: Chronos <robie@centrum.cz>\n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.0.1\n" 11 13 12 #: upool.sobjectpoolempty 14 #: pool.sobjectpoolempty 15 msgctxt "pool.sobjectpoolempty" 13 16 msgid "Object pool is empty" 14 17 msgstr "ZásobnÃk objektů je prázdnÃœ" 15 18 16 #: upool.sreleaseerror 19 #: pool.sreleaseerror 20 msgctxt "pool.sreleaseerror" 17 21 msgid "Unknown object for release from pool" 18 22 msgstr "NeznÃœmÃœ objekt pro uvolnÄnà ze zásobnÃku" -
trunk/Packages/Common/Languages/ResetableThread.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: Chronos <robie@centrum.cz>\n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.0.1\n" 11 13 12 #: uresetablethread.swaiterror 14 #: resetablethread.swaiterror 15 msgctxt "resetablethread.swaiterror" 13 16 msgid "WaitFor error" 14 17 msgstr "Chyba WaitFor" -
trunk/Packages/Common/Languages/ScaleDPI.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: \n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 11 "Language: cs\n" 12 "X-Generator: Poedit 1.8.9\n" 12 "X-Generator: Poedit 3.0.1\n" 13 13 14 #: uscaledpi.swrongdpi14 #: scaledpi.swrongdpi 15 15 #, object-pascal-format 16 msgctxt "scaledpi.swrongdpi" 16 17 msgid "Wrong DPI [%d,%d]" 17 18 msgstr "Chybné DPI [%d,%d]" -
trunk/Packages/Common/Languages/Threading.cs.po
r20 r21 1 1 msgid "" 2 2 msgstr "" 3 "Content-Type: text/plain; charset=UTF-8\n"4 3 "Project-Id-Version: \n" 5 4 "POT-Creation-Date: \n" … … 7 6 "Last-Translator: Chronos <robie@centrum.cz>\n" 8 7 "Language-Team: \n" 8 "Language: cs\n" 9 9 "MIME-Version: 1.0\n" 10 "Content-Type: text/plain; charset=UTF-8\n" 10 11 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.0.1\n" 11 13 12 #: uthreading.scurrentthreadnotfound14 #: threading.scurrentthreadnotfound 13 15 #, object-pascal-format 16 msgctxt "threading.scurrentthreadnotfound" 14 17 msgid "Current thread ID %d not found in virtual thread list." 15 18 msgstr "Aktuálnà vlákno ID %d nenalezeno v seznamu virtuálnÃch vláken." -
trunk/Packages/Common/LastOpenedList.pas
r20 r21 1 unit ULastOpenedList; 2 3 {$mode delphi} 1 unit LastOpenedList; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf;6 Classes, SysUtils, Registry, RegistryEx, Menus, XMLConf, DOM; 9 7 10 8 type … … 30 28 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 31 29 procedure AddItem(FileName: string); 30 function GetFirstFileName: string; 32 31 published 33 32 property MaxCount: Integer read FMaxCount write SetMaxCount; … … 83 82 destructor TLastOpenedList.Destroy; 84 83 begin 85 Items.Free;84 FreeAndNil(Items); 86 85 inherited; 87 86 end; … … 93 92 begin 94 93 if Assigned(MenuItem) then begin 95 MenuItem.Clear; 94 while MenuItem.Count > Items.Count do 95 MenuItem.Delete(MenuItem.Count - 1); 96 while MenuItem.Count < Items.Count do begin 97 NewMenuItem := TMenuItem.Create(MenuItem); 98 MenuItem.Add(NewMenuItem); 99 end; 96 100 for I := 0 to Items.Count - 1 do begin 97 NewMenuItem := TMenuItem.Create(MenuItem); 98 NewMenuItem.Caption := Items[I]; 99 NewMenuItem.OnClick := ClickAction; 100 MenuItem.Add(NewMenuItem); 101 MenuItem.Items[I].Caption := Items[I]; 102 MenuItem.Items[I].OnClick := ClickAction; 101 103 end; 102 104 end; … … 139 141 OpenKey(Context.Key, True); 140 142 for I := 0 to Items.Count - 1 do 141 WriteString('File' + IntToStr(I), UTF8Decode(Items[I]));143 WriteString('File' + IntToStr(I), Items[I]); 142 144 finally 143 145 Free; … … 153 155 begin 154 156 with XMLConfig do begin 155 Count := GetValue( Path + '/Count', 0);157 Count := GetValue(DOMString(Path + '/Count'), 0); 156 158 if Count > MaxCount then Count := MaxCount; 157 159 Items.Clear; 158 160 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), '');161 Value := string(GetValue(DOMString(Path + '/File' + IntToStr(I)), '')); 160 162 if Trim(Value) <> '' then Items.Add(Value); 161 163 end; … … 170 172 begin 171 173 with XMLConfig do begin 172 SetValue( Path + '/Count', Items.Count);174 SetValue(DOMString(Path + '/Count'), Items.Count); 173 175 for I := 0 to Items.Count - 1 do 174 SetValue( Path + '/File' + IntToStr(I), Items[I]);176 SetValue(DOMString(Path + '/File' + IntToStr(I)), DOMString(Items[I])); 175 177 Flush; 176 178 end; … … 185 187 end; 186 188 189 function TLastOpenedList.GetFirstFileName: string; 190 begin 191 if Items.Count > 0 then Result := Items[0] 192 else Result := ''; 193 end; 194 187 195 end. 188 -
trunk/Packages/Common/ListViewSort.pas
r20 r21 1 unit UListViewSort; 2 3 // Date: 2010-11-03 4 5 {$mode delphi} 1 unit ListViewSort; 2 3 // Date: 2019-05-17 6 4 7 5 interface 8 6 9 7 uses 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;8 {$IFDEF Windows}Windows, CommCtrl, LMessages, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils, 9 Controls, DateUtils, Dialogs, Forms, Grids, StdCtrls, ExtCtrls, 10 LclIntf, LclType, LResources, Generics.Collections, Generics.Defaults; 13 11 14 12 type … … 19 17 TCompareEvent = function (Item1, Item2: TObject): Integer of object; 20 18 TListFilterEvent = procedure (ListViewSort: TListViewSort) of object; 19 20 TObjects = TObjectList<TObject>; 21 21 22 22 { TListViewSort } … … 52 52 {$ENDIF} 53 53 public 54 List: TListObject;55 Source: TListObject;54 Source: TObjects; 55 List: TObjects; 56 56 constructor Create(AOwner: TComponent); override; 57 57 destructor Destroy; override; … … 81 81 FOnChange: TNotifyEvent; 82 82 FStringGrid1: TStringGrid; 83 procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 84 procedure DoOnResize(Sender: TObject); 83 procedure DoOnChange; 84 procedure GridDoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 85 procedure GridDoOnResize(Sender: TObject); 85 86 public 86 87 constructor Create(AOwner: TComponent); override; … … 90 91 function TextEnteredColumn(Index: Integer): Boolean; 91 92 function GetColValue(Index: Integer): string; 93 procedure Reset; 92 94 property StringGrid: TStringGrid read FStringGrid1 write FStringGrid1; 93 95 published … … 98 100 end; 99 101 102 { TListViewEx } 103 104 TListViewEx = class(TWinControl) 105 private 106 FFilter: TListViewFilter; 107 FListView: TListView; 108 FListViewSort: TListViewSort; 109 procedure ResizeHanlder; 110 public 111 constructor Create(TheOwner: TComponent); override; 112 destructor Destroy; override; 113 published 114 property ListView: TListView read FListView write FListView; 115 property ListViewSort: TListViewSort read FListViewSort write FListViewSort; 116 property Filter: TListViewFilter read FFilter write FFilter; 117 property Visible; 118 end; 119 100 120 procedure Register; 101 121 … … 105 125 procedure Register; 106 126 begin 107 RegisterComponents('Common', [TListViewSort, TListViewFilter]); 127 RegisterComponents('Common', [TListViewSort, TListViewFilter, TListViewEx]); 128 end; 129 130 { TListViewEx } 131 132 procedure TListViewEx.ResizeHanlder; 133 begin 134 end; 135 136 constructor TListViewEx.Create(TheOwner: TComponent); 137 begin 138 inherited; 139 Filter := TListViewFilter.Create(Self); 140 Filter.Parent := Self; 141 Filter.Align := alBottom; 142 ListView := TListView.Create(Self); 143 ListView.Parent := Self; 144 ListView.Align := alClient; 145 ListViewSort := TListViewSort.Create(Self); 146 ListViewSort.ListView := ListView; 147 end; 148 149 destructor TListViewEx.Destroy; 150 begin 151 inherited; 108 152 end; 109 153 110 154 { TListViewFilter } 111 155 112 procedure TListViewFilter.DoOnKeyUp(Sender: TObject; var Key: Word; 156 procedure TListViewFilter.DoOnChange; 157 begin 158 if Assigned(FOnChange) then FOnChange(Self); 159 end; 160 161 procedure TListViewFilter.GridDoOnKeyUp(Sender: TObject; var Key: Word; 113 162 Shift: TShiftState); 114 163 begin 115 if Assigned(FOnChange) then 116 FOnChange(Self); 117 end; 118 119 procedure TListViewFilter.DoOnResize(Sender: TObject); 164 DoOnChange; 165 end; 166 167 procedure TListViewFilter.GridDoOnResize(Sender: TObject); 120 168 begin 121 169 FStringGrid1.DefaultRowHeight := FStringGrid1.Height; … … 124 172 constructor TListViewFilter.Create(AOwner: TComponent); 125 173 begin 126 inherited Create(AOwner);174 inherited; 127 175 FStringGrid1 := TStringGrid.Create(Self); 128 176 FStringGrid1.Align := alClient; … … 135 183 FStringGrid1.Options := [goFixedHorzLine, goFixedVertLine, goVertLine, 136 184 goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll]; 137 FStringGrid1.OnKeyUp := DoOnKeyUp;138 FStringGrid1.OnResize := DoOnResize;185 FStringGrid1.OnKeyUp := GridDoOnKeyUp; 186 FStringGrid1.OnResize := GridDoOnResize; 139 187 end; 140 188 … … 142 190 var 143 191 I: Integer; 192 R: TRect; 144 193 begin 145 194 with FStringGrid1 do begin 146 //Columns.Clear;147 195 while Columns.Count > ListView.Columns.Count do Columns.Delete(Columns.Count - 1); 148 196 while Columns.Count < ListView.Columns.Count do Columns.Add; 149 197 for I := 0 to ListView.Columns.Count - 1 do begin 150 198 Columns[I].Width := ListView.Columns[I].Width; 199 if Selection.Left = I then begin 200 R := CellRect(I, 0); 201 Editor.Left := R.Left + 2; 202 Editor.Width := R.Width - 4; 203 end; 151 204 end; 152 205 end; … … 182 235 end; 183 236 237 procedure TListViewFilter.Reset; 238 var 239 I: Integer; 240 begin 241 with StringGrid do 242 for I := 0 to ColCount - 1 do 243 Cells[I, 0] := ''; 244 DoOnChange; 245 end; 246 184 247 { TListViewSort } 185 248 … … 197 260 if AMsg.Msg = WM_NOTIFY then 198 261 begin 199 Code := PHDNotify(vMsgNotify.NMHdr)^.Hdr.Code;262 Code := NMHDR(PHDNotify(vMsgNotify.NMHdr)^.Hdr).Code; 200 263 case Code of 201 264 HDN_ENDTRACKA, HDN_ENDTRACKW: … … 272 335 end; 273 336 337 var 338 ListViewSortCompare: TCompareEvent; 339 340 function ListViewCompare(constref Item1, Item2: TObject): Integer; 341 begin 342 Result := ListViewSortCompare(Item1, Item2); 343 end; 344 274 345 procedure TListViewSort.Sort(Compare: TCompareEvent); 275 346 begin 347 // TODO: Because TFLGObjectList compare handler is not class method, 348 // it is necessary to use simple function compare handler with local variable 349 ListViewSortCompare := Compare; 276 350 if (List.Count > 0) then 277 List.Sort( Compare);351 List.Sort(TComparer<TObject>.Construct(ListViewCompare)); 278 352 end; 279 353 … … 281 355 begin 282 356 if Assigned(FOnFilter) then FOnFilter(Self) 283 else if Assigned(Source) then 284 List.Assign(Source) else 357 else if Assigned(Source) then begin 285 358 List.Clear; 359 List.AddRange(Source); 360 end; 286 361 if ListView.Items.Count <> List.Count then 287 362 ListView.Items.Count := List.Count; … … 338 413 begin 339 414 inherited; 340 List := T ListObject.Create;415 List := TObjects.Create; 341 416 List.OwnsObjects := False; 342 417 end; … … 344 419 destructor TListViewSort.Destroy; 345 420 begin 346 List.Free;421 FreeAndNil(List); 347 422 inherited; 348 423 end; … … 353 428 TP1: TPoint; 354 429 XBias, YBias: Integer; 355 OldColor: TColor; 430 PenColor: TColor; 431 BrushColor: TColor; 356 432 BiasTop, BiasLeft: Integer; 357 433 Rect1: TRect; … … 365 441 Item.Left := 0; 366 442 GetCheckBias(XBias, YBias, BiasTop, BiasLeft, ListView); 367 OldColor := ListView.Canvas.Pen.Color; 443 PenColor := ListView.Canvas.Pen.Color; 444 BrushColor := ListView.Canvas.Brush.Color; 368 445 //TP1 := Item.GetPosition; 369 446 lRect := Item.DisplayRect(drBounds); // Windows 7 workaround … … 377 454 ItemLeft := Item.Left; 378 455 ItemLeft := 23; // Windows 7 workaround 379 456 380 457 Rect1.Left := ItemLeft - CheckWidth - BiasLeft + 1 + XBias; 381 458 //ShowMessage(IntToStr(Tp1.Y) + ', ' + IntToStr(BiasTop) + ', ' + IntToStr(XBias)); … … 408 485 end; 409 486 //ListView.Canvas.Brush.Color := ListView.Color; 410 ListView.Canvas.Brush.Color := clWindow;411 ListView.Canvas.Pen.Color := OldColor;487 ListView.Canvas.Brush.Color := BrushColor; 488 ListView.Canvas.Pen.Color := PenColor; 412 489 end; 413 490 … … 476 553 FHeaderHandle := ListView_GetHeader(FListView.Handle); 477 554 for I := 0 to FListView.Columns.Count - 1 do begin 555 {$push}{$warn 5057 off} 478 556 FillChar(Item, SizeOf(THDItem), 0); 557 {$pop} 479 558 Item.Mask := HDI_FORMAT; 480 559 Header_GetItem(FHeaderHandle, I, Item); -
trunk/Packages/Common/Memory.pas
r20 r21 1 unit UMemory; 2 3 {$mode Delphi}{$H+} 1 unit Memory; 4 2 5 3 interface … … 24 22 constructor Create; 25 23 destructor Destroy; override; 24 procedure WriteMemory(Position: Integer; Memory: TMemory); 25 procedure ReadMemory(Position: Integer; Memory: TMemory); 26 26 property Data: PByte read FData; 27 27 property Size: Integer read FSize write SetSize; … … 42 42 end; 43 43 44 44 45 implementation 45 46 … … 48 49 procedure TPositionMemory.SetSize(AValue: Integer); 49 50 begin 50 inherited SetSize(AValue);51 inherited; 51 52 if FPosition > FSize then FPosition := FSize; 52 53 end; … … 105 106 begin 106 107 Size := 0; 107 inherited Destroy; 108 inherited; 109 end; 110 111 procedure TMemory.WriteMemory(Position: Integer; Memory: TMemory); 112 begin 113 Move(Memory.FData, PByte(PByte(@FData) + Position)^, Memory.Size); 114 end; 115 116 procedure TMemory.ReadMemory(Position: Integer; Memory: TMemory); 117 begin 118 Move(PByte(PByte(@FData) + Position)^, Memory.FData, Memory.Size); 108 119 end; 109 120 110 121 end. 111 -
trunk/Packages/Common/PersistentForm.pas
r20 r21 1 unit UPersistentForm; 2 3 {$mode delphi} 4 5 // Date: 2015-04-18 1 unit PersistentForm; 6 2 7 3 interface 8 4 9 5 uses 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls; 6 Classes, SysUtils, Forms, RegistryEx, LCLIntf, Registry, Controls, ComCtrls, 7 ExtCtrls, LCLType; 11 8 12 9 type … … 19 16 FMinVisiblePart: Integer; 20 17 FRegistryContext: TRegistryContext; 18 FResizeEventOccured: Boolean; 21 19 procedure LoadControl(Control: TControl); 22 20 procedure SaveControl(Control: TControl); 21 procedure WindowStateChange(Sender: TObject); 23 22 public 24 FormNormalSize: TRect;25 23 FormRestoredSize: TRect; 26 24 FormWindowState: TWindowState; 25 FormFullScreen: Boolean; 27 26 Form: TForm; 28 27 procedure LoadFromRegistry(RegistryContext: TRegistryContext); … … 30 29 function CheckEntireVisible(Rect: TRect): TRect; 31 30 function CheckPartVisible(Rect: TRect; Part: Integer): TRect; 32 procedure Load(Form: TForm; DefaultMaximized: Boolean = False); 31 procedure Load(Form: TForm; DefaultMaximized: Boolean = False; 32 DefaultFullScreen: Boolean = False); 33 33 procedure Save(Form: TForm); 34 34 constructor Create(AOwner: TComponent); override; 35 procedure SetFullScreen(State: Boolean); 35 36 property RegistryContext: TRegistryContext read FRegistryContext 36 37 write FRegistryContext; … … 42 43 procedure Register; 43 44 45 44 46 implementation 45 46 47 47 48 procedure Register; … … 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 … … 120 154 RootKey := RegistryContext.RootKey; 121 155 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True); 122 // Normal size 123 FormNormalSize.Left := ReadIntegerWithDefault('NormalLeft', FormNormalSize.Left); 124 FormNormalSize.Top := ReadIntegerWithDefault('NormalTop', FormNormalSize.Top); 125 FormNormalSize.Right := ReadIntegerWithDefault('NormalWidth', FormNormalSize.Right - FormNormalSize.Left) 126 + FormNormalSize.Left; 127 FormNormalSize.Bottom := ReadIntegerWithDefault('NormalHeight', FormNormalSize.Bottom - FormNormalSize.Top) 128 + FormNormalSize.Top; 156 129 157 // Restored size 130 158 FormRestoredSize.Left := ReadIntegerWithDefault('RestoredLeft', FormRestoredSize.Left); … … 134 162 FormRestoredSize.Bottom := ReadIntegerWithDefault('RestoredHeight', FormRestoredSize.Bottom - FormRestoredSize.Top) 135 163 + FormRestoredSize.Top; 164 136 165 // Other state 137 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal))); 166 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(FormWindowState))); 167 FormFullScreen := ReadBoolWithDefault('FullScreen', FormFullScreen); 138 168 finally 139 169 Free; … … 147 177 RootKey := RegistryContext.RootKey; 148 178 OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True); 149 // Normal state 150 WriteInteger('NormalWidth', FormNormalSize.Right - FormNormalSize.Left); 151 WriteInteger('NormalHeight', FormNormalSize.Bottom - FormNormalSize.Top); 152 WriteInteger('NormalTop', FormNormalSize.Top); 153 WriteInteger('NormalLeft', FormNormalSize.Left); 154 // Restored state 179 180 // Restored size 155 181 WriteInteger('RestoredWidth', FormRestoredSize.Right - FormRestoredSize.Left); 156 182 WriteInteger('RestoredHeight', FormRestoredSize.Bottom - FormRestoredSize.Top); 157 183 WriteInteger('RestoredTop', FormRestoredSize.Top); 158 184 WriteInteger('RestoredLeft', FormRestoredSize.Left); 185 159 186 // Other state 160 187 WriteInteger('WindowState', Integer(FormWindowState)); 188 WriteBool('FullScreen', FormFullScreen); 161 189 finally 162 190 Free; … … 216 244 end; 217 245 218 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False); 219 var 220 LoadDefaults: Boolean; 246 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False; 247 DefaultFullScreen: Boolean = False); 221 248 begin 222 249 Self.Form := Form; 250 223 251 // Set default 224 FormNormalSize := Bounds((Screen.Width - Form.Width) div 2,225 (Screen.Height - Form.Height) div 2, Form.Width, Form.Height);226 252 FormRestoredSize := Bounds((Screen.Width - Form.Width) div 2, 227 253 (Screen.Height - Form.Height) div 2, Form.Width, Form.Height); 254 FormWindowState := Form.WindowState; 255 FormFullScreen := DefaultFullScreen; 228 256 229 257 LoadFromRegistry(RegistryContext); 230 258 231 if not EqualRect(FormNormalSize, FormRestoredSize) or 232 (LoadDefaults and DefaultMaximized) then begin 259 if (FormWindowState = wsMaximized) or DefaultMaximized then begin 233 260 // Restore to maximized state 234 261 Form.WindowState := wsNormal; … … 239 266 // Restore to normal state 240 267 Form.WindowState := wsNormal; 241 if FEntireVisible then Form NormalSize := CheckEntireVisible(FormNormalSize)268 if FEntireVisible then FormRestoredSize := CheckEntireVisible(FormRestoredSize) 242 269 else if FMinVisiblePart > 0 then 243 FormNormalSize := CheckPartVisible(FormNormalSize, FMinVisiblePart); 244 if not EqualRect(FormNormalSize, Form.BoundsRect) then 245 Form.BoundsRect := FormNormalSize; 246 end; 270 FormRestoredSize := CheckPartVisible(FormRestoredSize, FMinVisiblePart); 271 if not EqualRect(FormRestoredSize, Form.BoundsRect) then 272 Form.BoundsRect := FormRestoredSize; 273 end; 274 if FormFullScreen then SetFullScreen(True); 247 275 LoadControl(Form); 248 276 end; … … 251 279 begin 252 280 Self.Form := Form; 253 FormNormalSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height); 254 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 255 Form.RestoredHeight); 256 FormWindowState := Form.WindowState; 281 if not FormFullScreen then begin 282 FormWindowState := Form.WindowState; 283 if FormWindowState = wsMaximized then begin 284 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 285 Form.RestoredHeight); 286 end else 287 if FormWindowState = wsNormal then begin 288 FormRestoredSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height); 289 end; 290 end; 257 291 SaveToRegistry(RegistryContext); 258 292 SaveControl(Form); … … 268 302 end; 269 303 304 procedure TPersistentForm.SetFullScreen(State: Boolean); 305 {$IFDEF UNIX} 306 var 307 OldHandler: TNotifyEvent; 308 var 309 I: Integer; 310 {$ENDIF} 311 begin 312 if State then begin 313 FormFullScreen := True; 314 if Form.WindowState = wsMaximized then begin 315 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 316 Form.RestoredHeight); 317 end else 318 if Form.WindowState = wsNormal then begin 319 FormRestoredSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height); 320 end; 321 FormWindowState := Form.WindowState; 322 {$IFDEF WINDOWS} 323 Form.BorderStyle := bsNone; 324 {$ENDIF} 325 Form.WindowState := wsFullscreen; 326 {$IFDEF UNIX} 327 // Workaround on Linux, WindowState is rewriten by WMSize event to wsNormal. 328 // We need for that even to occure 329 OldHandler := Form.OnWindowStateChange; 330 Form.OnWindowStateChange := WindowStateChange; 331 FResizeEventOccured := False; 332 for I := 0 to 10 do begin 333 if FResizeEventOccured then Break; 334 Application.ProcessMessages; 335 Sleep(1); 336 end; 337 Form.OnWindowStateChange := OldHandler; 338 FormFullScreen := True; 339 {$ENDIF} 340 end else begin 341 FormFullScreen := False; 342 Form.WindowState := wsNormal; 343 {$IFDEF WINDOWS} 344 Form.BorderStyle := bsSizeable; 345 {$ENDIF} 346 if FormWindowState = wsNormal then begin 347 Form.WindowState := wsNormal; 348 Form.BoundsRect := FormRestoredSize; 349 end else 350 if FormWindowState = wsMaximized then begin 351 Form.BoundsRect := FormRestoredSize; 352 Form.WindowState := wsMaximized; 353 end; 354 end; 355 end; 356 357 procedure TPersistentForm.WindowStateChange(Sender: TObject); 358 begin 359 Form.WindowState := wsFullscreen; 360 FResizeEventOccured := True; 361 end; 362 270 363 end. 271 -
trunk/Packages/Common/Pool.pas
r20 r21 1 unit UPool; 2 3 {$mode Delphi}{$H+} 1 unit Pool; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, syncobjs, SpecializedList, UThreading;6 Classes, SysUtils, syncobjs, Generics.Collections, Threading; 9 7 10 8 type … … 22 20 function NewItemObject: TObject; virtual; 23 21 public 24 Items: T ListObject;25 FreeItems: T ListObject;22 Items: TObjectList<TObject>; 23 FreeItems: TObjectList<TObject>; 26 24 function Acquire: TObject; virtual; 27 25 procedure Release(Item: TObject); virtual; … … 59 57 try 60 58 Lock.Acquire; 61 inherited SetTotalCount(AValue);59 inherited; 62 60 finally 63 61 Lock.Release; … … 69 67 try 70 68 Lock.Acquire; 71 Result := inherited GetUsedCount;69 Result := inherited; 72 70 finally 73 71 Lock.Release; … … 90 88 end; 91 89 end; 92 Result := inherited Acquire;90 Result := inherited; 93 91 finally 94 92 Lock.Release; … … 100 98 try 101 99 Lock.Acquire; 102 inherited Release(Item);100 inherited; 103 101 finally 104 102 Lock.Release; … … 108 106 constructor TThreadedPool.Create; 109 107 begin 110 inherited Create;108 inherited; 111 109 Lock := TCriticalSection.Create; 112 110 end; … … 115 113 begin 116 114 TotalCount := 0; 117 Lock.Free;118 inherited Destroy;115 FreeAndNil(Lock); 116 inherited; 119 117 end; 120 118 … … 185 183 begin 186 184 inherited; 187 Items := T ListObject.Create;188 FreeItems := T ListObject.Create;185 Items := TObjectList<TObject>.Create; 186 FreeItems := TObjectList<TObject>.Create; 189 187 FreeItems.OwnsObjects := False; 190 188 FReleaseEvent := TEvent.Create(nil, False, False, ''); … … 201 199 202 200 end. 203 -
trunk/Packages/Common/PrefixMultiplier.pas
r20 r21 1 unit UPrefixMultiplier;1 unit PrefixMultiplier; 2 2 3 3 // Date: 2010-06-01 4 5 {$mode delphi}6 4 7 5 interface … … 21 19 { TPrefixMultiplier } 22 20 23 TPrefixMultiplier = class 21 TPrefixMultiplier = class(TComponent) 24 22 private 25 function TruncateDigits(Value: Double;Digits:Integer=3):Double;23 function TruncateDigits(Value: Double; Digits: Integer = 3): Double; 26 24 public 27 25 function Add(Value: Double; PrefixMultipliers: TPrefixMultiplierDef; … … 33 31 ( 34 32 (ShortText: 'y'; FullText: 'yocto'; Value: 1e-24), 35 33 (ShortText: 'z'; FullText: 'zepto'; Value: 1e-21), 36 34 (ShortText: 'a'; FullText: 'atto'; Value: 1e-18), 37 35 (ShortText: 'f'; FullText: 'femto'; Value: 1e-15), … … 54 52 ( 55 53 (ShortText: 'ys'; FullText: 'yocto'; Value: 1e-24), 56 54 (ShortText: 'zs'; FullText: 'zepto'; Value: 1e-21), 57 55 (ShortText: 'as'; FullText: 'atto'; Value: 1e-18), 58 56 (ShortText: 'fs'; FullText: 'femto'; Value: 1e-15), … … 72 70 ); 73 71 72 procedure Register; 73 74 74 75 implementation 76 77 procedure Register; 78 begin 79 RegisterComponents('Common', [TPrefixMultiplier]); 80 end; 75 81 76 82 { TPrefixMultiplier } … … 92 98 end; 93 99 94 function TPrefixMultiplier.Add(Value: Double;PrefixMultipliers:TPrefixMultiplierDef95 ; UnitText:string;Digits:Integer):string;100 function TPrefixMultiplier.Add(Value: Double; PrefixMultipliers: TPrefixMultiplierDef 101 ; UnitText:string; Digits: Integer): string; 96 102 var 97 103 I: Integer; … … 118 124 119 125 end. 120 -
trunk/Packages/Common/RegistryEx.pas
r20 r21 1 unit URegistry; 2 3 {$MODE Delphi} 1 unit RegistryEx; 4 2 5 3 interface … … 9 7 10 8 type 11 TRegistryRoot = (rrKeyClassesRoot = HKEY($80000000), 12 rrKeyCurrentUser = HKEY($80000001), 13 rrKeyLocalMachine = HKEY($80000002), 14 rrKeyUsers = HKEY($80000003), 15 rrKeyPerformanceData = HKEY($80000004), 16 rrKeyCurrentConfig = HKEY($80000005), 17 rrKeyDynData = HKEY($80000006)); 9 TRegistryRoot = (rrKeyClassesRoot, rrKeyCurrentUser, rrKeyLocalMachine, 10 rrKeyUsers, rrKeyPerformanceData, rrKeyCurrentConfig, rrKeyDynData); 18 11 19 12 { TRegistryContext } … … 22 15 RootKey: HKEY; 23 16 Key: string; 17 class function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; static; overload; 18 class function Create(RootKey: HKEY; Key: string): TRegistryContext; static; overload; 24 19 class operator Equal(A, B: TRegistryContext): Boolean; 25 20 end; … … 32 27 procedure SetCurrentContext(AValue: TRegistryContext); 33 28 public 29 function ReadChar(const Name: string): Char; 30 procedure WriteChar(const Name: string; Value: Char); 34 31 function ReadBoolWithDefault(const Name: string; 35 32 DefaultValue: Boolean): Boolean; 36 33 function ReadIntegerWithDefault(const Name: string; DefaultValue: Integer): Integer; 37 34 function ReadStringWithDefault(const Name: string; DefaultValue: string): string; 35 function ReadCharWithDefault(const Name: string; DefaultValue: Char): Char; 38 36 function ReadFloatWithDefault(const Name: string; 39 37 DefaultValue: Double): Double; 38 function ReadDateTimeWithDefault(const Name: string; DefaultValue: TDateTime): TDateTime; 40 39 function DeleteKeyRecursive(const Key: string): Boolean; 41 40 function OpenKey(const Key: string; CanCreate: Boolean): Boolean; … … 43 42 end; 44 43 45 function RegContext(RootKey: HKEY; Key: string): TRegistryContext; 44 const 45 RegistryRootHKEY: array[TRegistryRoot] of HKEY = (HKEY_CLASSES_ROOT, 46 HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA, 47 HKEY_CURRENT_CONFIG, HKEY_DYN_DATA); 46 48 47 49 48 50 implementation 49 50 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;51 begin52 Result.RootKey := RootKey;53 Result.Key := Key;54 end;55 51 56 52 { TRegistryContext } … … 59 55 begin 60 56 Result := (A.Key = B.Key) and (A.RootKey = B.RootKey); 57 end; 58 59 class function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; 60 begin 61 Result.RootKey := RegistryRootHKEY[RootKey]; 62 Result.Key := Key; 63 end; 64 65 class function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext; 66 begin 67 Result.RootKey := RootKey; 68 Result.Key := Key; 61 69 end; 62 70 … … 83 91 end; 84 92 93 function TRegistryEx.ReadCharWithDefault(const Name: string; DefaultValue: Char 94 ): Char; 95 begin 96 if ValueExists(Name) then Result := ReadChar(Name) 97 else begin 98 WriteChar(Name, DefaultValue); 99 Result := DefaultValue; 100 end; 101 end; 102 85 103 function TRegistryEx.ReadFloatWithDefault(const Name: string; 86 104 DefaultValue: Double): Double; … … 89 107 else begin 90 108 WriteFloat(Name, DefaultValue); 109 Result := DefaultValue; 110 end; 111 end; 112 113 function TRegistryEx.ReadDateTimeWithDefault(const Name: string; 114 DefaultValue: TDateTime): TDateTime; 115 begin 116 if ValueExists(Name) then Result := ReadDateTime(Name) 117 else begin 118 WriteDateTime(Name, DefaultValue); 91 119 Result := DefaultValue; 92 120 end; … … 113 141 function TRegistryEx.OpenKey(const Key: string; CanCreate: Boolean): Boolean; 114 142 begin 115 {$IFDEF Linux}116 CloseKey;143 {$IFDEF UNIX} 144 //CloseKey; 117 145 {$ENDIF} 118 Result := inherited OpenKey(Key, CanCreate);146 Result := inherited; 119 147 end; 120 148 121 149 function TRegistryEx.GetCurrentContext: TRegistryContext; 122 150 begin 123 Result.Key := CurrentPath;151 Result.Key := String(CurrentPath); 124 152 Result.RootKey := RootKey; 125 153 end; … … 129 157 RootKey := AValue.RootKey; 130 158 OpenKey(AValue.Key, True); 159 end; 160 161 function TRegistryEx.ReadChar(const Name: string): Char; 162 var 163 S: string; 164 begin 165 S := ReadString(Name); 166 if Length(S) > 0 then Result := S[1] 167 else Result := #0; 168 end; 169 170 procedure TRegistryEx.WriteChar(const Name: string; Value: Char); 171 begin 172 WriteString(Name, Value); 131 173 end; 132 174 -
trunk/Packages/Common/ResetableThread.pas
r20 r21 1 unit UResetableThread; 2 3 {$mode Delphi}{$H+} 1 unit ResetableThread; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, syncobjs, UThreading, UPool;6 Classes, SysUtils, syncobjs, Threading, Pool; 9 7 10 8 type … … 156 154 FThread.Name := 'ResetableThread'; 157 155 FThread.Parent := Self; 158 FThread. Resume;156 FThread.Start; 159 157 end; 160 158 … … 167 165 FreeAndNil(FStopEvent); 168 166 FreeAndNil(FLock); 169 inherited Destroy;167 inherited; 170 168 end; 171 169 … … 286 284 constructor TThreadPool.Create; 287 285 begin 288 inherited Create;286 inherited; 289 287 end; 290 288 … … 293 291 TotalCount := 0; 294 292 WaitForEmpty; 295 inherited Destroy;293 inherited; 296 294 end; 297 295 298 296 end. 299 -
trunk/Packages/Common/ScaleDPI.pas
r20 r21 1 unit UScaleDPI;1 unit ScaleDPI; 2 2 3 3 { See: http://wiki.lazarus.freepascal.org/High_DPI } 4 4 5 {$mode delphi}{$H+}6 7 5 interface 8 6 9 7 uses 10 Classes, Forms, Graphics, Controls, ComCtrls, LCLType, SysUtils, StdCtrls,11 Contnrs;8 Classes, Forms, Graphics, Controls, ComCtrls, LCLType, SysUtils, 9 Generics.Collections; 12 10 13 11 type 12 TControlDimensions = class; 14 13 15 14 { TControlDimension } … … 18 17 BoundsRect: TRect; 19 18 FontHeight: Integer; 20 Controls: T ObjectList; // TList<TControlDimension>19 Controls: TControlDimensions; 21 20 // Class specifics 22 21 ButtonSize: TPoint; // TToolBar … … 26 25 constructor Create; 27 26 destructor Destroy; override; 27 end; 28 29 TControlDimensions = class(TObjectList<TControlDimension>) 28 30 end; 29 31 … … 73 75 constructor TControlDimension.Create; 74 76 begin 75 Controls := T ObjectList.Create;77 Controls := TControlDimensions.Create; 76 78 end; 77 79 … … 79 81 begin 80 82 FreeAndNil(Controls); 81 inherited Destroy;83 inherited; 82 84 end; 83 85 … … 212 214 TempBmp: TBitmap; 213 215 Temp: array of TBitmap; 214 NewWidth, NewHeight: integer; 215 I: Integer; 216 begin 217 NewWidth := ScaleX(ImgList.Width, FromDPI.X); 218 NewHeight := ScaleY(ImgList.Height, FromDPI.Y); 219 220 SetLength(Temp, ImgList.Count); 221 for I := 0 to ImgList.Count - 1 do 222 begin 223 TempBmp := TBitmap.Create; 224 TempBmp.PixelFormat := pf32bit; 225 ImgList.GetBitmap(I, TempBmp); 226 Temp[I] := TBitmap.Create; 227 Temp[I].SetSize(NewWidth, NewHeight); 228 Temp[I].PixelFormat := pf32bit; 229 Temp[I].TransparentColor := TempBmp.TransparentColor; 230 //Temp[I].TransparentMode := TempBmp.TransparentMode; 231 Temp[I].Transparent := True; 232 Temp[I].Canvas.Brush.Style := bsSolid; 233 Temp[I].Canvas.Brush.Color := Temp[I].TransparentColor; 234 Temp[I].Canvas.FillRect(0, 0, Temp[I].Width, Temp[I].Height); 235 236 if (Temp[I].Width = 0) or (Temp[I].Height = 0) then Continue; 237 Temp[I].Canvas.StretchDraw(Rect(0, 0, Temp[I].Width, Temp[I].Height), TempBmp); 238 TempBmp.Free; 239 end; 240 241 ImgList.Clear; 242 ImgList.Width := NewWidth; 243 ImgList.Height := NewHeight; 244 245 for I := 0 to High(Temp) do 246 begin 247 ImgList.Add(Temp[I], nil); 248 Temp[i].Free; 216 NewWidth: Integer; 217 NewHeight: Integer; 218 I: Integer; 219 begin 220 ImgList.BeginUpdate; 221 try 222 NewWidth := ScaleX(ImgList.Width, FromDPI.X); 223 NewHeight := ScaleY(ImgList.Height, FromDPI.Y); 224 225 Temp := nil; 226 SetLength(Temp, ImgList.Count); 227 for I := 0 to ImgList.Count - 1 do 228 begin 229 TempBmp := TBitmap.Create; 230 try 231 TempBmp.PixelFormat := pf32bit; 232 ImgList.GetBitmap(I, TempBmp); 233 Temp[I] := TBitmap.Create; 234 Temp[I].SetSize(NewWidth, NewHeight); 235 {$IFDEF UNIX} 236 Temp[I].PixelFormat := pf24bit; 237 {$ELSE} 238 Temp[I].PixelFormat := pf32bit; 239 {$ENDIF} 240 Temp[I].TransparentColor := TempBmp.TransparentColor; 241 //Temp[I].TransparentMode := TempBmp.TransparentMode; 242 Temp[I].Transparent := True; 243 Temp[I].Canvas.Brush.Style := bsSolid; 244 Temp[I].Canvas.Brush.Color := Temp[I].TransparentColor; 245 Temp[I].Canvas.FillRect(0, 0, Temp[I].Width, Temp[I].Height); 246 247 if (Temp[I].Width = 0) or (Temp[I].Height = 0) then Continue; 248 Temp[I].Canvas.StretchDraw(Rect(0, 0, Temp[I].Width, Temp[I].Height), TempBmp); 249 finally 250 TempBmp.Free; 251 end; 252 end; 253 254 ImgList.Clear; 255 ImgList.Width := NewWidth; 256 ImgList.Height := NewHeight; 257 258 for I := 0 to High(Temp) do 259 begin 260 ImgList.Add(Temp[I], nil); 261 Temp[i].Free; 262 end; 263 finally 264 ImgList.EndUpdate; 249 265 end; 250 266 end; … … 284 300 WinControl: TWinControl; 285 301 ToolBarControl: TToolBar; 286 OldAnchors: TAnchors; 287 OldAutoSize: Boolean; 288 begin 302 //OldAnchors: TAnchors; 303 //OldAutoSize: Boolean; 304 begin 305 //if not (Control is TCustomPage) then 306 // Resize childs first 307 if Control is TWinControl then begin 308 WinControl := TWinControl(Control); 309 if WinControl.ControlCount > 0 then begin 310 for I := 0 to WinControl.ControlCount - 1 do begin 311 if WinControl.Controls[I] is TControl then begin 312 ScaleControl(WinControl.Controls[I], FromDPI); 313 end; 314 end; 315 end; 316 end; 317 289 318 //if Control is TMemo then Exit; 290 319 //if Control is TForm then … … 312 341 with TCoolBar(Control) do begin 313 342 BeginUpdate; 314 for I := 0 to Bands.Count - 1 do 315 with Bands[I] do begin 316 MinWidth := ScaleX(MinWidth, FromDPI.X); 317 MinHeight := ScaleY(MinHeight, FromDPI.Y); 318 Width := ScaleX(Width, FromDPI.X); 319 //Control.Invalidate; 343 try 344 for I := 0 to Bands.Count - 1 do 345 with Bands[I] do begin 346 MinWidth := ScaleX(MinWidth, FromDPI.X); 347 MinHeight := ScaleY(MinHeight, FromDPI.Y); 348 // Workaround to bad band width auto sizing 349 //Width := ScaleX(Width, FromDPI.X); 350 Width := ScaleX(Control.Width + 28, FromDPI.X); 351 //Control.Invalidate; 352 end; 353 // Workaround for bad autosizing of coolbar 354 if AutoSize then begin 355 AutoSize := False; 356 Height := ScaleY(Height, FromDPI.Y); 357 AutoSize := True; 320 358 end; 321 EndUpdate; 359 finally 360 EndUpdate; 361 end; 322 362 end; 323 363 … … 330 370 end; 331 371 332 //if not (Control is TCustomPage) then333 if Control is TWinControl then begin334 WinControl := TWinControl(Control);335 if WinControl.ControlCount > 0 then begin336 for I := 0 to WinControl.ControlCount - 1 do begin337 if WinControl.Controls[I] is TControl then begin338 ScaleControl(WinControl.Controls[I], FromDPI);339 end;340 end;341 end;342 end;343 372 //if Control is TForm then 344 373 // Control.EnableAutoSizing; -
trunk/Packages/Common/StopWatch.pas
r6 r21 5 5 6 6 uses 7 {$IFDEF W indows}Windows,{$ENDIF}7 {$IFDEF WINDOWS}Windows,{$ENDIF} 8 8 SysUtils, DateUtils; 9 9 … … 13 13 TStopWatch = class 14 14 private 15 fFrequency: TLargeInteger;16 fIsRunning: Boolean;17 fIsHighResolution: Boolean;18 fStartCount, fStopCount: TLargeInteger;19 procedure SetTickStamp(var lInt : TLargeInteger);15 FFrequency: TLargeInteger; 16 FIsRunning: Boolean; 17 FIsHighResolution: Boolean; 18 FStartCount, fStopCount: TLargeInteger; 19 procedure SetTickStamp(var Value: TLargeInteger); 20 20 function GetElapsedTicks: TLargeInteger; 21 21 function GetElapsedMiliseconds: TLargeInteger; 22 22 function GetElapsed: string; 23 23 public 24 constructor Create(const startOnCreate: Boolean = False) ;24 constructor Create(const StartOnCreate: Boolean = False) ; 25 25 procedure Start; 26 26 procedure Stop; 27 property IsHighResolution : Boolean read fIsHighResolution;28 property ElapsedTicks 29 property ElapsedMiliseconds 30 property Elapsed 31 property IsRunning : Boolean read fIsRunning;27 property IsHighResolution: Boolean read FIsHighResolution; 28 property ElapsedTicks: TLargeInteger read GetElapsedTicks; 29 property ElapsedMiliseconds: TLargeInteger read GetElapsedMiliseconds; 30 property Elapsed: string read GetElapsed; 31 property IsRunning: Boolean read FIsRunning; 32 32 end; 33 33 34 34 35 implementation 35 36 36 constructor TStopWatch.Create(const startOnCreate : boolean = false);37 constructor TStopWatch.Create(const StartOnCreate: Boolean = False); 37 38 begin 38 inherited Create;39 FIsRunning := False; 39 40 40 fIsRunning := False; 41 42 {$IFDEF Windows} 41 {$IFDEF WINDOWS} 43 42 fIsHighResolution := QueryPerformanceFrequency(fFrequency) ; 44 43 {$ELSE} 45 fIsHighResolution := False;44 FIsHighResolution := False; 46 45 {$ENDIF} 47 if NOT fIsHighResolution then fFrequency := MSecsPerSec;46 if NOT FIsHighResolution then FFrequency := MSecsPerSec; 48 47 49 48 if StartOnCreate then Start; … … 52 51 function TStopWatch.GetElapsedTicks: TLargeInteger; 53 52 begin 54 Result := fStopCount - fStartCount;53 Result := FStopCount - FStartCount; 55 54 end; 56 55 57 procedure TStopWatch.SetTickStamp(var lInt : TLargeInteger);56 procedure TStopWatch.SetTickStamp(var Value: TLargeInteger); 58 57 begin 59 if fIsHighResolution then58 if FIsHighResolution then 60 59 {$IFDEF Windows} 61 QueryPerformanceCounter( lInt)60 QueryPerformanceCounter(Value) 62 61 {$ELSE} 63 62 {$ENDIF} 64 63 else 65 lInt := MilliSecondOf(Now);64 Value := MilliSecondOf(Now); 66 65 end; 67 66 68 67 function TStopWatch.GetElapsed: string; 69 68 var 70 dt: TDateTime;69 Elapsed: TDateTime; 71 70 begin 72 dt:= ElapsedMiliseconds / MSecsPerSec / SecsPerDay;73 result := Format('%d days, %s', [Trunc(dt), FormatDateTime('hh:nn:ss.z', Frac(dt))]) ;71 Elapsed := ElapsedMiliseconds / MSecsPerSec / SecsPerDay; 72 Result := Format('%d days, %s', [Trunc(Elapsed), FormatDateTime('hh:nn:ss.z', Frac(Elapsed))]) ; 74 73 end; 75 74 76 75 function TStopWatch.GetElapsedMiliseconds: TLargeInteger; 77 76 begin 78 Result := (MSecsPerSec * (fStopCount - fStartCount)) div fFrequency;77 Result := (MSecsPerSec * (fStopCount - FStartCount)) div FFrequency; 79 78 end; 80 79 81 80 procedure TStopWatch.Start; 82 81 begin 83 SetTickStamp( fStartCount);84 fIsRunning := True;82 SetTickStamp(FStartCount); 83 FIsRunning := True; 85 84 end; 86 85 87 86 procedure TStopWatch.Stop; 88 87 begin 89 SetTickStamp( fStopCount);90 fIsRunning := False;88 SetTickStamp(FStopCount); 89 FIsRunning := False; 91 90 end; 92 91 -
trunk/Packages/Common/SyncCounter.pas
r20 r21 1 unit USyncCounter; 2 3 {$mode delphi} 1 unit SyncCounter; 4 2 5 3 interface … … 25 23 procedure Assign(Source: TSyncCounter); 26 24 end; 25 27 26 28 27 implementation … … 69 68 begin 70 69 Lock.Free; 71 inherited Destroy;70 inherited; 72 71 end; 73 72 … … 79 78 80 79 end. 81 -
trunk/Packages/Common/Threading.pas
r20 r21 1 unit UThreading; 2 3 {$mode delphi} 1 unit Threading; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Forms, Contnrs, SyncObjs;6 Classes, SysUtils, Forms, Generics.Collections, SyncObjs; 9 7 10 8 type 11 9 TExceptionEvent = procedure (Sender: TObject; E: Exception) of object; 12 10 TMethodCall = procedure of object; 13 14 11 15 12 { TVirtualThread } … … 22 19 function GetSuspended: Boolean; virtual; abstract; 23 20 function GetTerminated: Boolean; virtual; abstract; 24 function GetThreadId: Integer; virtual; abstract;21 function GetThreadId: TThreadID; virtual; abstract; 25 22 procedure SetFreeOnTerminate(const AValue: Boolean); virtual; abstract; 26 23 procedure SetPriority(const AValue: TThreadPriority); virtual; abstract; … … 30 27 Name: string; 31 28 procedure Execute; virtual; abstract; 32 procedure Resume; virtual; abstract;33 procedure Suspend; virtual; abstract;34 29 procedure Start; virtual; abstract; 35 30 procedure Terminate; virtual; abstract; … … 44 39 property Terminated: Boolean read GetTerminated write SetTerminated; 45 40 property Finished: Boolean read GetFinished; 46 property ThreadId: Integerread GetThreadId;41 property ThreadId: TThreadID read GetThreadId; 47 42 end; 48 43 … … 70 65 function GetSuspended: Boolean; override; 71 66 function GetTerminated: Boolean; override; 72 function GetThreadId: Integer; override;67 function GetThreadId: TThreadID; override; 73 68 procedure SetFreeOnTerminate(const AValue: Boolean); override; 74 69 procedure SetPriority(const AValue: TThreadPriority); override; … … 81 76 procedure Sleep(Delay: Integer); override; 82 77 procedure Execute; override; 83 procedure Resume; override;84 procedure Suspend; override;85 78 procedure Start; override; 86 79 procedure Terminate; override; … … 106 99 { TThreadList } 107 100 108 TThreadList = class(TObjectList )109 function FindById(Id: Integer): TVirtualThread;101 TThreadList = class(TObjectList<TVirtualThread>) 102 function FindById(Id: TThreadID): TVirtualThread; 110 103 constructor Create; virtual; 111 104 end; … … 134 127 Thread.FreeOnTerminate := False; 135 128 Thread.Method := Method; 136 Thread. Resume;129 Thread.Start; 137 130 while (Thread.State = ttsRunning) or (Thread.State = ttsReady) do begin 138 131 if MainThreadID = ThreadID then Application.ProcessMessages; … … 155 148 Thread.Method := Method; 156 149 Thread.OnFinished := CallBack; 157 Thread. Resume;150 Thread.Start; 158 151 //if Thread.State = ttsExceptionOccured then 159 152 // raise Exception.Create(Thread.ExceptionMessage); … … 168 161 if MainThreadID = ThreadID then Method 169 162 else begin 170 Thread := ThreadList.FindById(ThreadID); 163 try 164 ThreadListLock.Acquire; 165 Thread := ThreadList.FindById(ThreadID); 166 finally 167 ThreadListLock.Release; 168 end; 171 169 if Assigned(Thread) then begin 172 170 Thread.Synchronize(Method); … … 177 175 { TThreadList } 178 176 179 function TThreadList.FindById(Id: Integer): TVirtualThread;177 function TThreadList.FindById(Id: TThreadID): TVirtualThread; 180 178 var 181 179 I: Integer; 182 180 begin 183 181 I := 0; 184 while (I < ThreadList.Count) and (T VirtualThread(ThreadList[I]).ThreadID <> Id) do182 while (I < ThreadList.Count) and (ThreadList[I].ThreadID <> Id) do 185 183 Inc(I); 186 if I < ThreadList.Count then Result := T VirtualThread(ThreadList[I])184 if I < ThreadList.Count then Result := ThreadList[I] 187 185 else Result := nil; 188 186 end; … … 190 188 constructor TThreadList.Create; 191 189 begin 192 inherited Create;190 inherited; 193 191 end; 194 192 … … 237 235 end; 238 236 239 function TListedThread.GetThreadId: Integer;237 function TListedThread.GetThreadId: TThreadID; 240 238 begin 241 239 Result := FThread.ThreadID; … … 293 291 ThreadListLock.Release; 294 292 end; 295 F Thread.Free;296 inherited Destroy;293 FreeAndNil(FThread); 294 inherited; 297 295 end; 298 296 … … 313 311 procedure TListedThread.Execute; 314 312 begin 315 end;316 317 procedure TListedThread.Resume;318 begin319 FThread.Resume;320 end;321 322 procedure TListedThread.Suspend;323 begin324 FThread.Suspend;325 313 end; 326 314 … … 374 362 finalization 375 363 376 ThreadList.Free;377 ThreadListLock.Free;364 FreeAndNil(ThreadList); 365 FreeAndNil(ThreadListLock); 378 366 379 367 end. 380 -
trunk/Packages/Common/URI.pas
r20 r21 1 unit U URI;1 unit URI; 2 2 3 3 // Date: 2011-04-04 4 5 {$mode delphi}6 4 7 5 interface … … 85 83 end; 86 84 85 87 86 implementation 88 87 89 88 function LeftCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 90 89 var 91 I , J: Integer;90 I: Integer; 92 91 Matched: Boolean; 93 92 begin … … 113 112 function RightCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 114 113 var 115 I , J: Integer;114 I: Integer; 116 115 Matched: Boolean; 117 116 begin … … 183 182 begin 184 183 Items.Free; 185 inherited Destroy;184 inherited; 186 185 end; 187 186 … … 202 201 203 202 procedure TURI.SetAsString(Value: string); 204 var205 HostAddr: string;206 HostPort: string;207 203 begin 208 204 LeftCutString(Value, Scheme, ':'); … … 235 231 begin 236 232 Path.Free; 237 inherited Destroy;233 inherited; 238 234 end; 239 235 … … 246 242 Fragment := TURI(Source).Fragment; 247 243 Query := TURI(Source).Query; 248 end else inherited Assign(Source);244 end else inherited; 249 245 end; 250 246 … … 294 290 destructor TURL.Destroy; 295 291 begin 296 inherited Destroy;292 inherited; 297 293 end; 298 294 … … 347 343 begin 348 344 Directory.Free; 349 inherited Destroy; 350 end; 351 345 inherited; 346 end; 352 347 353 348 end. 354 -
trunk/Packages/Common/XML.pas
r20 r21 1 unit UXMLUtils; 2 3 {$mode delphi} 1 unit XML; 4 2 5 3 interface … … 7 5 uses 8 6 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM;7 Classes, SysUtils, DateUtils, DOM, xmlread; 10 8 11 9 function XMLTimeToDateTime(XMLDateTime: string): TDateTime; 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;10 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 13 11 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 12 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); … … 16 14 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 17 15 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 16 procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double); 18 17 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 19 18 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; … … 21 20 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 22 21 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 22 function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double; 23 procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string); 23 24 24 25 25 26 implementation 27 28 function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double; 29 var 30 NewNode: TDOMNode; 31 begin 32 Result := DefaultValue; 33 NewNode := Node.FindNode(DOMString(Name)); 34 if Assigned(NewNode) then 35 Result := StrToFloat(string(NewNode.TextContent)); 36 end; 37 38 procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string); 39 var 40 Parser: TDOMParser; 41 Src: TXMLInputSource; 42 InFile: TFileStream; 43 begin 44 try 45 InFile := TFileStream.Create(FileName, fmOpenRead); 46 Src := TXMLInputSource.Create(InFile); 47 Parser := TDOMParser.Create; 48 Parser.Options.PreserveWhitespace := True; 49 Parser.Parse(Src, Doc); 50 finally 51 Src.Free; 52 Parser.Free; 53 InFile.Free; 54 end; 55 end; 26 56 27 57 function GetTimeZoneBias: Integer; … … 30 60 TimeZoneInfo: TTimeZoneInformation; 31 61 begin 62 {$push}{$warn 5057 off} 32 63 case GetTimeZoneInformation(TimeZoneInfo) of 33 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias;34 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias;64 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias; 65 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias; 35 66 else 36 67 Result := 0; 37 68 end; 69 {$pop} 38 70 end; 39 71 {$ELSE} … … 45 77 function LeftCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 46 78 var 47 I , J: Integer;79 I: Integer; 48 80 Matched: Boolean; 49 81 begin … … 99 131 if Pos('Z', XMLDateTime) > 0 then 100 132 LeftCutString(XMLDateTime, Part, 'Z'); 101 SecondFraction := StrToFloat('0' + De cimalSeparator + Part);133 SecondFraction := StrToFloat('0' + DefaultFormatSettings.DecimalSeparator + Part); 102 134 Millisecond := Trunc(SecondFraction * 1000); 103 135 end else begin … … 118 150 end; 119 151 120 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;152 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 121 153 const 122 154 Neg: array[Boolean] of string = ('+', '-'); … … 139 171 NewNode: TDOMNode; 140 172 begin 141 NewNode := Node.OwnerDocument.CreateElement( Name);142 NewNode.TextContent := IntToStr(Value);173 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 174 NewNode.TextContent := DOMString(IntToStr(Value)); 143 175 Node.AppendChild(NewNode); 144 176 end; … … 148 180 NewNode: TDOMNode; 149 181 begin 150 NewNode := Node.OwnerDocument.CreateElement( Name);151 NewNode.TextContent := IntToStr(Value);182 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 183 NewNode.TextContent := DOMString(IntToStr(Value)); 152 184 Node.AppendChild(NewNode); 153 185 end; … … 157 189 NewNode: TDOMNode; 158 190 begin 159 NewNode := Node.OwnerDocument.CreateElement( Name);160 NewNode.TextContent := BoolToStr(Value);191 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 192 NewNode.TextContent := DOMString(BoolToStr(Value)); 161 193 Node.AppendChild(NewNode); 162 194 end; … … 166 198 NewNode: TDOMNode; 167 199 begin 168 NewNode := Node.OwnerDocument.CreateElement( Name);169 NewNode.TextContent := Value;200 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 201 NewNode.TextContent := DOMString(Value); 170 202 Node.AppendChild(NewNode); 171 203 end; … … 175 207 NewNode: TDOMNode; 176 208 begin 177 NewNode := Node.OwnerDocument.CreateElement(Name); 178 NewNode.TextContent := DateTimeToXMLTime(Value); 209 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 210 NewNode.TextContent := DOMString(DateTimeToXMLTime(Value)); 211 Node.AppendChild(NewNode); 212 end; 213 214 procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double); 215 var 216 NewNode: TDOMNode; 217 begin 218 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 219 NewNode.TextContent := DOMString(FloatToStr(Value)); 179 220 Node.AppendChild(NewNode); 180 221 end; … … 185 226 begin 186 227 Result := DefaultValue; 187 NewNode := Node.FindNode( Name);188 if Assigned(NewNode) then 189 Result := StrToInt( NewNode.TextContent);228 NewNode := Node.FindNode(DOMString(Name)); 229 if Assigned(NewNode) then 230 Result := StrToInt(string(NewNode.TextContent)); 190 231 end; 191 232 … … 195 236 begin 196 237 Result := DefaultValue; 197 NewNode := Node.FindNode( Name);198 if Assigned(NewNode) then 199 Result := StrToInt64( NewNode.TextContent);238 NewNode := Node.FindNode(DOMString(Name)); 239 if Assigned(NewNode) then 240 Result := StrToInt64(string(NewNode.TextContent)); 200 241 end; 201 242 … … 205 246 begin 206 247 Result := DefaultValue; 207 NewNode := Node.FindNode( Name);208 if Assigned(NewNode) then 209 Result := StrToBool( NewNode.TextContent);248 NewNode := Node.FindNode(DOMString(Name)); 249 if Assigned(NewNode) then 250 Result := StrToBool(string(NewNode.TextContent)); 210 251 end; 211 252 … … 215 256 begin 216 257 Result := DefaultValue; 217 NewNode := Node.FindNode( Name);218 if Assigned(NewNode) then 219 Result := NewNode.TextContent;258 NewNode := Node.FindNode(DOMString(Name)); 259 if Assigned(NewNode) then 260 Result := string(NewNode.TextContent); 220 261 end; 221 262 … … 226 267 begin 227 268 Result := DefaultValue; 228 NewNode := Node.FindNode( Name);229 if Assigned(NewNode) then 230 Result := XMLTimeToDateTime( NewNode.TextContent);269 NewNode := Node.FindNode(DOMString(Name)); 270 if Assigned(NewNode) then 271 Result := XMLTimeToDateTime(string(NewNode.TextContent)); 231 272 end; 232 273 233 274 end. 234 -
trunk/UCore.pas
r20 r21 7 7 uses 8 8 Classes, SysUtils, XMLConf, LazFileUtils, ActnList, Controls, UVCS, UProject, 9 ULastOpenedList, Forms, Dialogs, Menus, Contnrs, UBackend;9 LastOpenedList, Forms, Dialogs, Menus, Contnrs, UBackend; 10 10 11 11 type -
trunk/Units/UProject.pas
r19 r21 6 6 7 7 uses 8 Classes, SysUtils, UVCS, UBackend, Contnrs, DOM, XMLRead, XMLWrite, UXMLUtils,8 Classes, SysUtils, UVCS, UBackend, Contnrs, DOM, XMLRead, XMLWrite, XML, 9 9 LazFileUtils; 10 10 -
trunk/VCSCommander.lpi
r20 r21 46 46 <Debugging> 47 47 <GenerateDebugInfo Value="False"/> 48 <DebugInfoType Value="dsDwarf3"/> 48 49 </Debugging> 49 50 <LinkSmart Value="True"/> … … 71 72 </Modes> 72 73 </RunParams> 73 <RequiredPackages Count=" 4">74 <RequiredPackages Count="3"> 74 75 <Item1> 75 <PackageName Value="TemplateGenerics"/> 76 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 76 <PackageName Value="FCL"/> 77 77 </Item1> 78 78 <Item2> 79 <PackageName Value="FCL"/> 79 <PackageName Value="Common"/> 80 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 80 81 </Item2> 81 82 <Item3> 82 <PackageName Value="Common"/> 83 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 83 <PackageName Value="LCL"/> 84 84 </Item3> 85 <Item4>86 <PackageName Value="LCL"/>87 </Item4>88 85 </RequiredPackages> 89 86 <Units Count="19"> -
trunk/VCSCommander.lpr
r20 r21 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UCore, Common, TemplateGenerics,UFormBrowse, UVCS,10 Forms, UFormMain, UCore, Common, UFormBrowse, UVCS, 11 11 UFormFavorites, UFormSettings, UFormConsole, USubversion, UProject, SysUtils, 12 12 UFormCommit, UFormCheckout, UBazaar, UBackend, UFormLog, UFormTest,
Note:
See TracChangeset
for help on using the changeset viewer.