mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
Patch from Andrew Haines
git-svn-id: trunk@5374 -
This commit is contained in:
parent
3a41138231
commit
2caa9fbfde
@ -280,7 +280,7 @@ type
|
||||
TListItems = class; //forward declaration!
|
||||
TCustomListView = class; //forward declaration!
|
||||
TSortType = (stNone, stData, stText, stBoth);
|
||||
|
||||
|
||||
TListItem = class(TPersistent)
|
||||
private
|
||||
FOwner: TListItems;
|
||||
@ -293,7 +293,6 @@ type
|
||||
FState:byte;//by VVI - for state (currently Selected) accumulating
|
||||
function GetState(const AnIndex: Integer): Boolean;
|
||||
procedure SetState(const AnIndex: Integer; const AState: Boolean);
|
||||
|
||||
procedure SetData(const AValue: Pointer);
|
||||
procedure SetImageIndex(const AValue: Integer);
|
||||
procedure SetCaption(const AValue : String);
|
||||
@ -309,6 +308,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Delete;
|
||||
public
|
||||
procedure MakeVisible(PartialOK: Boolean);
|
||||
property Caption : String read FCaption write SetCaption;
|
||||
property Cut: Boolean index 0 read GetState write SetState;
|
||||
property Data: Pointer read FData write SetData;
|
||||
@ -433,6 +433,8 @@ type
|
||||
Column: TListColumn) of object;
|
||||
TLVColumnRClickEvent = procedure(Sender: TObject; Column: TListColumn;
|
||||
Point: TPoint) of object;
|
||||
TLVCompareEvent = procedure(Sender: TObject; Item1, Item2: TListItem;
|
||||
Data: Integer; var Compare: Integer) of object;
|
||||
TLVDeletedEvent = procedure(Sender: TObject; Item: TListItem) of object;
|
||||
TLVSelectItemEvent = procedure(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean) of object;
|
||||
@ -460,6 +462,7 @@ type
|
||||
FUpdateCount: integer;
|
||||
FOnChange: TLVChangeEvent;
|
||||
FOnColumnClick: TLVColumnClickEvent;
|
||||
FOnCompare: TLVCompareEvent;
|
||||
FOnDeletion: TLVDeletedEvent;
|
||||
FOnSelectItem: TLVSelectItemEvent;
|
||||
FStates: TListViewStates;
|
||||
@ -468,6 +471,7 @@ type
|
||||
procedure SetColumns(const AValue: TListColumns);
|
||||
procedure SetDefaultItemHeight(AValue: integer);
|
||||
procedure SetItems(const AValue : TListItems);
|
||||
procedure SetItemVisible(const Avalue: TListItem);
|
||||
procedure SetMultiSelect(const AValue: Boolean);
|
||||
procedure SetSmallImages(const AValue: TCustomImageList);
|
||||
procedure SetScrollBars(const Value: TScrollStyle);
|
||||
@ -477,6 +481,7 @@ type
|
||||
procedure SetSortColumn(const AValue: Integer);
|
||||
procedure SetSortType(const AValue: TSortType);
|
||||
procedure SetViewStyle (const Avalue: TViewStyle);
|
||||
procedure Sort;
|
||||
procedure UpdateScrollbars;
|
||||
procedure CNNotify(var AMessage: TLMNotify); message CN_NOTIFY;
|
||||
procedure DoUpdate;
|
||||
@ -486,6 +491,7 @@ type
|
||||
procedure Loaded; override;
|
||||
procedure Change(AItem: TListItem; AChange: Integer); dynamic;
|
||||
procedure ColClick(AColumn: TListColumn); dynamic;
|
||||
|
||||
procedure Delete(Item : TListItem);
|
||||
procedure DoDeletion(AItem: TListItem); dynamic;
|
||||
procedure DoSelectItem(AItem: TListItem; ASelected: Boolean); dynamic;
|
||||
@ -517,6 +523,7 @@ type
|
||||
property ViewStyle: TViewStyle read FViewStyle write SetViewStyle;
|
||||
property OnChange: TLVChangeEvent read FOnChange write FOnChange;
|
||||
property OnColumnClick: TLVColumnClickEvent read FOnColumnClick write FOnColumnClick;
|
||||
property OnCompare: TLVCompareEvent read FOnCompare write FOnCompare;
|
||||
property OnDeletion: TLVDeletedEvent read FOnDeletion write FOnDeletion;
|
||||
property OnSelectItem: TLVSelectItemEvent read FOnSelectItem write FOnSelectItem;
|
||||
public
|
||||
@ -560,6 +567,7 @@ type
|
||||
property OnChange;
|
||||
property OnClick;
|
||||
property OnColumnClick;
|
||||
property OnCompare;
|
||||
property OnDblClick;
|
||||
property OnMouseDown;
|
||||
property OnMouseUp;
|
||||
@ -2241,6 +2249,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.121 2004/04/04 17:10:05 marc
|
||||
Patch from Andrew Haines
|
||||
|
||||
Revision 1.120 2004/03/18 22:35:52 mattias
|
||||
improved TCustomListView.ItemAdded with an Index param from Andrew
|
||||
|
||||
|
@ -28,6 +28,7 @@ begin
|
||||
FViewStyle := vsList;
|
||||
FSortType := stNone;
|
||||
FSortColumn := 0;
|
||||
FOnCompare := nil;
|
||||
FImageChangeLink := TChangeLink.Create;
|
||||
FImageChangeLink.OnChange := @ImageChanged;
|
||||
FSelected := nil;
|
||||
@ -246,7 +247,14 @@ End;
|
||||
procedure TCustomListView.SetItems(const AValue : TListItems);
|
||||
begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetItemVisible }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetItemVisible(const AValue : TListItem);
|
||||
begin
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_SHOWITEM,self,AValue);
|
||||
end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView Delete }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -286,13 +294,16 @@ end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetSortType }
|
||||
{ TCustomListView SetSortType }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetSortType(const AValue: TSortType);
|
||||
begin
|
||||
if FSortType = AValue then Exit;
|
||||
FSortType := AValue;
|
||||
if not(AValue in [stNone]) then
|
||||
Sort;
|
||||
UpdateProperties;
|
||||
ColumnsChanged;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -302,9 +313,47 @@ procedure TCustomListView.SetSortColumn(const AValue : Integer);
|
||||
begin
|
||||
if FSortColumn = AValue then Exit;
|
||||
FSortColumn := AValue;
|
||||
if not(FSortType in [stNone]) then
|
||||
Sort;
|
||||
UpdateProperties;
|
||||
end;
|
||||
|
||||
function CompareItems(Item1, Item2: Pointer): Integer;
|
||||
var
|
||||
Str1: String;
|
||||
Str2: String;
|
||||
ListView: TCustomListView;
|
||||
begin
|
||||
ListView := TListItem(Item1).Owner.Owner;
|
||||
if Assigned(ListView.FOnCompare) then begin
|
||||
ListView.FOnCompare(ListView, TListItem(Item1), TListItem(Item2),0 ,Result);
|
||||
end
|
||||
else begin
|
||||
if ListView.FSortColumn = 0 then begin
|
||||
Str1 := TListItem(Item1).Caption;
|
||||
Str2 := TListItem(Item2).Caption;
|
||||
end
|
||||
else begin
|
||||
if ListView.FSortColumn <= TListItem(Item1).SubItems.Count then
|
||||
Str1 := TListItem(Item1).SubItems.Strings[ListView.FSortColumn-1]
|
||||
else Str1 := '';
|
||||
if ListView.FSortColumn <= TListItem(Item2).SubItems.Count then
|
||||
Str2 := TListItem(Item2).SubItems.Strings[ListView.FSortColumn-1]
|
||||
else Str2 := '';
|
||||
end;
|
||||
Result := AnsiCompareText(Str1, Str2);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView Sort }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.Sort;
|
||||
begin
|
||||
if FListItems.Count < 2 then Exit;
|
||||
FListItems.FItems.Sort(@CompareItems);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView Destructor }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -565,6 +614,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.32 2004/04/04 17:10:05 marc
|
||||
Patch from Andrew Haines
|
||||
|
||||
Revision 1.31 2004/03/18 22:35:52 mattias
|
||||
improved TCustomListView.ItemAdded with an Index param from Andrew
|
||||
|
||||
|
@ -132,6 +132,16 @@ begin
|
||||
else
|
||||
Result := -1;
|
||||
end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem MakeVisible }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.MakeVisible(PartialOK: Boolean);
|
||||
begin
|
||||
if FOwner <> nil then
|
||||
if FOwner.Fowner <> nil then
|
||||
FOwner.FOwner.SetItemVisible(Self);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetState }
|
||||
@ -147,6 +157,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.16 2004/04/04 17:10:05 marc
|
||||
Patch from Andrew Haines
|
||||
|
||||
Revision 1.15 2003/03/15 13:26:07 mattias
|
||||
fixes for fpc 1.1
|
||||
|
||||
|
@ -3260,17 +3260,33 @@ begin
|
||||
gtk_clist_select_row(PGtkCList(Widget),TListItem(Data).Index,0);
|
||||
{$EndIf}
|
||||
end;
|
||||
LM_LV_SHOWITEM:
|
||||
if (Sender is TListView) then
|
||||
begin
|
||||
if Data<>nil
|
||||
then begin
|
||||
Widget:= GetWidgetInfo(Pointer(Handle), True)^.CoreWidget;
|
||||
//0=NotVisible
|
||||
//1=PartiallyVisible
|
||||
//2=Fully Visible
|
||||
if gtk_clist_row_is_visible(PGtkCList(Widget),
|
||||
TListItem(Data).Index) < 2
|
||||
then gtk_clist_moveto(PGtkCList(Widget),TListItem(Data).Index,0,1,0);
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
LM_BRINGTOFRONT:
|
||||
begin
|
||||
{ Assert(False, 'Trace:TODO:bringtofront');
|
||||
//For now just hide and show again.
|
||||
if (Sender is TControl) then begin
|
||||
TControl(Sender).Parent.RemoveControl(TControl(Sender));
|
||||
writeln('Removed control ', TControl(Sender).Name);
|
||||
TControl(Sender).Parent.InsertControl(TControl(Sender));
|
||||
writeln('Inserted control ', TControl(Sender).Name);
|
||||
end;
|
||||
{ Assert(False, 'Trace:TODO:bringtofront');
|
||||
//For now just hide and show again.
|
||||
if (Sender is TControl)
|
||||
then begin
|
||||
TControl(Sender).Parent.RemoveControl(TControl(Sender));
|
||||
writeln('Removed control ', TControl(Sender).Name);
|
||||
TControl(Sender).Parent.InsertControl(TControl(Sender));
|
||||
writeln('Inserted control ', TControl(Sender).Name);
|
||||
end;
|
||||
}
|
||||
if (Sender is TCustomForm) then
|
||||
BringFormToFront(Sender);
|
||||
@ -9378,6 +9394,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.490 2004/04/04 17:10:05 marc
|
||||
Patch from Andrew Haines
|
||||
|
||||
Revision 1.489 2004/04/03 18:08:39 mattias
|
||||
fixed TLabel.AutoWrap=true and label on formless parent in gtk intf
|
||||
|
||||
|
@ -132,6 +132,7 @@ const
|
||||
LM_LV_CHANGEITEM = LM_LV_FIRST+1;
|
||||
LM_LV_DELETEITEM = LM_LV_FIRST+2;
|
||||
LM_LV_SELECTITEM = LM_LV_FIRST+3;
|
||||
LM_LV_SHOWITEM = LM_LV_FIRST+4;
|
||||
LM_LV_LAST = LM_LV_FIRST+9; // LM_COMUSER+89
|
||||
|
||||
// TComboBox
|
||||
@ -970,6 +971,7 @@ begin
|
||||
LM_LV_CHANGEITEM :Result:='LM_LV_CHANGEITEM';
|
||||
LM_LV_DELETEITEM :Result:='LM_LV_DELETEITEM';
|
||||
LM_LV_SELECTITEM :Result:='LM_LV_SELECTITEM';
|
||||
LM_LV_SHOWITEM :Result:='LM_LV_SHOWITEM';
|
||||
//LM_LV_LAST :Result:='LM_LV_LAST';
|
||||
|
||||
// TComboBox
|
||||
@ -1087,6 +1089,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.61 2004/04/04 17:10:05 marc
|
||||
Patch from Andrew Haines
|
||||
|
||||
Revision 1.60 2004/02/04 22:17:09 mattias
|
||||
removed workaround VirtualCreate
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user