mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 14:59:08 +02:00
MG: client rect bugs nearly completed
git-svn-id: trunk@1674 -
This commit is contained in:
parent
5c631902b8
commit
872140dc14
@ -110,9 +110,11 @@ type
|
|||||||
function IndexOfKey(Key: Pointer): integer;
|
function IndexOfKey(Key: Pointer): integer;
|
||||||
function FindHashItem(Item: Pointer): PDynHashArrayItem;
|
function FindHashItem(Item: Pointer): PDynHashArrayItem;
|
||||||
function FindHashItemWithKey(Key: Pointer): PDynHashArrayItem;
|
function FindHashItemWithKey(Key: Pointer): PDynHashArrayItem;
|
||||||
property FirstHashItem: PDynHashArrayItem read FFirstItem;
|
|
||||||
function GetHashItem(HashIndex: integer): PDynHashArrayItem;
|
function GetHashItem(HashIndex: integer): PDynHashArrayItem;
|
||||||
procedure Delete(ADynHashArrayItem: PDynHashArrayItem);
|
procedure Delete(ADynHashArrayItem: PDynHashArrayItem);
|
||||||
|
procedure AssignTo(List: TList);
|
||||||
|
|
||||||
|
property FirstHashItem: PDynHashArrayItem read FFirstItem;
|
||||||
property MinCapacity: integer read FMinCapacity write FMinCapacity;
|
property MinCapacity: integer read FMinCapacity write FMinCapacity;
|
||||||
property MaxCapacity: integer read FMaxCapacity write FMaxCapacity;
|
property MaxCapacity: integer read FMaxCapacity write FMaxCapacity;
|
||||||
property Capacity: integer read FCapacity;
|
property Capacity: integer read FCapacity;
|
||||||
@ -382,47 +384,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDynHashArray.Remove(Item: Pointer);
|
procedure TDynHashArray.Remove(Item: Pointer);
|
||||||
var Index: integer;
|
|
||||||
OldNext, Old: PDynHashArrayItem;
|
|
||||||
begin
|
begin
|
||||||
if (Item=nil) or (FItems=nil) then exit;
|
Delete(FindHashItem(Item));
|
||||||
Index:=IndexOf(Item);
|
|
||||||
if (Index<0) then exit;
|
|
||||||
Old:=FItems[Index];
|
|
||||||
if Old=nil then exit;
|
|
||||||
if Old^.Item=Item then begin
|
|
||||||
OldNext:=Old^.Next;
|
|
||||||
if (OldNext=nil) or (OldNext^.IsOverflow) then
|
|
||||||
FItems[Index]:=OldNext
|
|
||||||
else
|
|
||||||
FItems[Index]:=nil;
|
|
||||||
end else begin
|
|
||||||
repeat
|
|
||||||
Old:=Old^.Next;
|
|
||||||
if Old=nil then exit;
|
|
||||||
if Old^.IsOverflow=false then exit;
|
|
||||||
until (Old^.Item=Item);
|
|
||||||
end;
|
|
||||||
Delete(Old);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDynHashArray.Delete(ADynHashArrayItem: PDynHashArrayItem);
|
procedure TDynHashArray.Delete(ADynHashArrayItem: PDynHashArrayItem);
|
||||||
|
var Index: integer;
|
||||||
|
OldNext: PDynHashArrayItem;
|
||||||
begin
|
begin
|
||||||
if ADynHashArrayItem=nil then exit;
|
if ADynHashArrayItem=nil then exit;
|
||||||
|
// delete from cache
|
||||||
if (FHashCacheIndex>=0)
|
if (FHashCacheIndex>=0)
|
||||||
and ((ADynHashArrayItem^.Item=FHashCacheItem)
|
and ((ADynHashArrayItem^.Item=FHashCacheItem)
|
||||||
or (Assigned(OnGetKeyForHashItem)
|
or (Assigned(OnGetKeyForHashItem)
|
||||||
and (OnGetKeyForHashItem(ADynHashArrayItem^.Item)=FHashCacheItem)))
|
and (OnGetKeyForHashItem(ADynHashArrayItem^.Item)=FHashCacheItem)))
|
||||||
then
|
then
|
||||||
// if the user removes an item, changes the key and readds it, the hash
|
// if the user removes an item, changes the key and readds it, the hash
|
||||||
// can change for it, so the cache must be cleared
|
// of the item can change
|
||||||
|
// => the cache must be cleared
|
||||||
ClearCache;
|
ClearCache;
|
||||||
if (ADynHashArrayItem^.IsOverflow=false) and (ADynHashArrayItem^.Next<>nil)
|
// delete from FItems
|
||||||
then
|
if not ADynHashArrayItem^.IsOverflow then begin
|
||||||
ADynHashArrayItem^.Next^.IsOverflow:=false;
|
// Item is first item with hash
|
||||||
|
Index:=IndexOf(ADynHashArrayItem^.Item);
|
||||||
|
OldNext:=ADynHashArrayItem^.Next;
|
||||||
|
if (OldNext=nil) or (not (OldNext^.IsOverflow)) then
|
||||||
|
FItems[Index]:=nil
|
||||||
|
else begin
|
||||||
|
FItems[Index]:=OldNext;
|
||||||
|
OldNext^.IsOverflow:=false;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// adjust FFirstItem
|
||||||
if FFirstItem=ADynHashArrayItem then
|
if FFirstItem=ADynHashArrayItem then
|
||||||
FFirstItem:=FFirstItem^.Next;
|
FFirstItem:=FFirstItem^.Next;
|
||||||
|
// free storage item
|
||||||
DisposeHashItem(ADynHashArrayItem);
|
DisposeHashItem(ADynHashArrayItem);
|
||||||
|
// adjust count and capacity
|
||||||
dec(FCount);
|
dec(FCount);
|
||||||
if FCount<FLowWaterMark then begin
|
if FCount<FLowWaterMark then begin
|
||||||
// resize
|
// resize
|
||||||
@ -430,6 +428,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDynHashArray.AssignTo(List: TList);
|
||||||
|
var i: integer;
|
||||||
|
HashItem: PDynHashArrayItem;
|
||||||
|
begin
|
||||||
|
List.Count:=Count;
|
||||||
|
HashItem:=FirstHashItem;
|
||||||
|
i:=0;
|
||||||
|
while HashItem<>nil do begin
|
||||||
|
List[i]:=HashItem^.Item;
|
||||||
|
inc(i);
|
||||||
|
HashItem:=HashItem^.Next;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDynHashArray.First: Pointer;
|
function TDynHashArray.First: Pointer;
|
||||||
begin
|
begin
|
||||||
if FFirstItem<>nil then
|
if FFirstItem<>nil then
|
||||||
|
@ -478,7 +478,7 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{$I form.inc}
|
{$I form.inc}
|
||||||
{$I Customform.inc}
|
{$I customform.inc}
|
||||||
{$I screen.inc}
|
{$I screen.inc}
|
||||||
{$I application.inc}
|
{$I application.inc}
|
||||||
{$I hintwindow.inc}
|
{$I hintwindow.inc}
|
||||||
|
@ -304,6 +304,13 @@ begin
|
|||||||
Result := InterfaceObject.GetWindowRect(Handle, Rect);
|
Result := InterfaceObject.GetWindowRect(Handle, Rect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF ClientRectBugFix}
|
||||||
|
Function GetWindowSize(Handle : hwnd; var Width, Height: integer): boolean;
|
||||||
|
begin
|
||||||
|
Result := InterfaceObject.GetWindowSize(Handle, Width, Height);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
Function GetWindowOrgEx(dc : hdc; var P : TPoint): Integer;
|
Function GetWindowOrgEx(dc : hdc; var P : TPoint): Integer;
|
||||||
begin
|
begin
|
||||||
Result := InterfaceObject.GetWindowOrgEx(dc,P);
|
Result := InterfaceObject.GetWindowOrgEx(dc,P);
|
||||||
@ -1085,6 +1092,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.29 2002/05/12 04:56:20 lazarus
|
||||||
|
MG: client rect bugs nearly completed
|
||||||
|
|
||||||
Revision 1.28 2002/05/10 06:05:56 lazarus
|
Revision 1.28 2002/05/10 06:05:56 lazarus
|
||||||
MG: changed license to LGPL
|
MG: changed license to LGPL
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user