MWE: Fixed more compatebility issues (Sort, SelectedItem)

git-svn-id: trunk@1535 -
This commit is contained in:
lazarus 2002-03-23 15:51:17 +00:00
parent 6a99eabc13
commit 5e3396a8bf
6 changed files with 182 additions and 161 deletions

View File

@ -1,3 +1,4 @@
{ $Id$}
{ {
/*************************************************************************** /***************************************************************************
ComCtrls.pp ComCtrls.pp
@ -72,7 +73,7 @@ uses
{Not used yet, but soon} {Not used yet, but soon}
TBCDRF_NOEDGES = $00010000; // Don't draw the button edges TBCDRF_NOEDGES = $00010000; // Don't draw the button edges
TBCDRF_HILITEHOTTRACK = $00020000; // Use color of the button bk when hottracked TBCDRF_HILITEHOTTRACK = $00020000; // Use color of the button bk when hottracked
TBCDRF_NOOFFSET = $00040000; // Don't offset the button if pressed TBCDRF_NOOFFSET = $00040000; // Don't offset the button if pressed
TBCDRF_NOMARK = $00080000; // Don't draw the default highlight of the image/text for TBSTATE_MARKED TBCDRF_NOMARK = $00080000; // Don't draw the default highlight of the image/text for TBSTATE_MARKED
TBCDRF_NOETCHEDEFFECT = $00100000; // Don't draw the etched effect for disabled items TBCDRF_NOETCHEDEFFECT = $00100000; // Don't draw the etched effect for disabled items
@ -116,7 +117,7 @@ uses
TB_SETIMAGELIST = WM_USER + 48; TB_SETIMAGELIST = WM_USER + 48;
TB_GETIMAGELIST = WM_USER + 49; TB_GETIMAGELIST = WM_USER + 49;
TB_LOADIMAGES = WM_USER + 50; TB_LOADIMAGES = WM_USER + 50;
TB_GETRECT = WM_USER + 51; TB_GETRECT = WM_USER + 51;
TB_SETHOTIMAGELIST = WM_USER + 52; TB_SETHOTIMAGELIST = WM_USER + 52;
TB_GETHOTIMAGELIST = WM_USER + 53; TB_GETHOTIMAGELIST = WM_USER + 53;
TB_SETDISABLEDIMAGELIST = WM_USER + 54; TB_SETDISABLEDIMAGELIST = WM_USER + 54;
@ -277,18 +278,18 @@ const
CCS_RIGHT = (CCS_VERT or CCS_BOTTOM); CCS_RIGHT = (CCS_VERT or CCS_BOTTOM);
CCS_NOMOVEX = (CCS_VERT or CCS_NOMOVEY); CCS_NOMOVEX = (CCS_VERT or CCS_NOMOVEY);
ICC_LISTVIEW_CLASSES = $00000001; ICC_LISTVIEW_CLASSES = $00000001;
ICC_TREEVIEW_CLASSES = $00000002; ICC_TREEVIEW_CLASSES = $00000002;
ICC_BAR_CLASSES = $00000004; ICC_BAR_CLASSES = $00000004;
ICC_TAB_CLASSES = $00000008; ICC_TAB_CLASSES = $00000008;
ICC_UPDOWN_CLASS = $00000010; ICC_UPDOWN_CLASS = $00000010;
ICC_PROGRESS_CLASS = $00000020; ICC_PROGRESS_CLASS = $00000020;
ICC_HOTKEY_CLASS = $00000040; ICC_HOTKEY_CLASS = $00000040;
ICC_ANIMATE_CLASS = $00000080; ICC_ANIMATE_CLASS = $00000080;
ICC_WIN95_CLASSES = $000000FF; ICC_WIN95_CLASSES = $000000FF;
ICC_DATE_CLASSES = $00000100; ICC_DATE_CLASSES = $00000100;
ICC_USEREX_CLASSES = $00000200; ICC_USEREX_CLASSES = $00000200;
ICC_COOL_CLASSES = $00000400; ICC_COOL_CLASSES = $00000400;
ICC_INTERNET_CLASSES = $00000800; ICC_INTERNET_CLASSES = $00000800;
ICC_PAGESCROLLER_CLASS = $00001000; ICC_PAGESCROLLER_CLASS = $00001000;
ICC_NATIVEFNTCTL_CLASS = $00002000; ICC_NATIVEFNTCTL_CLASS = $00002000;
@ -383,16 +384,21 @@ type
TListItems = class; //forward declaration! TListItems = class; //forward declaration!
TCustomListView = class; //forward declaration! TCustomListView = class; //forward declaration!
TSortType = (stNone, stData, stText, stBoth);
TListItem = class(TPersistent) TListItem = class(TPersistent)
private private
FOwner : TListItems; FOwner: TListItems;
FSubItems: TStrings; FSubItems: TStrings;
//FIndex : Integer; //FIndex : Integer;
FCaption : String; FCaption: String;
FData: Pointer;
FImageIndex: Integer; FImageIndex: Integer;
FDestroying: Boolean;
procedure SetData(const AValue: Pointer);
procedure SetImageIndex(const AValue: Integer); procedure SetImageIndex(const AValue: Integer);
Procedure SetCaption(const Value : String); procedure SetCaption(const AValue : String);
// Procedure SetSubItems(Value : TStrings); // Procedure SetSubItems(Value : TStrings);
Function GetIndex : Integer; Function GetIndex : Integer;
protected protected
@ -403,6 +409,7 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure Delete; procedure Delete;
property Caption : String read FCaption write SetCaption; property Caption : String read FCaption write SetCaption;
property Data: Pointer read FData write SetData;
property Index : Integer read GetIndex; property Index : Integer read GetIndex;
property Owner : TListItems read FOwner; property Owner : TListItems read FOwner;
property SubItems : TStrings read FSubItems write FSubItems;//SetSubItems; property SubItems : TStrings read FSubItems write FSubItems;//SetSubItems;
@ -415,80 +422,21 @@ type
FItems : TList; FItems : TList;
Function GetCount : Integer; Function GetCount : Integer;
protected protected
Function GetItem(Index : Integer): TListItem; function GetItem(const AIndex: Integer): TListItem;
procedure SetITem(Index : Integer; Value : TListItem); procedure SetITem(const AIndex: Integer; const AValue: TListItem);
Procedure ItemChanged(sender : TObject); //called by TListItem in response to SubItems changing procedure ItemChanged(sender : TObject); //called by TListItem in response to SubItems changing
public public
function Add: TListItem;
constructor Create(AOwner : TCustomListView); constructor Create(AOwner : TCustomListView);
destructor Destroy; override; destructor Destroy; override;
function Add:TListItem; procedure Delete(const AIndex : Integer);
Procedure Delete(Index : Integer); function FindData(const AData: Pointer): TListItem;
function Insert(Index : Integer) : TListItem; function Insert(const AIndex: Integer) : TListItem;
property Count : Integer read GetCount; property Count: Integer read GetCount;
property Item[Index : Integer]: TListItem read GetItem write SetItem; default; property Item[const AIndex: Integer]: TListItem read GetItem write SetItem; default;
property Owner : TCustomListView read FOwner; property Owner : TCustomListView read FOwner;
end; 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; TWidth = 0..MaxInt;
TListColumn = class(TCollectionItem) TListColumn = class(TCollectionItem)
@ -541,10 +489,10 @@ type
property Owner: TCustomListView read FOwner; property Owner: TCustomListView read FOwner;
property Items[const AIndex: Integer]: TListColumn read GetItem write SetItem; default; property Items[const AIndex: Integer]: TListColumn read GetItem write SetItem; default;
end; end;
TViewStyle = (vsList,vsReport); TViewStyle = (vsList,vsReport);
TCustomListView = class(TWinControl) TCustomListView = class(TWinControl)
private private
//FReadOnly : Boolean; //FReadOnly : Boolean;
@ -554,7 +502,7 @@ type
FListItems : TListItems; FListItems : TListItems;
FColumns : TListColumns; FColumns : TListColumns;
FViewStyle : TViewStyle; FViewStyle : TViewStyle;
FSorted : Boolean; FSortType: TSortType;
FSortColumn : Integer; FSortColumn : Integer;
FMultiSelect: Boolean; FMultiSelect: Boolean;
FImageChangeLink : TChangeLink; FImageChangeLink : TChangeLink;
@ -563,14 +511,19 @@ type
FScrolledTop: integer; // vertical scrolled pixels (hidden pixels at top) FScrolledTop: integer; // vertical scrolled pixels (hidden pixels at top)
FLastHorzScrollInfo: TScrollInfo; FLastHorzScrollInfo: TScrollInfo;
FLastVertScrollInfo: TScrollInfo; FLastVertScrollInfo: TScrollInfo;
procedure SetColumns(Value: TListColumns); function GetSelection: TListItem;
procedure SetColumns(const AValue: TListColumns);
procedure SetDefaultItemHeight(AValue: integer); procedure SetDefaultItemHeight(AValue: integer);
procedure SetItems(Value : TListItems); procedure SetItems(const AValue : TListItems);
procedure SetMultiSelect(const AValue: Boolean); procedure SetMultiSelect(const AValue: Boolean);
procedure SetSmallImages(const AValue: TCustomImageList); procedure SetSmallImages(const AValue: TCustomImageList);
procedure SetScrollBars(const Value: TScrollStyle); procedure SetScrollBars(const Value: TScrollStyle);
procedure SetScrolledLeft(AValue: integer); procedure SetScrolledLeft(AValue: Integer);
procedure SetScrolledTop(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; procedure UpdateScrollbars;
protected protected
ParentWindow : TScrolledWindow; ParentWindow : TScrolledWindow;
@ -578,9 +531,6 @@ type
procedure InsertItem(Item : TListItem); procedure InsertItem(Item : TListItem);
function GetMaxScrolledLeft : Integer; function GetMaxScrolledLeft : Integer;
function GetMaxScrolledTop : Integer; function GetMaxScrolledTop : Integer;
procedure SetViewStyle (value : TViewStyle);
procedure SetSortColumn(Value : Integer);
procedure SetSorted(Value : Boolean);
procedure ColumnsChanged; //called by TListColumns procedure ColumnsChanged; //called by TListColumns
procedure ItemChanged(Index : Integer); //called by TListItems procedure ItemChanged(Index : Integer); //called by TListItems
procedure ItemDeleted(Index : Integer); //called by TListItems procedure ItemDeleted(Index : Integer); //called by TListItems
@ -601,16 +551,17 @@ type
property ScrolledTop: integer read FScrolledTop write SetScrolledTop; property ScrolledTop: integer read FScrolledTop write SetScrolledTop;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth; property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth;
property SmallImages: TCustomImageList read FSmallImages write SetSmallImages; 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 SortColumn: Integer read FSortColumn write SetSortColumn;
property ViewStyle: TViewStyle read FViewStyle write SetViewStyle; property ViewStyle: TViewStyle read FViewStyle write SetViewStyle;
public public
constructor Create(Aowner: TComponent); override; constructor Create(Aowner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
property Selected: TListItem read GetSelection write SetSelection;
end; end;
TListView = class(TCustomListView) TListView = class(TCustomListView)
published published
property Align; property Align;
property Anchors; property Anchors;
// property BorderStyle; // property BorderStyle;
@ -624,6 +575,7 @@ type
// property HideSelection; // property HideSelection;
property Items; property Items;
property MultiSelect; property MultiSelect;
property PopupMenu;
// property ReadOnly default False; // property ReadOnly default False;
// property RowSelect; // property RowSelect;
property ScrollBars; property ScrollBars;
@ -642,7 +594,7 @@ type
end; end;
TProgressBarOrientation = (pbHorizontal, pbVertical, pbRightToLeft, pbTopDown); TProgressBarOrientation = (pbHorizontal, pbVertical, pbRightToLeft, pbTopDown);
{ TProgressBar } { TProgressBar }
{ {
@abstract(Simple progressbar.) @abstract(Simple progressbar.)
@ -672,7 +624,7 @@ type
procedure SetOrientation (Value : TProgressBarOrientation); procedure SetOrientation (Value : TProgressBarOrientation);
protected protected
procedure ApplyChanges; procedure ApplyChanges;
procedure AttachSignals; override; procedure AttachSignals; override;
procedure InitializeWnd; override; procedure InitializeWnd; override;
{ procedure SetBarTextFormat; } { procedure SetBarTextFormat; }
public public
@ -708,19 +660,19 @@ type
property OnMouseMove; property OnMouseMove;
property OnMouseUp; property OnMouseUp;
property OnStartDrag; property OnStartDrag;
{ ... to be implemented for Delphi compatibility { ... to be implemented for Delphi compatibility
// property Anchors; // property Anchors;
// property Constraints; // property Constraints;
// property OnStartDock; // property OnStartDock;
// property OnEndDock; // property OnEndDock;
} }
published { additional functionality } published { additional functionality }
property BarShowText : boolean read FBarShowText write SetBarShowText; property BarShowText : boolean read FBarShowText write SetBarShowText;
{ property BarTextFormat : string read FBarTextFormat write SetBarTextFormat; } { property BarTextFormat : string read FBarTextFormat write SetBarTextFormat; }
end; end;
{ TToolBar } { TToolBar }
const const
@ -1037,17 +989,17 @@ type
protected protected
procedure ApplyChanges; procedure ApplyChanges;
procedure DoChange(var msg); message LM_CHANGED; procedure DoChange(var msg); message LM_CHANGED;
procedure AttachSignals; override; procedure AttachSignals; override;
procedure InitializeWnd; override; procedure InitializeWnd; override;
{ ... what about these? { ... what about these?
procedure CreateParams(var Params: TCreateParams); override; procedure CreateParams(var Params: TCreateParams); override;
procedure DestroyWnd; override; procedure DestroyWnd; override;
} }
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure SetTick(Value: Integer); procedure SetTick(Value: Integer);
published published
property Ctl3D; property Ctl3D;
property LineSize: Integer read FLineSize write SetLineSize default 1; property LineSize: Integer read FLineSize write SetLineSize default 1;
property Max: Integer read FMax write SetMax default 10; property Max: Integer read FMax write SetMax default 10;
property Min: Integer read FMin write SetMin default 0; property Min: Integer read FMin write SetMin default 0;
@ -1059,7 +1011,7 @@ type
property SelStart: Integer read FSelStart write SetSelStart; property SelStart: Integer read FSelStart write SetSelStart;
property TickMarks: TTickMark read FTickMarks write SetTickMarks; property TickMarks: TTickMark read FTickMarks write SetTickMarks;
property TickStyle: TTickStyle read FTickStyle write SetTickStyle; property TickStyle: TTickStyle read FTickStyle write SetTickStyle;
property Visible; property Visible;
property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnEnter; property OnEnter;
property OnExit; property OnExit;
@ -1075,13 +1027,13 @@ type
property OnEndDrag; property OnEndDrag;
property PopupMenu; property PopupMenu;
property ShowHint; property ShowHint;
property TabOrder; property TabOrder;
property TabStop default True; property TabStop default True;
property OnStartDrag; property OnStartDrag;
published { additional functionality } published { additional functionality }
property ShowScale : boolean read FShowScale write SetShowScale; property ShowScale : boolean read FShowScale write SetShowScale;
property ScalePos : TTrackBarScalePos read FScalePos write SetScalePos; property ScalePos : TTrackBarScalePos read FScalePos write SetScalePos;
property DragMode; property DragMode;
end; end;
@ -1099,8 +1051,6 @@ type
TAddMode = (taAddFirst, taAdd, taInsert); TAddMode = (taAddFirst, taAdd, taInsert);
TSortType = (stNone, stData, stText, stBoth);
TTreeNodeArray = ^TTreeNode; TTreeNodeArray = ^TTreeNode;
ETreeNodeError = class(Exception); ETreeNodeError = class(Exception);
@ -1598,7 +1548,7 @@ type
procedure SetDragMode(Value: TDragMode); override; procedure SetDragMode(Value: TDragMode); override;
procedure SetOptions(NewOptions: TTreeViewOptions); procedure SetOptions(NewOptions: TTreeViewOptions);
procedure WndProc(var Message: TLMessage); override; procedure WndProc(var Message: TLMessage); override;
property AutoExpand: Boolean read GetAutoExpand write SetAutoExpand default False; property AutoExpand: Boolean read GetAutoExpand write SetAutoExpand default False;
property BorderStyle: TBorderStyle property BorderStyle: TBorderStyle
read FBorderStyle write SetBorderStyle default bsSingle; read FBorderStyle write SetBorderStyle default bsSingle;
@ -1832,6 +1782,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.27 2002/03/12 23:55:36 lazarus
MWE: MWE:
* More delphi compatibility added/updated to TListView * More delphi compatibility added/updated to TListView

View File

@ -7,14 +7,14 @@ constructor TCustomListView.Create(Aowner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FColumns := TListColumns.Create(self); FColumns := TListColumns.Create(self);
FListItems := TListITems.Create(self); FListItems := TListItems.Create(self);
FBorderStyle := bsSingle; FBorderStyle := bsSingle;
FScrollBars:=ssBoth; FScrollBars := ssBoth;
FSmallImages := nil; FSmallImages := nil;
fCompStyle := csListView; FCompStyle := csListView;
fViewStyle := vsList; FViewStyle := vsList;
fSorted := False; FSortType := stNone;
fSortColumn := 0; FSortColumn := 0;
FImageChangeLink := TChangeLink.Create; FImageChangeLink := TChangeLink.Create;
FImageChangeLink.OnChange := @ImageChanged; FImageChangeLink.OnChange := @ImageChanged;
Setbounds(2,2,300,300); Setbounds(2,2,300,300);
@ -67,7 +67,7 @@ End;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView SetItems } { TCustomListView SetItems }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCustomListView.SetItems(Value : TListItems); procedure TCustomListView.SetItems(const AValue : TListItems);
begin begin
end; end;
@ -88,39 +88,39 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView SetColumns } { TCustomListView SetColumns }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCustomListView.SetColumns(Value: TListColumns); procedure TCustomListView.SetColumns(const AValue: TListColumns);
begin begin
FColumns.Assign(Value); FColumns.Assign(AValue);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView SetViewStyle } { TCustomListView SetViewStyle }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCustomListView.SetViewStyle(Value : TViewStyle); procedure TCustomListView.SetViewStyle(const AValue: TViewStyle);
begin begin
if FViewStyle = Value then Exit; if FViewStyle = AValue then Exit;
FViewStyle := Value; FViewStyle := AValue;
CNSendMessage(LM_SETPROPERTIES,self,nil); CNSendMessage(LM_SETPROPERTIES,self,nil);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView SetSorted } { TCustomListView SetSortType }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCustomListView.SetSorted(Value : Boolean); procedure TCustomListView.SetSortType(const AValue: TSortType);
begin begin
if FSorted = Value then Exit; if FSortType = AValue then Exit;
FSorted := Value; FSortType := AValue;
CNSendMessage(LM_SETPROPERTIES,self,nil); CNSendMessage(LM_SETPROPERTIES,self,nil);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TCustomListView SetSortColumn } { TCustomListView SetSortColumn }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TCustomListView.SetSortColumn(Value : Integer); procedure TCustomListView.SetSortColumn(const AValue : Integer);
begin begin
if FSortColumn = Value then Exit; if FSortColumn = AValue then Exit;
FSortColumn := Value; FSortColumn := AValue;
CNSendMessage(LM_SETPROPERTIES,self,nil); CNSendMessage(LM_SETPROPERTIES,self,nil);
end; end;
@ -135,6 +135,21 @@ begin
inherited Destroy; inherited Destroy;
end; 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); procedure TCustomListView.SetMultiSelect(const AValue: Boolean);
begin begin
if FMultiSelect <> AValue then if FMultiSelect <> AValue then
@ -318,6 +333,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.14 2002/03/14 23:25:52 lazarus
MG: fixed TBevel.Create and TListView.Destroy MG: fixed TBevel.Create and TListView.Destroy

View File

@ -1,3 +1,4 @@
{ $Id$}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListColumn } { TListColumn }
@ -107,6 +108,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.1 2002/03/12 23:55:37 lazarus
MWE: MWE:
* More delphi compatibility added/updated to TListView * More delphi compatibility added/updated to TListView

View File

@ -1,3 +1,5 @@
{ $Id$}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListColumns } { TListColumns }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -33,6 +35,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.1 2002/03/12 23:55:37 lazarus
MWE: MWE:
* More delphi compatibility added/updated to TListView * More delphi compatibility added/updated to TListView

View File

@ -1,3 +1,5 @@
{ $Id$}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItem Constructor } { TListItem Constructor }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -5,28 +7,37 @@ constructor TListItem.Create(AOwner : TListItems);
begin begin
Inherited Create; Inherited Create;
FOwner := AOwner; FOwner := AOwner;
SubItems := TStringList.Create; FSubItems := TStringList.Create;
TStringList(SubItems).OnChange := @ItemChanged; TStringList(FSubItems).OnChange := @ItemChanged;
FDestroying := False;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItem SetCaption } { TListItem SetCaption }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TListItem.SetCaption(const Value : String); procedure TListItem.SetCaption(const AValue : String);
begin begin
FCaption := Value; FCaption := AValue;
FOwner.ItemChanged(self); FOwner.ItemChanged(self);
end; end;
{------------------------------------------------------------------------------}
{ TListItem SetData }
{------------------------------------------------------------------------------}
procedure TListItem.SetData(const AValue: Pointer);
begin
FData := AValue;
// TODO: Sort
end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItem GetIndex } { TListItem GetIndex }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
function TListItem.GetIndex : Integer; function TListItem.GetIndex : Integer;
begin begin
if Assigned(FOwner) then if Assigned(FOwner)
Result := FOwner.FItems.IndexOf(self) then Result := FOwner.FItems.IndexOf(self)
else else Result := -1;
Result := -1;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -43,7 +54,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TListItem.Delete; procedure TListItem.Delete;
begin begin
free; if not FDestroying then Free;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -59,8 +70,12 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
destructor TListItem.Destroy; destructor TListItem.Destroy;
begin begin
SubItems.Free; FDestroying := True;
Inherited Destroy; if FOwner <> nil
then FOwner.Delete(Index);
SubItems.Free;
inherited Destroy;
end; end;
procedure TListItem.SetImageIndex(const AValue: Integer); procedure TListItem.SetImageIndex(const AValue: Integer);
@ -72,4 +87,10 @@ begin
end; end;
end; end;
{ =============================================================================
$Log$
Revision 1.7 2002/03/23 15:49:22 lazarus
MWE: Fixed more compatebility issues (Sort, SelectedItem)
}

View File

@ -1,3 +1,5 @@
{ $Id$}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItems Constructor } { TListItems Constructor }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -19,21 +21,21 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItems GetItem } { TListItems GetItem }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
function TListItems.GetItem(Index : Integer): TListItem; function TListItems.GetItem(const AIndex: Integer): TListItem;
begin begin
Result:=nil; Result:=nil;
if (FItems.Count-1 <Index) then Exit; if (FItems.Count-1 < AIndex) then Exit;
Result := TListItem(FItems.Items[Index]); Result := TListItem(FItems.Items[AIndex]);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItems SetItem } { TListItems SetItem }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TListItems.SetItem(Index : Integer; Value : TListItem); procedure TListItems.SetItem(const AIndex: Integer; const AValue: TListItem);
begin begin
if FItems.Count-1 < Index then Exit; if FItems.Count-1 < AIndex then Exit;
FItems.Items[Index] := Value; FItems.Items[AIndex] := AValue;
FOwner.ItemChanged(Index); FOwner.ItemChanged(AIndex);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -50,23 +52,18 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItems Delete } { TListItems Delete }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TListItems.Delete(Index : Integer); procedure TListItems.Delete(const AIndex: Integer);
begin begin
// Writeln('--------'); if (FItems.Items[Aindex] <> nil)
if (FItems.Items[index] <> nil) then then Item[AIndex].Delete;
Item[Index].Delete; FItems.Delete(AIndex);
FItems.Delete(index); FOwner.ItemDeleted(AIndex);
// if (FItems.Items[index] <> nil) then
// TListItem(FItems.Items[Index]).Delete;
Writeln('--------');
FOwner.ItemDeleted(Index);
// Writeln('--Item Deleted Called------');
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TListItems Insert } { TListItems Insert }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
function TListItems.Insert(Index : Integer) : TListItem; function TListItems.Insert(const AIndex: Integer): TListItem;
begin begin
// ToDo // ToDo
Result:=nil; Result:=nil;
@ -81,6 +78,22 @@ begin
inherited Destroy; inherited Destroy;
end; 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 } { TListItems ItemChanged }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -95,3 +108,10 @@ begin
FOwner.ItemChanged(Index); FOwner.ItemChanged(Index);
end; end;
{ =============================================================================
$Log$
Revision 1.9 2002/03/23 15:49:22 lazarus
MWE: Fixed more compatebility issues (Sort, SelectedItem)
}