MG: added scrollbars for TListView

git-svn-id: trunk@1708 -
This commit is contained in:
lazarus 2002-05-28 14:58:30 +00:00
parent 784fb02b29
commit ee79b89293
2 changed files with 83 additions and 19 deletions

View File

@ -272,6 +272,8 @@ type
FSelected: TListItem; // temp copy of the selected item FSelected: TListItem; // temp copy of the selected item
FLastHorzScrollInfo: TScrollInfo; FLastHorzScrollInfo: TScrollInfo;
FLastVertScrollInfo: TScrollInfo; FLastVertScrollInfo: TScrollInfo;
FUpdateCount: integer;
FUpdateNeeded: boolean;
FOnChange: TLVChangeEvent; FOnChange: TLVChangeEvent;
FOnColumnClick: TLVColumnClickEvent; FOnColumnClick: TLVColumnClickEvent;
FOnSelectItem: TLVSelectItemEvent; FOnSelectItem: TLVSelectItemEvent;
@ -290,6 +292,7 @@ type
procedure SetViewStyle (const Avalue: TViewStyle); procedure SetViewStyle (const Avalue: TViewStyle);
procedure UpdateScrollbars; procedure UpdateScrollbars;
procedure CNNotify(var AMessage: TLMNotify); message CN_NOTIFY; procedure CNNotify(var AMessage: TLMNotify); message CN_NOTIFY;
procedure DoUpdate;
protected protected
ParentWindow : TScrolledWindow; ParentWindow : TScrolledWindow;
procedure Change(AItem: TListItem; AChange: Integer); dynamic; procedure Change(AItem: TListItem; AChange: Integer); dynamic;
@ -328,6 +331,8 @@ type
public public
constructor Create(Aowner: TComponent); override; constructor Create(Aowner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure BeginUpdate;
procedure EndUpdate;
property Selected: TListItem read GetSelection write SetSelection; property Selected: TListItem read GetSelection write SetSelection;
end; end;
@ -354,7 +359,7 @@ type
property SortColumn; property SortColumn;
property Visible; property Visible;
property ViewStyle; property ViewStyle;
property OnMOuseMOve; property OnMouseMove;
property OnChange; property OnChange;
property OnClick; property OnClick;
property OnColumnClick; property OnColumnClick;
@ -1559,6 +1564,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.36 2002/05/28 14:58:29 lazarus
MG: added scrollbars for TListView
Revision 1.35 2002/05/20 14:19:03 lazarus Revision 1.35 2002/05/20 14:19:03 lazarus
MG: activated the clientrect bugfixes MG: activated the clientrect bugfixes

View File

@ -40,12 +40,8 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TCustomListView.ColumnsChanged; Procedure TCustomListView.ColumnsChanged;
Begin Begin
if csDestroying in Componentstate Then Exit; FUpdateNeeded:=true;
//TODO: Optimize implementation by invoking individual upadates instead of DoUpdate;
// recreating window
//notify the interface....
RecreateWnd;
CNSendMessage(LM_SETPROPERTIES,self,nil);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -135,6 +131,22 @@ begin
end; end;
end; end;
{------------------------------------------------------------------------------
TCustomListView DoUpdate
------------------------------------------------------------------------------}
procedure TCustomListView.DoUpdate;
begin
if FUpdateCount>0 then exit;
if not FUpdateNeeded then exit;
FUpdateNeeded:=false;
if csDestroying in Componentstate Then Exit;
//TODO: Optimize implementation by invoking individual upadates instead of
// recreating window
//notify the interface....
RecreateWnd;
CNSendMessage(LM_SETPROPERTIES,self,nil);
end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView DoSelectItem } { TCustomListView DoSelectItem }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -149,6 +161,9 @@ end;
Procedure TCustomListView.ItemChanged(Index : Integer); //called by TListItems Procedure TCustomListView.ItemChanged(Index : Integer); //called by TListItems
Begin Begin
if csDestroying in Componentstate Then Exit; if csDestroying in Componentstate Then Exit;
if FUpdateCount>0 then
FUpdateNeeded:=true
else
//notify the interface.... //notify the interface....
CNSendMessage(LM_LV_CHANGEITEM,self,@Index); CNSendMessage(LM_LV_CHANGEITEM,self,@Index);
End; End;
@ -158,6 +173,10 @@ End;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TCustomListView.ItemDeleted(Index : Integer); //called by TListItems Procedure TCustomListView.ItemDeleted(Index : Integer); //called by TListItems
Begin Begin
if csDestroying in Componentstate Then Exit;
if FUpdateCount>0 then
FUpdateNeeded:=true
else
//notify the interface.... //notify the interface....
CNSendMessage(LM_LV_DELETEITEM,self,@Index); CNSendMessage(LM_LV_DELETEITEM,self,@Index);
End; End;
@ -167,6 +186,10 @@ End;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TCustomListView.ItemAdded; Procedure TCustomListView.ItemAdded;
Begin Begin
if csDestroying in Componentstate Then Exit;
if FUpdateCount>0 then
FUpdateNeeded:=true
else
//notify the interface.... //notify the interface....
CNSendMessage(LM_LV_ADDITEM,self,nil); CNSendMessage(LM_LV_ADDITEM,self,nil);
End; End;
@ -242,6 +265,30 @@ begin
inherited Destroy; inherited Destroy;
end; end;
{------------------------------------------------------------------------------
TCustomListView BeginUpdate
Params: None
Result: none
Increases the update count. Use this procedure before any big change, so that
the interface will not show any single step.
------------------------------------------------------------------------------}
procedure TCustomListView.BeginUpdate;
begin
inc(FUpdateCount);
end;
{------------------------------------------------------------------------------}
{ TCustomListView GetSelection }
{------------------------------------------------------------------------------}
procedure TCustomListView.EndUpdate;
begin
if FUpdateCount=0 then exit;
dec(FUpdateCount);
if FUpdateCount>0 then exit;
DoUpdate;
end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView GetSelection } { TCustomListView GetSelection }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -287,6 +334,10 @@ end;
Procedure TCustomListView.ImageChanged(Sender : TObject); Procedure TCustomListView.ImageChanged(Sender : TObject);
begin begin
if csDestroying in Componentstate Then Exit;
if FUpdateCount>0 then
FUpdateNeeded:=true
else
//image changed so redraw it all.... //image changed so redraw it all....
CNSendMessage(LM_SETPROPERTIES,self,nil); CNSendMessage(LM_SETPROPERTIES,self,nil);
end; end;
@ -328,6 +379,9 @@ procedure TCustomListView.UpdateScrollbars;
var var
ScrollInfo: TScrollInfo; ScrollInfo: TScrollInfo;
begin begin
writeln('TODO: TCustomListView.UpdateScrollbars');
exit;
if not HandleAllocated then exit if not HandleAllocated then exit
else else
begin begin
@ -417,7 +471,7 @@ end;
Function TCustomListView.GetMaxScrolledLeft : Integer; Function TCustomListView.GetMaxScrolledLeft : Integer;
begin begin
result := 0; Result := 0;
end; end;
Function TCustomListView.GetMaxScrolledTop : Integer; Function TCustomListView.GetMaxScrolledTop : Integer;
@ -432,7 +486,6 @@ begin
FDefItemHeight:=AValue; FDefItemHeight:=AValue;
// Include(FStates,tvsTopsNeedsUpdate); // Include(FStates,tvsTopsNeedsUpdate);
Invalidate; Invalidate;
end; end;
// included by comctrls.pp // included by comctrls.pp
@ -440,6 +493,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.19 2002/05/28 14:58:30 lazarus
MG: added scrollbars for TListView
Revision 1.18 2002/05/10 06:05:52 lazarus Revision 1.18 2002/05/10 06:05:52 lazarus
MG: changed license to LGPL MG: changed license to LGPL