From: Olivier S. <ob...@us...> - 2005-09-19 13:46:18
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24100/dev/JVCL3/run Modified Files: JvListView.pas Log Message: Added ExtendedColumns property Index: JvListView.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvListView.pas,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** JvListView.pas 15 Sep 2005 10:19:43 -0000 1.56 --- JvListView.pas 19 Sep 2005 13:46:07 -0000 1.57 *************** *** 96,101 **** end; ! // (rom) Why that? C++ Builder should need this class. ! {$EXTERNALSYM TJvListItem} TJvListView = class(TJvExListView) --- 96,120 ---- end; ! TJvListExtendedColumn = class(TCollectionItem) ! private ! FSortMethod: TJvSortMethod; ! FUseParentSortMethod: Boolean; ! function GetSortMethod: TJvSortMethod; ! procedure SetSortMethod(const Value: TJvSortMethod); ! public ! constructor Create(Collection: TCollection); override; ! published ! property SortMethod: TJvSortMethod read GetSortMethod write SetSortMethod default smAutomatic; ! property UseParentSortMethod : Boolean read FUseParentSortMethod write FUseParentSortMethod default True; ! end; ! ! TJvListExtendedColumns = class(TOwnedCollection) ! private ! function GetItem(Index: Integer): TJvListExtendedColumn; ! procedure SetItem(Index: Integer; const Value: TJvListExtendedColumn); ! public ! constructor Create(AOwner: TPersistent); ! property Items[Index: Integer] : TJvListExtendedColumn read GetItem write SetItem; default; ! end; TJvListView = class(TJvExListView) *************** *** 114,117 **** --- 133,138 ---- FAutoSelect: Boolean; FPicture: TPicture; + FExtendedColumns: TJvListExtendedColumns; + FSavedExtendedColumns: TJvListExtendedColumns; // use for Create/DestroyWnd process procedure DoPictureChange(Sender: TObject); procedure SetPicture(const Value: TPicture); *************** *** 119,122 **** --- 140,144 ---- procedure UpdateHeaderImages(HeaderHandle: Integer); procedure WMAutoSelect(var Msg: TMessage); message WM_AUTOSELECT; + procedure SetExtendedColumns(const Value: TJvListExtendedColumns); {$IFDEF COMPILER5} function GetItemIndex: Integer; *************** *** 134,141 **** procedure SetItemPopup(Node: TListItem; Value: TPopupMenu); function GetItemPopup(Node: TListItem): TPopupMenu; - procedure CreateWnd; override; procedure DoHeaderImagesChange(Sender: TObject); procedure Loaded; override; procedure WMNCCalcSize(var Msg: TWMNCCalcSize); message WM_NCCALCSIZE; procedure InsertItem(Item: TListItem); override; --- 156,168 ---- procedure SetItemPopup(Node: TListItem; Value: TPopupMenu); function GetItemPopup(Node: TListItem): TPopupMenu; procedure DoHeaderImagesChange(Sender: TObject); procedure Loaded; override; + + procedure CreateWnd; override; + procedure DestroyWnd; override; + procedure WMNCCalcSize(var Msg: TWMNCCalcSize); message WM_NCCALCSIZE; + procedure LVMDeleteColumn(var Msg: TMessage); message LVM_DELETECOLUMN; + procedure LVMInsertColumn(var Msg: TMessage); message LVM_INSERTCOLUMN; procedure InsertItem(Item: TListItem); override; *************** *** 193,196 **** --- 220,234 ---- property OnMouseLeave; property OnParentColorChange; + + // This property contains a collection that allows to specify additional + // properties for each columns (sort method for instance). It can not be + // included in the Columns collection as the VCL does not offer a way + // to specify which class to use for the items of the Columns collection. + // Note that this one (ExtendedColumns) is populated automatically when + // a column is added or deleted. But because the VCL code for add starts + // by deleting all columns to reinsert them after, you should not change + // the properties for any item of ExtendedColumns in a loop that contains + // a call to the Add method of the Columns property. + property ExtendedColumns : TJvListExtendedColumns read FExtendedColumns write SetExtendedColumns; end; *************** *** 334,337 **** --- 372,419 ---- end; + { TJvListExtendedColumn } + + constructor TJvListExtendedColumn.Create(Collection: TCollection); + begin + inherited Create(Collection); + + FSortMethod := smAutomatic; + FUseParentSortMethod := True; + end; + + function TJvListExtendedColumn.GetSortMethod: TJvSortMethod; + begin + if (Collection.Owner is TJvListView) and UseParentSortMethod then + Result := TJvListView(Collection.Owner).SortMethod + else + Result := FSortMethod; + end; + + procedure TJvListExtendedColumn.SetSortMethod( + const Value: TJvSortMethod); + begin + FSortMethod := Value; + UseParentSortMethod := False; + end; + + { TJvListExtendedColumns } + + constructor TJvListExtendedColumns.Create(AOwner: TPersistent); + begin + inherited Create(AOwner, TJvListExtendedColumn); + end; + + function TJvListExtendedColumns.GetItem( + Index: Integer): TJvListExtendedColumn; + begin + Result := TJvListExtendedColumn(inherited Items[Index]); + end; + + procedure TJvListExtendedColumns.SetItem(Index: Integer; + const Value: TJvListExtendedColumn); + begin + inherited Items[Index] := Value; + end; + //=== { TJvListView } ======================================================== *************** *** 351,358 **** --- 433,446 ---- FPicture := TPicture.Create; FPicture.OnChange := DoPictureChange; + + FExtendedColumns := TJvListExtendedColumns.Create(Self); + FSavedExtendedColumns := TJvListExtendedColumns.Create(Self); end; destructor TJvListView.Destroy; begin + FExtendedColumns.Free; + FSavedExtendedColumns.Free; + FImageChangeLink.Free; FPicture.Free; *************** *** 524,528 **** // (Salvatore) ! SortKind := TJvListView(Parm.Sender).SortMethod; if Assigned(TJvListView(Parm.Sender).OnAutoSort) then TJvListView(Parm.Sender).OnAutoSort(Parm.Sender, Parm.Index, SortKind); --- 612,616 ---- // (Salvatore) ! SortKind := TJvListView(Parm.Sender).ExtendedColumns[Parm.Index].SortMethod; if Assigned(TJvListView(Parm.Sender).OnAutoSort) then TJvListView(Parm.Sender).OnAutoSort(Parm.Sender, Parm.Index, SortKind); *************** *** 1142,1145 **** --- 1230,1239 ---- end; + procedure TJvListView.SetExtendedColumns( + const Value: TJvListExtendedColumns); + begin + FExtendedColumns.Assign(Value); + end; + procedure TJvListView.Notification(AComponent: TComponent; Operation: TOperation); *************** *** 1162,1165 **** --- 1256,1261 ---- inherited CreateWnd; UpdateHeaderImages(ListView_GetHeader(Handle)); + if FSavedExtendedColumns.Count > 0 then + FExtendedColumns.Assign(FSavedExtendedColumns); end; *************** *** 1454,1457 **** --- 1550,1571 ---- end; + procedure TJvListView.LVMDeleteColumn(var Msg: TMessage); + begin + inherited; + FExtendedColumns.Delete(Msg.WParam); + end; + + procedure TJvListView.LVMInsertColumn(var Msg: TMessage); + begin + inherited; + FExtendedColumns.Insert(Msg.WParam); + end; + + procedure TJvListView.DestroyWnd; + begin + FSavedExtendedColumns.Assign(FExtendedColumns); + inherited DestroyWnd; + end; + {$IFDEF COMPILER5} |