Changeset 59 for trunk/Packages
- Timestamp:
- Dec 3, 2014, 9:09:42 PM (10 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 5 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.lpk
r54 r59 1 <?xml version="1.0" ?>1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <CONFIG> 3 3 <Package Version="4"> … … 12 12 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 13 13 </SearchPaths> 14 <Other>15 <CompilerMessages>16 <UseMsgFile Value="True"/>17 </CompilerMessages>18 <CompilerPath Value="$(CompPath)"/>19 </Other>20 14 </CompilerOptions> 21 15 <Description Value="Various libraries"/> 22 16 <License Value="GNU/GPL"/> 23 17 <Version Minor="7"/> 24 <Files Count=" 15">18 <Files Count="20"> 25 19 <Item1> 26 20 <Filename Value="StopWatch.pas"/> … … 87 81 <UnitName Value="UApplicationInfo"/> 88 82 </Item15> 83 <Item16> 84 <Filename Value="USyncCounter.pas"/> 85 <UnitName Value="USyncCounter"/> 86 </Item16> 87 <Item17> 88 <Filename Value="UListViewSort.pas"/> 89 <HasRegisterProc Value="True"/> 90 <UnitName Value="UListViewSort"/> 91 </Item17> 92 <Item18> 93 <Filename Value="UPersistentForm.pas"/> 94 <HasRegisterProc Value="True"/> 95 <UnitName Value="UPersistentForm"/> 96 </Item18> 97 <Item19> 98 <Filename Value="UFindFile.pas"/> 99 <HasRegisterProc Value="True"/> 100 <UnitName Value="UFindFile"/> 101 </Item19> 102 <Item20> 103 <Filename Value="UScaleDPI.pas"/> 104 <UnitName Value="UScaleDPI"/> 105 </Item20> 89 106 </Files> 90 107 <i18n> -
trunk/Packages/Common/Common.pas
r54 r59 10 10 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 11 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 UJobProgressView, UXMLUtils, UApplicationInfo, LazarusPackageIntf; 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, UScaleDPI, LazarusPackageIntf; 13 14 14 15 implementation … … 20 21 RegisterUnit('UJobProgressView', @UJobProgressView.Register); 21 22 RegisterUnit('UApplicationInfo', @UApplicationInfo.Register); 23 RegisterUnit('UListViewSort', @UListViewSort.Register); 24 RegisterUnit('UPersistentForm', @UPersistentForm.Register); 25 RegisterUnit('UFindFile', @UFindFile.Register); 22 26 end; 23 27 -
trunk/Packages/Common/UApplicationInfo.pas
r54 r59 55 55 procedure Register; 56 56 begin 57 RegisterComponents(' Samples', [TApplicationInfo]);57 RegisterComponents('Common', [TApplicationInfo]); 58 58 end; 59 59 -
trunk/Packages/Common/UCommon.pas
r55 r59 48 48 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 49 49 function SplitString(var Text: string; Count: Word): string; 50 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 50 51 function GetBit(Variable: QWord; Index: Byte): Boolean; 52 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload; 51 53 procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload; 52 54 procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload; … … 336 338 end; 337 339 340 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 341 var 342 I: Integer; 343 begin 344 Result := 0; 345 for I := 0 to MaxIndex - 1 do 346 if ((Variable shr I) and 1) = 1 then Inc(Result); 347 end; 348 338 349 function GetBit(Variable:QWord;Index:Byte):Boolean; 339 350 begin … … 341 352 end; 342 353 354 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); 355 begin 356 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index); 357 end; 358 343 359 procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload; 344 360 begin 345 Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);361 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index); 346 362 end; 347 363 348 364 procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload; 349 365 begin 350 Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);366 Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index); 351 367 end; 352 368 353 369 procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload; 354 370 begin 355 Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);371 Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index); 356 372 end; 357 373 -
trunk/Packages/Common/UDebugLog.pas
r54 r59 31 31 Items: TListObject; 32 32 Lock: TCriticalSection; 33 procedure Add( Group: string; Text: string);33 procedure Add(Text: string; Group: string = ''); 34 34 procedure WriteToFile(Text: string); 35 35 constructor Create(AOwner: TComponent); override; … … 52 52 procedure Register; 53 53 begin 54 RegisterComponents(' Samples', [TDebugLog]);54 RegisterComponents('Common', [TDebugLog]); 55 55 end; 56 56 … … 69 69 end; 70 70 71 procedure TDebugLog.Add( Group: string; Text: string);71 procedure TDebugLog.Add(Text: string; Group: string = ''); 72 72 var 73 73 NewItem: TDebugLogItem; -
trunk/Packages/Common/UFindFile.pas
r54 r59 64 64 procedure Register; 65 65 begin 66 RegisterComponents(' Samples', [TFindFile]);66 RegisterComponents('Common', [TFindFile]); 67 67 end; 68 68 -
trunk/Packages/Common/UJobProgressView.lfm
r54 r59 28 28 object LabelOperation: TLabel 29 29 Left = 8 30 Height = 1 430 Height = 13 31 31 Top = 8 32 Width = 6 732 Width = 66 33 33 Caption = 'Operations:' 34 34 Font.Height = -11 … … 80 80 object LabelEstimatedTimePart: TLabel 81 81 Left = 8 82 Height = 1 482 Height = 13 83 83 Top = -2 84 Width = 7 284 Width = 71 85 85 Caption = 'Estimated time:' 86 86 ParentColor = False … … 132 132 object LabelEstimatedTimeTotal: TLabel 133 133 Left = 8 134 Height = 1 4134 Height = 13 135 135 Top = 0 136 Width = 9 8136 Width = 97 137 137 Caption = 'Total estimated time:' 138 138 ParentColor = False -
trunk/Packages/Common/UJobProgressView.pas
r54 r59 111 111 Finished: Boolean; 112 112 FOnJobFinish: TJobProgressViewMethod; 113 FOnOwnerDraw: TNotifyEvent; 114 FOwnerDraw: Boolean; 113 115 FShowDelay: Integer; 114 116 FTerminate: Boolean; … … 116 118 TotalStartTime: TDateTime; 117 119 Log: TStringList; 118 Form: TFormJobProgressView;119 120 procedure SetTerminate(const AValue: Boolean); 120 121 procedure UpdateProgress; … … 122 123 procedure StartJobs; 123 124 procedure UpdateHeight; 125 procedure JobProgressChange(Sender: TObject); 124 126 public 127 Form: TFormJobProgressView; 125 128 Jobs: TObjectList; // TListObject<TJob> 126 129 CurrentJob: TJob; … … 136 139 property Terminate: Boolean read FTerminate write SetTerminate; 137 140 published 141 property OwnerDraw: Boolean read FOwnerDraw write FOwnerDraw; 138 142 property ShowDelay: Integer read FShowDelay write FShowDelay; 139 143 property AutoClose: Boolean read FAutoClose write FAutoClose; 140 144 property OnJobFinish: TJobProgressViewMethod read FOnJobFinish 141 145 write FOnJobFinish; 146 property OnOwnerDraw: TNotifyEvent read FOnOwnerDraw 147 write FOnOwnerDraw; 142 148 end; 143 149 … … 163 169 procedure Register; 164 170 begin 165 RegisterComponents(' Samples', [TJobProgressView]);171 RegisterComponents('Common', [TJobProgressView]); 166 172 end; 167 173 … … 196 202 NewJob.Progress.Max := 100; 197 203 NewJob.Progress.Reset; 204 NewJob.Progress.OnChange := JobProgressChange; 198 205 Jobs.Add(NewJob); 199 206 //ReloadJobList; … … 212 219 Terminate := False; 213 220 214 Form.BringToFront;221 if not OwnerDraw then Form.BringToFront; 215 222 216 223 Finished := False; … … 244 251 CurrentJobIndex := I; 245 252 CurrentJob := TJob(Jobs[I]); 253 JobProgressChange(Self); 246 254 StartTime := Now; 247 255 Form.LabelEstimatedTimePart.Caption := Format(SEstimatedTime, ['']); … … 339 347 end; 340 348 349 procedure TJobProgressView.JobProgressChange(Sender: TObject); 350 begin 351 if Assigned(FOnOwnerDraw) then 352 FOnOwnerDraw(Self); 353 end; 354 341 355 procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject); 342 356 var … … 357 371 if not Visible then begin 358 372 TimerUpdate.Interval := UpdateInterval; 359 Show;373 if not JobProgressView.OwnerDraw then Show; 360 374 end; 361 375 end; … … 509 523 destructor TJobProgressView.Destroy; 510 524 begin 511 Log.Free;512 Jobs.Free;513 inherited Destroy;525 FreeAndNil(Log); 526 FreeAndNil(Jobs); 527 inherited; 514 528 end; 515 529 … … 519 533 FLock.Acquire; 520 534 FMax := AValue; 535 if FMax < 1 then FMax := 1; 521 536 if FValue >= FMax then FValue := FMax; 522 537 finally … … 610 625 begin 611 626 Progress.Free; 612 inherited Destroy;627 inherited; 613 628 end; 614 629 -
trunk/Packages/Common/ULastOpenedList.pas
r55 r59 6 6 7 7 uses 8 Classes, SysUtils, Registry, URegistry, Menus ;8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf; 9 9 10 10 type … … 18 18 procedure SetMaxCount(AValue: Integer); 19 19 procedure LimitMaxCount; 20 procedure ItemsChange(Sender: TObject); 21 procedure DoChange; 20 22 public 21 23 Items: TStringList; … … 25 27 procedure LoadFromRegistry(Context: TRegistryContext); 26 28 procedure SaveToRegistry(Context: TRegistryContext); 29 procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string); 30 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 27 31 procedure AddItem(FileName: string); 28 32 published … … 38 42 procedure Register; 39 43 begin 40 RegisterComponents(' Samples', [TLastOpenedList]);44 RegisterComponents('Common', [TLastOpenedList]); 41 45 end; 42 46 … … 58 62 end; 59 63 64 procedure TLastOpenedList.ItemsChange(Sender: TObject); 65 begin 66 DoChange; 67 end; 68 69 procedure TLastOpenedList.DoChange; 70 begin 71 if Assigned(FOnChange) then 72 FOnChange(Self); 73 end; 74 60 75 constructor TLastOpenedList.Create(AOwner: TComponent); 61 76 begin 62 77 inherited; 63 78 Items := TStringList.Create; 79 Items.OnChange := ItemsChange; 64 80 MaxCount := 10; 65 81 end; … … 129 145 end; 130 146 147 procedure TLastOpenedList.LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string 148 ); 149 var 150 I: Integer; 151 Value: string; 152 Count: Integer; 153 begin 154 with XMLConfig do begin 155 Count := GetValue(Path + '/Count', 0); 156 if Count > MaxCount then Count := MaxCount; 157 Items.Clear; 158 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), ''); 160 if Trim(Value) <> '' then Items.Add(Value); 161 end; 162 if Assigned(FOnChange) then 163 FOnChange(Self); 164 end; 165 end; 166 167 procedure TLastOpenedList.SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 168 var 169 I: Integer; 170 begin 171 with XMLConfig do begin 172 SetValue(Path + '/Count', Items.Count); 173 for I := 0 to Items.Count - 1 do 174 SetValue(Path + '/File' + IntToStr(I), Items[I]); 175 Flush; 176 end; 177 end; 178 131 179 procedure TLastOpenedList.AddItem(FileName:string); 132 180 begin … … 134 182 Items.Insert(0, FileName); 135 183 LimitMaxCount; 136 if Assigned(FOnChange) then 137 FOnChange(Self); 184 DoChange; 138 185 end; 139 186 -
trunk/Packages/Common/UMemory.pas
r55 r59 24 24 constructor Create; 25 25 destructor Destroy; override; 26 procedure WriteMemory(Position: Integer; Memory: TMemory);27 procedure ReadMemory(Position: Integer; Memory: TMemory);28 26 property Data: PByte read FData; 29 27 property Size: Integer read FSize write SetSize; … … 110 108 end; 111 109 112 procedure TMemory.WriteMemory(Position: Integer; Memory: TMemory);113 begin114 Move(Memory.FData, PByte(@FData + Position)^, Memory.Size);115 end;116 117 procedure TMemory.ReadMemory(Position: Integer; Memory: TMemory);118 begin119 Move(PByte(@FData + Position)^, Memory.FData, Memory.Size);120 end;121 122 110 end. 123 111 -
trunk/Packages/Common/URegistry.pas
r55 r59 17 17 rrKeyDynData = HKEY($80000006)); 18 18 19 { TRegistryContext } 20 19 21 TRegistryContext = record 20 22 RootKey: HKEY; 21 23 Key: string; 24 class operator Equal(A, B: TRegistryContext): Boolean; 22 25 end; 23 26 … … 26 29 TRegistryEx = class(TRegistry) 27 30 private 31 function GetCurrentContext: TRegistryContext; 32 procedure SetCurrentContext(AValue: TRegistryContext); 28 33 public 29 34 function ReadBoolWithDefault(const Name: string; … … 35 40 function DeleteKeyRecursive(const Key: string): Boolean; 36 41 function OpenKey(const Key: string; CanCreate: Boolean): Boolean; 42 property CurrentContext: TRegistryContext read GetCurrentContext write SetCurrentContext; 37 43 end; 38 44 … … 46 52 Result.RootKey := RootKey; 47 53 Result.Key := Key; 54 end; 55 56 { TRegistryContext } 57 58 class operator TRegistryContext.Equal(A, B: TRegistryContext): Boolean; 59 begin 60 Result := (A.Key = B.Key) and (A.RootKey = B.RootKey); 48 61 end; 49 62 … … 106 119 end; 107 120 121 function TRegistryEx.GetCurrentContext: TRegistryContext; 122 begin 123 Result.Key := CurrentPath; 124 Result.RootKey := RootKey; 125 end; 126 127 procedure TRegistryEx.SetCurrentContext(AValue: TRegistryContext); 128 begin 129 RootKey := AValue.RootKey; 130 OpenKey(AValue.Key, True); 131 end; 132 108 133 function TRegistryEx.ReadBoolWithDefault(const Name: string; 109 134 DefaultValue: Boolean): Boolean; -
trunk/Packages/Common/UResetableThread.pas
r54 r59 104 104 105 105 procedure TResetableThread.WaitForStart; 106 var107 WaitResult: TWaitResult;106 //var 107 // WaitResult: TWaitResult; 108 108 begin 109 109 //try … … 127 127 128 128 procedure TResetableThread.WaitForStop; 129 var130 WaitState: TWaitResult;129 //var 130 // WaitState: TWaitResult; 131 131 begin 132 132 try -
trunk/Packages/Common/UURI.pas
r54 r59 326 326 Drive := Drive + DriveSeparator; 327 327 end else Drive := ''; 328 Directory.AsString := AValue; 328 if (Drive <> '') and (AValue = '') then 329 Directory.AsString := Directory.DirSeparator 330 else Directory.AsString := AValue; 329 331 end; 330 332
Note:
See TracChangeset
for help on using the changeset viewer.