mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 08:30:58 +02:00
MWE: Fixed more compatebility issues (Sort, SelectedItem)
git-svn-id: trunk@1535 -
This commit is contained in:
parent
6a99eabc13
commit
5e3396a8bf
117
lcl/comctrls.pp
117
lcl/comctrls.pp
@ -1,3 +1,4 @@
|
||||
{ $Id$}
|
||||
{
|
||||
/***************************************************************************
|
||||
ComCtrls.pp
|
||||
@ -383,16 +384,21 @@ type
|
||||
|
||||
TListItems = class; //forward declaration!
|
||||
TCustomListView = class; //forward declaration!
|
||||
TSortType = (stNone, stData, stText, stBoth);
|
||||
|
||||
TListItem = class(TPersistent)
|
||||
private
|
||||
FOwner : TListItems;
|
||||
FOwner: TListItems;
|
||||
FSubItems: TStrings;
|
||||
//FIndex : Integer;
|
||||
FCaption : String;
|
||||
FCaption: String;
|
||||
FData: Pointer;
|
||||
FImageIndex: Integer;
|
||||
FDestroying: Boolean;
|
||||
|
||||
procedure SetData(const AValue: Pointer);
|
||||
procedure SetImageIndex(const AValue: Integer);
|
||||
Procedure SetCaption(const Value : String);
|
||||
procedure SetCaption(const AValue : String);
|
||||
// Procedure SetSubItems(Value : TStrings);
|
||||
Function GetIndex : Integer;
|
||||
protected
|
||||
@ -403,6 +409,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Delete;
|
||||
property Caption : String read FCaption write SetCaption;
|
||||
property Data: Pointer read FData write SetData;
|
||||
property Index : Integer read GetIndex;
|
||||
property Owner : TListItems read FOwner;
|
||||
property SubItems : TStrings read FSubItems write FSubItems;//SetSubItems;
|
||||
@ -415,80 +422,21 @@ type
|
||||
FItems : TList;
|
||||
Function GetCount : Integer;
|
||||
protected
|
||||
Function GetItem(Index : Integer): TListItem;
|
||||
procedure SetITem(Index : Integer; Value : TListItem);
|
||||
Procedure ItemChanged(sender : TObject); //called by TListItem in response to SubItems changing
|
||||
function GetItem(const AIndex: Integer): TListItem;
|
||||
procedure SetITem(const AIndex: Integer; const AValue: TListItem);
|
||||
procedure ItemChanged(sender : TObject); //called by TListItem in response to SubItems changing
|
||||
public
|
||||
function Add: TListItem;
|
||||
constructor Create(AOwner : TCustomListView);
|
||||
destructor Destroy; override;
|
||||
function Add:TListItem;
|
||||
Procedure Delete(Index : Integer);
|
||||
function Insert(Index : Integer) : TListItem;
|
||||
property Count : Integer read GetCount;
|
||||
property Item[Index : Integer]: TListItem read GetItem write SetItem; default;
|
||||
procedure Delete(const AIndex : Integer);
|
||||
function FindData(const AData: Pointer): TListItem;
|
||||
function Insert(const AIndex: Integer) : TListItem;
|
||||
property Count: Integer read GetCount;
|
||||
property Item[const AIndex: Integer]: TListItem read GetItem write SetItem; default;
|
||||
property Owner : TCustomListView read FOwner;
|
||||
end;
|
||||
|
||||
|
||||
(*
|
||||
TViewColumn = class(TPersistent)
|
||||
private
|
||||
FCaption: String;
|
||||
FAlignment: TColumnAlignment;
|
||||
FOnChange: TNotifyEvent;
|
||||
FWidth: Integer;
|
||||
FMinWidth: Integer;
|
||||
FMaxWidth: Integer;
|
||||
FAutoSize: Boolean;
|
||||
FVisible: Boolean;
|
||||
procedure SetVisible(const AValue: Boolean);
|
||||
procedure SetAutoSize(const AValue: Boolean);
|
||||
procedure SetMinWidth(const AValue: Integer);
|
||||
procedure SetMaxWidth(const AValue: Integer);
|
||||
procedure SetWidth(const AValue: Integer);
|
||||
procedure SetCaption(const AValue: String);
|
||||
|
||||
procedure SetAlignment(const AValue: TColumnAlignment);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
Property Caption : String read FCaption write SetCaption;
|
||||
Property Width : Integer read FWidth write SetWidth;
|
||||
property MinWidth : Integer read FMinWidth write SetMinWidth;
|
||||
property MaxWidth : Integer read FMaxWidth write SetMaxWidth;
|
||||
property Alignment : TColumnAlignment read FAlignment write SetAlignment;
|
||||
Property AutoSize : Boolean read FAutoSize write SetAutoSize;
|
||||
Property Visible : Boolean read FVisible write SetVisible;
|
||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
||||
|
||||
end;
|
||||
*)
|
||||
|
||||
(*
|
||||
TViewColumns = class(TPersistent)
|
||||
private
|
||||
FItems : TList;
|
||||
FOnChange : TNotifyEvent;
|
||||
Listview : TCustomListView;
|
||||
FUpdating: Boolean;
|
||||
procedure SetUpdating(const AValue: Boolean);
|
||||
function GetCount: Integer;
|
||||
function GetItem(Index : Integer): TViewColumn;
|
||||
protected
|
||||
procedure ColumnChanged(Sender : TObject);
|
||||
public
|
||||
constructor Create(Aowner : TCustomListView);
|
||||
Destructor Destroy; override;
|
||||
Function Add(const S : String): Integer;
|
||||
Procedure Delete(Index : Integer);
|
||||
Procedure Clear; //deletes all columns
|
||||
property Count : Integer read GetCount;
|
||||
property Item[Index : Integer]: TViewColumn read GetItem; default;
|
||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
||||
property Updating : Boolean read FUpdating write SetUpdating;
|
||||
end;
|
||||
*)
|
||||
|
||||
TWidth = 0..MaxInt;
|
||||
|
||||
TListColumn = class(TCollectionItem)
|
||||
@ -554,7 +502,7 @@ type
|
||||
FListItems : TListItems;
|
||||
FColumns : TListColumns;
|
||||
FViewStyle : TViewStyle;
|
||||
FSorted : Boolean;
|
||||
FSortType: TSortType;
|
||||
FSortColumn : Integer;
|
||||
FMultiSelect: Boolean;
|
||||
FImageChangeLink : TChangeLink;
|
||||
@ -563,14 +511,19 @@ type
|
||||
FScrolledTop: integer; // vertical scrolled pixels (hidden pixels at top)
|
||||
FLastHorzScrollInfo: TScrollInfo;
|
||||
FLastVertScrollInfo: TScrollInfo;
|
||||
procedure SetColumns(Value: TListColumns);
|
||||
function GetSelection: TListItem;
|
||||
procedure SetColumns(const AValue: TListColumns);
|
||||
procedure SetDefaultItemHeight(AValue: integer);
|
||||
procedure SetItems(Value : TListItems);
|
||||
procedure SetItems(const AValue : TListItems);
|
||||
procedure SetMultiSelect(const AValue: Boolean);
|
||||
procedure SetSmallImages(const AValue: TCustomImageList);
|
||||
procedure SetScrollBars(const Value: TScrollStyle);
|
||||
procedure SetScrolledLeft(AValue: integer);
|
||||
procedure SetScrolledTop(AValue: integer);
|
||||
procedure SetScrolledLeft(AValue: Integer);
|
||||
procedure SetScrolledTop(AValue: Integer);
|
||||
procedure SetSelection(const AValue: TListItem);
|
||||
procedure SetSortColumn(const AValue: Integer);
|
||||
procedure SetSortType(const AValue: TSortType);
|
||||
procedure SetViewStyle (const Avalue: TViewStyle);
|
||||
procedure UpdateScrollbars;
|
||||
protected
|
||||
ParentWindow : TScrolledWindow;
|
||||
@ -578,9 +531,6 @@ type
|
||||
procedure InsertItem(Item : TListItem);
|
||||
function GetMaxScrolledLeft : Integer;
|
||||
function GetMaxScrolledTop : Integer;
|
||||
procedure SetViewStyle (value : TViewStyle);
|
||||
procedure SetSortColumn(Value : Integer);
|
||||
procedure SetSorted(Value : Boolean);
|
||||
procedure ColumnsChanged; //called by TListColumns
|
||||
procedure ItemChanged(Index : Integer); //called by TListItems
|
||||
procedure ItemDeleted(Index : Integer); //called by TListItems
|
||||
@ -601,12 +551,13 @@ type
|
||||
property ScrolledTop: integer read FScrolledTop write SetScrolledTop;
|
||||
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth;
|
||||
property SmallImages: TCustomImageList read FSmallImages write SetSmallImages;
|
||||
property Sorted: Boolean read FSorted write SetSorted;
|
||||
property SortType: TSortType read FSortType write SetSortType;
|
||||
property SortColumn: Integer read FSortColumn write SetSortColumn;
|
||||
property ViewStyle: TViewStyle read FViewStyle write SetViewStyle;
|
||||
public
|
||||
constructor Create(Aowner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
property Selected: TListItem read GetSelection write SetSelection;
|
||||
end;
|
||||
|
||||
TListView = class(TCustomListView)
|
||||
@ -624,6 +575,7 @@ type
|
||||
// property HideSelection;
|
||||
property Items;
|
||||
property MultiSelect;
|
||||
property PopupMenu;
|
||||
// property ReadOnly default False;
|
||||
// property RowSelect;
|
||||
property ScrollBars;
|
||||
@ -1099,8 +1051,6 @@ type
|
||||
|
||||
TAddMode = (taAddFirst, taAdd, taInsert);
|
||||
|
||||
TSortType = (stNone, stData, stText, stBoth);
|
||||
|
||||
TTreeNodeArray = ^TTreeNode;
|
||||
|
||||
ETreeNodeError = class(Exception);
|
||||
@ -1832,6 +1782,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.28 2002/03/23 15:51:17 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
Revision 1.27 2002/03/12 23:55:36 lazarus
|
||||
MWE:
|
||||
* More delphi compatibility added/updated to TListView
|
||||
|
@ -7,14 +7,14 @@ constructor TCustomListView.Create(Aowner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FColumns := TListColumns.Create(self);
|
||||
FListItems := TListITems.Create(self);
|
||||
FListItems := TListItems.Create(self);
|
||||
FBorderStyle := bsSingle;
|
||||
FScrollBars:=ssBoth;
|
||||
FScrollBars := ssBoth;
|
||||
FSmallImages := nil;
|
||||
fCompStyle := csListView;
|
||||
fViewStyle := vsList;
|
||||
fSorted := False;
|
||||
fSortColumn := 0;
|
||||
FCompStyle := csListView;
|
||||
FViewStyle := vsList;
|
||||
FSortType := stNone;
|
||||
FSortColumn := 0;
|
||||
FImageChangeLink := TChangeLink.Create;
|
||||
FImageChangeLink.OnChange := @ImageChanged;
|
||||
Setbounds(2,2,300,300);
|
||||
@ -67,7 +67,7 @@ End;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetItems }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetItems(Value : TListItems);
|
||||
procedure TCustomListView.SetItems(const AValue : TListItems);
|
||||
begin
|
||||
end;
|
||||
|
||||
@ -88,39 +88,39 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetColumns }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetColumns(Value: TListColumns);
|
||||
procedure TCustomListView.SetColumns(const AValue: TListColumns);
|
||||
begin
|
||||
FColumns.Assign(Value);
|
||||
FColumns.Assign(AValue);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetViewStyle }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetViewStyle(Value : TViewStyle);
|
||||
procedure TCustomListView.SetViewStyle(const AValue: TViewStyle);
|
||||
begin
|
||||
if FViewStyle = Value then Exit;
|
||||
FViewStyle := Value;
|
||||
if FViewStyle = AValue then Exit;
|
||||
FViewStyle := AValue;
|
||||
CNSendMessage(LM_SETPROPERTIES,self,nil);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetSorted }
|
||||
{ TCustomListView SetSortType }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetSorted(Value : Boolean);
|
||||
procedure TCustomListView.SetSortType(const AValue: TSortType);
|
||||
begin
|
||||
if FSorted = Value then Exit;
|
||||
FSorted := Value;
|
||||
if FSortType = AValue then Exit;
|
||||
FSortType := AValue;
|
||||
CNSendMessage(LM_SETPROPERTIES,self,nil);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetSortColumn }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetSortColumn(Value : Integer);
|
||||
procedure TCustomListView.SetSortColumn(const AValue : Integer);
|
||||
begin
|
||||
if FSortColumn = Value then Exit;
|
||||
FSortColumn := Value;
|
||||
if FSortColumn = AValue then Exit;
|
||||
FSortColumn := AValue;
|
||||
CNSendMessage(LM_SETPROPERTIES,self,nil);
|
||||
end;
|
||||
|
||||
@ -135,6 +135,21 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView GetSelection }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListView.GetSelection: TListItem;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetSelection }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetSelection(const AValue: TListItem);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TCustomListView.SetMultiSelect(const AValue: Boolean);
|
||||
begin
|
||||
if FMultiSelect <> AValue then
|
||||
@ -318,6 +333,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.15 2002/03/23 15:49:22 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
Revision 1.14 2002/03/14 23:25:52 lazarus
|
||||
MG: fixed TBevel.Create and TListView.Destroy
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
{ $Id$}
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListColumn }
|
||||
@ -107,6 +108,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2002/03/23 15:49:22 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
Revision 1.1 2002/03/12 23:55:37 lazarus
|
||||
MWE:
|
||||
* More delphi compatibility added/updated to TListView
|
||||
|
@ -1,3 +1,5 @@
|
||||
{ $Id$}
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListColumns }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -33,6 +35,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2002/03/23 15:49:22 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
Revision 1.1 2002/03/12 23:55:37 lazarus
|
||||
MWE:
|
||||
* More delphi compatibility added/updated to TListView
|
||||
|
@ -1,3 +1,5 @@
|
||||
{ $Id$}
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem Constructor }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -5,28 +7,37 @@ constructor TListItem.Create(AOwner : TListItems);
|
||||
begin
|
||||
Inherited Create;
|
||||
FOwner := AOwner;
|
||||
SubItems := TStringList.Create;
|
||||
TStringList(SubItems).OnChange := @ItemChanged;
|
||||
FSubItems := TStringList.Create;
|
||||
TStringList(FSubItems).OnChange := @ItemChanged;
|
||||
FDestroying := False;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetCaption }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetCaption(const Value : String);
|
||||
procedure TListItem.SetCaption(const AValue : String);
|
||||
begin
|
||||
FCaption := Value;
|
||||
FCaption := AValue;
|
||||
FOwner.ItemChanged(self);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetData }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetData(const AValue: Pointer);
|
||||
begin
|
||||
FData := AValue;
|
||||
// TODO: Sort
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem GetIndex }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.GetIndex : Integer;
|
||||
begin
|
||||
if Assigned(FOwner) then
|
||||
Result := FOwner.FItems.IndexOf(self)
|
||||
else
|
||||
Result := -1;
|
||||
if Assigned(FOwner)
|
||||
then Result := FOwner.FItems.IndexOf(self)
|
||||
else Result := -1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -43,7 +54,7 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.Delete;
|
||||
begin
|
||||
free;
|
||||
if not FDestroying then Free;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -59,8 +70,12 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
destructor TListItem.Destroy;
|
||||
begin
|
||||
FDestroying := True;
|
||||
if FOwner <> nil
|
||||
then FOwner.Delete(Index);
|
||||
|
||||
SubItems.Free;
|
||||
Inherited Destroy;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TListItem.SetImageIndex(const AValue: Integer);
|
||||
@ -72,4 +87,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.7 2002/03/23 15:49:22 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
{ $Id$}
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems Constructor }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -19,21 +21,21 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems GetItem }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.GetItem(Index : Integer): TListItem;
|
||||
function TListItems.GetItem(const AIndex: Integer): TListItem;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (FItems.Count-1 <Index) then Exit;
|
||||
Result := TListItem(FItems.Items[Index]);
|
||||
if (FItems.Count-1 < AIndex) then Exit;
|
||||
Result := TListItem(FItems.Items[AIndex]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems SetItem }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItems.SetItem(Index : Integer; Value : TListItem);
|
||||
procedure TListItems.SetItem(const AIndex: Integer; const AValue: TListItem);
|
||||
begin
|
||||
if FItems.Count-1 < Index then Exit;
|
||||
FItems.Items[Index] := Value;
|
||||
FOwner.ItemChanged(Index);
|
||||
if FItems.Count-1 < AIndex then Exit;
|
||||
FItems.Items[AIndex] := AValue;
|
||||
FOwner.ItemChanged(AIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -50,23 +52,18 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems Delete }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItems.Delete(Index : Integer);
|
||||
procedure TListItems.Delete(const AIndex: Integer);
|
||||
begin
|
||||
// Writeln('--------');
|
||||
if (FItems.Items[index] <> nil) then
|
||||
Item[Index].Delete;
|
||||
FItems.Delete(index);
|
||||
// if (FItems.Items[index] <> nil) then
|
||||
// TListItem(FItems.Items[Index]).Delete;
|
||||
Writeln('--------');
|
||||
FOwner.ItemDeleted(Index);
|
||||
// Writeln('--Item Deleted Called------');
|
||||
if (FItems.Items[Aindex] <> nil)
|
||||
then Item[AIndex].Delete;
|
||||
FItems.Delete(AIndex);
|
||||
FOwner.ItemDeleted(AIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems Insert }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.Insert(Index : Integer) : TListItem;
|
||||
function TListItems.Insert(const AIndex: Integer): TListItem;
|
||||
begin
|
||||
// ToDo
|
||||
Result:=nil;
|
||||
@ -81,6 +78,22 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems FindData }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.FindData(const AData: Pointer): TListItem;
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
for n := 0 to FItems.Count - 1 do
|
||||
begin
|
||||
Result := TListItem(FItems[n]);
|
||||
if Result.Data = AData then Exit;
|
||||
end;
|
||||
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems ItemChanged }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -95,3 +108,10 @@ begin
|
||||
FOwner.ItemChanged(Index);
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.9 2002/03/23 15:49:22 lazarus
|
||||
MWE: Fixed more compatebility issues (Sort, SelectedItem)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user