mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 07:49:33 +02:00
* Implemented most of TListColoum/Item in the Ws for gtk and win32
git-svn-id: trunk@5667 -
This commit is contained in:
parent
f4e75dad35
commit
c4afc3033d
examples
lcl
@ -23,19 +23,21 @@ program ListBoxTest;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, Buttons, Classes, Forms, StdCtrls, SysUtils, Vclglobals,
|
||||
CListBox;
|
||||
Interfaces, Buttons, Classes, Forms, StdCtrls, SysUtils, Vclglobals, Controls{,
|
||||
CListBox};
|
||||
|
||||
type
|
||||
TListBoxTestForm = class(TForm)
|
||||
public
|
||||
Button1, Button2, Button3, Button4: TButton;
|
||||
ListBox: TCListBox;
|
||||
ListBox: TListBox;
|
||||
// ListBox: TCListBox;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure Button4Click(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -93,15 +95,19 @@ begin
|
||||
Button4.caption := 'Unused';
|
||||
Button4.Show;
|
||||
|
||||
ListBox := TCListBox.Create(Self);
|
||||
// ListBox := TCListBox.Create(Self);
|
||||
ListBox := TListBox.Create(Self);
|
||||
ListBox.Parent := Self;
|
||||
ListBox.Left := 10;
|
||||
ListBox.Top := 10;
|
||||
ListBox.Width := 280;
|
||||
ListBox.Height := 155;
|
||||
ListBox.Height := 150;
|
||||
ListBox.Anchors := [akLeft, akRight, akTop];
|
||||
{ ListBox.ExtendedSelect := true;
|
||||
ListBox.MultiSelect := true;
|
||||
} ListBox.Show;
|
||||
|
||||
OnResize := @FormResize;
|
||||
end;
|
||||
|
||||
procedure TListBoxTestForm.Button1Click(Sender: TObject);
|
||||
@ -139,6 +145,11 @@ begin
|
||||
writeln('TListBoxTestForm.Button4Click ',X);
|
||||
end;
|
||||
|
||||
procedure TListBoxTestForm.FormResize(Sender: TObject);
|
||||
begin
|
||||
Caption := Format('%dx%d', [ListBox.Width, ListBox.Height]);
|
||||
end;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TListBoxTestForm, ListBoxTestForm);
|
||||
|
@ -155,7 +155,7 @@ end;
|
||||
procedure TMyForm.Edit2Change(Sender: TObject);
|
||||
begin
|
||||
if ListView.Selected = nil then Exit;
|
||||
ListView.Selected.SubItems[1] := Edit2.Text;
|
||||
ListView.Selected.SubItems[0] := Edit2.Text;
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -166,6 +166,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.7 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.6 2004/05/20 21:28:54 marc
|
||||
* Fixed win32 listview
|
||||
|
||||
|
@ -9,7 +9,9 @@ component can be found here:
|
||||
http://users.iafrica.com/d/da/dart/Delphi/TTreeView/TreeView.html
|
||||
}
|
||||
|
||||
interface
|
||||
interface
|
||||
|
||||
{$mode objfpc} {$H+}
|
||||
|
||||
uses
|
||||
SysUtils, LResources, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
|
@ -281,66 +281,80 @@ type
|
||||
TCustomListView = class; //forward declaration!
|
||||
TSortType = (stNone, stData, stText, stBoth);
|
||||
|
||||
TListItemState = (lisCut, lisDropTarget, lisFocused, lisSelected);
|
||||
TListItemStates = set of TListItemState;
|
||||
|
||||
TListItem = class(TPersistent)
|
||||
private
|
||||
FOwner: TListItems;
|
||||
FSubItems: TStrings;
|
||||
//FIndex : Integer;
|
||||
FCaption: String;
|
||||
FData: Pointer;
|
||||
FImageIndex: Integer;
|
||||
FDestroying: Boolean;
|
||||
FState:byte;//by VVI - for state (currently Selected) accumulating
|
||||
function GetState(const AnIndex: Integer): Boolean;
|
||||
procedure SetState(const AnIndex: Integer; const AState: Boolean);
|
||||
FStates: TListItemStates;
|
||||
function GetState(const ALisOrd: Integer): Boolean;
|
||||
function GetIndex : Integer;
|
||||
function GetSubItemImages(const AIndex: Integer): Integer;
|
||||
function GetSubItems: TStrings;
|
||||
|
||||
function IntfUpdateAllowed: Boolean;
|
||||
procedure IntfUpdateText;
|
||||
procedure IntfUpdateImages;
|
||||
|
||||
procedure SetState(const ALisOrd: Integer; const AIsSet: Boolean);
|
||||
procedure SetSubItemImages(const AIndex, AValue: Integer);
|
||||
procedure SetData(const AValue: Pointer);
|
||||
procedure SetImageIndex(const AValue: Integer);
|
||||
procedure SetCaption(const AValue : String);
|
||||
// Procedure SetSubItems(Value : TStrings);
|
||||
function GetIndex : Integer;
|
||||
function GetSubItemImages(AnIndex: Integer): Integer;
|
||||
procedure SetSubItemImages(AnIndex: Integer; const AValue: Integer);
|
||||
procedure SetSubItems(const AValue: TStrings);
|
||||
protected
|
||||
Procedure ItemChanged(sender : TObject); //called by the onchange of the tstringlist in TListItem
|
||||
function IsEqual(Item : TListItem) : Boolean;
|
||||
function IsEqual(const AItem: TListItem): Boolean;
|
||||
public
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
constructor Create(AOwner : TListItems);
|
||||
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 Cut: Boolean index Ord(lisCut) read GetState write SetState;
|
||||
property Data: Pointer read FData write SetData;
|
||||
property DropTarget: Boolean index 1 read GetState write SetState;
|
||||
property Focused: Boolean index 2 read GetState write SetState;
|
||||
property DropTarget: Boolean index Ord(lisDropTarget) read GetState write SetState;
|
||||
property Focused: Boolean index Ord(lisFocused) read GetState write SetState;
|
||||
property Index: Integer read GetIndex;
|
||||
property ImageIndex : Integer read FImageIndex write SetImageIndex default -1;
|
||||
property Owner : TListItems read FOwner;
|
||||
property Selected: Boolean index 3 read GetState write SetState;
|
||||
property SubItems : TStrings read FSubItems write FSubItems;//SetSubItems;
|
||||
property SubItemImages[AnIndex: Integer]: Integer
|
||||
property ImageIndex: Integer read FImageIndex write SetImageIndex default -1;
|
||||
property Owner: TListItems read FOwner;
|
||||
property Selected: Boolean index Ord(lisSelected) read GetState write SetState;
|
||||
property SubItems: TStrings read GetSubItems write SetSubItems;
|
||||
property SubItemImages[const AIndex: Integer]: Integer
|
||||
read GetSubItemImages write SetSubItemImages;
|
||||
end;
|
||||
|
||||
|
||||
{ TListItems }
|
||||
{
|
||||
Listitems have a build in cache of the last accessed item.
|
||||
This will speed up interface updates since Item.Index is
|
||||
often used for the same item updating more properties.
|
||||
If FCacheIndex = -1 then the cache is not valid.
|
||||
}
|
||||
|
||||
TListItems = class(TPersistent)
|
||||
private
|
||||
FOwner: TCustomListView;
|
||||
FItems: TList;
|
||||
function GetCount : Integer;
|
||||
FItems: TList;
|
||||
FCacheIndex: Integer; // Caches the last used item
|
||||
FCacheItem: TListItem; //
|
||||
procedure ItemDeleted(const AItem: TListItem); //called by TListItem when freed
|
||||
protected
|
||||
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
|
||||
|
||||
procedure DefineProperties(Filer: TFiler); override;
|
||||
procedure ReadData(Stream: TStream);
|
||||
procedure WriteData(Stream: TStream);
|
||||
|
||||
protected
|
||||
procedure DefineProperties(Filer: TFiler); override;
|
||||
function GetCount : Integer;
|
||||
function GetItem(const AIndex: Integer): TListItem;
|
||||
function IndexOf(const AItem: TListItem): Integer;
|
||||
procedure SetITem(const AIndex: Integer; const AValue: TListItem);
|
||||
public
|
||||
function Add: TListItem;
|
||||
procedure AddItem(AItem: TListItem);
|
||||
@ -370,8 +384,10 @@ type
|
||||
FMaxWidth: TWidth;
|
||||
FVisible: Boolean;
|
||||
FWidth: TWidth;
|
||||
FImageIndex: Integer;
|
||||
FTag: Integer;
|
||||
function GetWidth: TWidth;
|
||||
function IntfUpdateAllowed: Boolean;
|
||||
procedure SetVisible(const AValue: Boolean);
|
||||
procedure SetAutoSize(const AValue: Boolean);
|
||||
procedure SetMinWidth(const AValue: TWidth);
|
||||
@ -379,9 +395,9 @@ type
|
||||
procedure SetWidth(const AValue: TWidth);
|
||||
procedure SetCaption(const AValue: String);
|
||||
procedure SetAlignment(const AValue: TAlignment);
|
||||
// procedure SetImageIndex(const AValue: TImageIndex);
|
||||
procedure SetImageIndex(const AValue: TImageIndex);
|
||||
protected
|
||||
// procedure SetIndex(const AValue: Integer); override;
|
||||
procedure SetIndex(AValue: Integer); override;
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
destructor Destroy; override;
|
||||
@ -390,7 +406,7 @@ type
|
||||
property Alignment: TAlignment read FAlignment write SetAlignment;
|
||||
property AutoSize: Boolean read FAutoSize write SetAutoSize;
|
||||
property Caption: string read FCaption write SetCaption;
|
||||
// property ImageIndex: TImageIndex read FImageIndex write SetImageIndex;
|
||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex;
|
||||
property MaxWidth: TWidth read FMaxWidth write SetMaxWidth;
|
||||
property MinWidth: TWidth read FMinWidth write SetMinWidth;
|
||||
property Tag: Integer read FTag write FTag;
|
||||
@ -489,10 +505,11 @@ type
|
||||
procedure UpdateProperties;
|
||||
protected
|
||||
//called by TListItems
|
||||
procedure ItemChanged(const AItem: TListItem; const AIndex : Integer);
|
||||
procedure ItemDeleted(const AIndex: Integer);
|
||||
procedure ItemInserted(const AItem: TListItem; const AIndex: Integer);
|
||||
|
||||
//called by TListColumns
|
||||
procedure ColumnsChanged;
|
||||
protected
|
||||
procedure InitializeWnd; override;
|
||||
procedure Loaded; override;
|
||||
@ -505,7 +522,6 @@ type
|
||||
procedure InsertItem(Item : TListItem);
|
||||
function GetMaxScrolledLeft : Integer;
|
||||
function GetMaxScrolledTop : Integer;
|
||||
procedure ColumnsChanged; //called by TListColumns
|
||||
procedure ImageChanged(Sender : TObject);
|
||||
procedure WMHScroll(var Msg: TLMScroll); message LM_HSCROLL;
|
||||
procedure WMVScroll(var Msg: TLMScroll); message LM_VSCROLL;
|
||||
@ -2282,6 +2298,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.136 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.135 2004/07/11 13:03:53 mattias
|
||||
extended RolesForForm to manage multiple roles for on control
|
||||
|
||||
|
@ -170,7 +170,7 @@ begin
|
||||
inherited InitializeWnd;
|
||||
CNSendMessage(LM_SETPROPERTIES,Self,nil);
|
||||
if FSelected <> nil
|
||||
then TWSCustomListViewClass(WidgetSetClass).SelectItem(Self, FSelected);
|
||||
then TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index, FSelected, lisSelected, True);
|
||||
end;
|
||||
|
||||
procedure TCustomListView.Loaded;
|
||||
@ -196,21 +196,6 @@ begin
|
||||
if Assigned(FOnSelectItem) then FOnSelectItem(Self, AItem, ASelected);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ItemChanged }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.ItemChanged(const AItem: TListItem; const AIndex: Integer); //called by TListItems
|
||||
Begin
|
||||
if csDestroying in Componentstate Then Exit;
|
||||
if FUpdateCount>0 then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).ChangeItem(Self, AIndex, AItem);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ItemDeleted }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -224,7 +209,7 @@ begin
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then Exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).DeleteItem(Self, AIndex);
|
||||
TWSCustomListViewClass(WidgetSetClass).ItemDelete(Self, AIndex);
|
||||
end;
|
||||
End;
|
||||
|
||||
@ -240,7 +225,7 @@ begin
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then Exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).InsertItem(Self, AIndex, AItem);
|
||||
TWSCustomListViewClass(WidgetSetClass).ItemInsert(Self, AIndex, AItem);
|
||||
end;
|
||||
End;
|
||||
|
||||
@ -257,7 +242,7 @@ end;
|
||||
procedure TCustomListView.SetItemVisible(const AValue : TListItem);
|
||||
begin
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).ShowItem(Self, AValue);
|
||||
TWSCustomListViewClass(WidgetSetClass).ItemShow(Self, AValue.Index, AValue);
|
||||
end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView Delete }
|
||||
@ -363,9 +348,15 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
destructor TCustomListView.Destroy;
|
||||
begin
|
||||
FreeThenNil(FColumns);
|
||||
FreeThenNil(FImageChangeLink);
|
||||
FreeThenNil(FListItems);
|
||||
{$IFDEF VER1_0}
|
||||
// we need the csDestroying flag.
|
||||
// FPC 1.0.x doesnt call BeforeDestruction
|
||||
BeforeDestruction;
|
||||
{$ENDIF}
|
||||
|
||||
FreeAndNil(FColumns);
|
||||
FreeAndNil(FImageChangeLink);
|
||||
FreeAndNil(FListItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -416,9 +407,7 @@ begin
|
||||
FSelected := AValue;
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
|
||||
TWSCustomListViewClass(WidgetSetClass).SelectItem(Self, FSelected);
|
||||
|
||||
//DoSelectItem(FSelected, True);
|
||||
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index, FSelected, lisSelected, True);
|
||||
end;
|
||||
|
||||
procedure TCustomListView.SetMultiSelect(const AValue: Boolean);
|
||||
@ -620,6 +609,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.38 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.37 2004/05/21 18:12:17 mattias
|
||||
quick fixed crashing property overloading BorderStyle
|
||||
|
||||
|
@ -39,8 +39,10 @@ begin
|
||||
end;
|
||||
|
||||
constructor TListColumn.Create(ACollection: TCollection);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
inherited Create(ACollection);
|
||||
FAlignment := taLeftJustify;
|
||||
FCaption := '';
|
||||
FWidth := 50;
|
||||
@ -49,85 +51,222 @@ begin
|
||||
FMaxWidth := 0;
|
||||
FAutoSize := False;
|
||||
FTag := 0;
|
||||
Changed(False);
|
||||
FImageIndex := -1;
|
||||
inherited Create(ACollection);
|
||||
|
||||
// MWE: I don't think a changed is needed here
|
||||
//Changed(False);
|
||||
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnInsert(LV, Index, Self);
|
||||
WSC.ColumnSetAlignment(LV, Index, Self, FAlignment);
|
||||
WSC.ColumnSetAutosize(LV, Index, Self, FAutosize);
|
||||
WSC.ColumnSetCaption(LV, Index, Self, FCaption);
|
||||
WSC.ColumnSetMaxWidth(LV, Index, Self, FMaxWidth);
|
||||
WSC.ColumnSetMinWidth(LV, Index, Self, FMinWidth);
|
||||
WSC.ColumnSetWidth(LV, Index, Self, FWidth);
|
||||
WSC.ColumnSetImage(LV, Index, Self, FImageIndex);
|
||||
WSC.ColumnSetVisible(LV, Index, Self, FVisible);
|
||||
end;
|
||||
|
||||
destructor TListColumn.Destroy;
|
||||
var
|
||||
Columns: TListColumns;
|
||||
idx: Integer;
|
||||
UpdAllowed: Boolean;
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if (Collection<>nil) and (Collection is TListColumns) then begin
|
||||
idx := Index;
|
||||
UpdAllowed := IntfUpdateAllowed;
|
||||
|
||||
if Collection is TListColumns
|
||||
then begin
|
||||
Columns:=TListColumns(Collection);
|
||||
if Columns.FItemNeedsUpdate=Self then Columns.FItemNeedsUpdate:=nil;
|
||||
end;
|
||||
end;
|
||||
inherited Destroy;
|
||||
Changed(False);
|
||||
|
||||
// MWE: I don't think a changed is needed here
|
||||
//Changed(False);
|
||||
|
||||
if not UpdAllowed then Exit;
|
||||
|
||||
LV := Columns.FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnDelete(LV, Idx);
|
||||
end;
|
||||
|
||||
function TListColumn.IntfUpdateAllowed: Boolean;
|
||||
begin
|
||||
Result := (Collection <> nil)
|
||||
and (TListColumns(Collection).FOwner <> nil)
|
||||
and TListColumns(Collection).FOwner.HandleAllocated
|
||||
and not (csDestroying in TListColumns(Collection).FOwner.ComponentState);
|
||||
end;
|
||||
|
||||
function TListColumn.GetWidth: TWidth;
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
// TODO: read actual width
|
||||
Result := FWidth;
|
||||
if IntfUpdateAllowed
|
||||
then begin
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
Result := WSC.ColumnGetWidth(LV, Index, Self);
|
||||
if Result < 0
|
||||
then Result := FWidth;
|
||||
end
|
||||
else Result := FWidth;
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetAlignment(const AValue: TAlignment);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FAlignment = AValue then Exit;
|
||||
|
||||
FAlignment := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetAlignment(LV, Index, Self, FAlignment);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetCaption(const AValue: String);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if AValue = FCaption then Exit;
|
||||
FCaption := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetCaption(LV, Index, Self, FCaption);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetWidth(const AValue: TWidth);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FWidth = AValue then Exit;
|
||||
|
||||
FWidth := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetWidth(LV, Index, Self, FWidth);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetMaxWidth(const AValue: TWidth);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FMaxWidth = AValue then Exit;
|
||||
|
||||
FMaxWidth := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetMaxWidth(LV, Index, Self, FMaxWidth);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetMinWidth(const AValue: TWidth);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FMinWidth = AValue then Exit;
|
||||
|
||||
FMinWidth := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetMinWidth(LV, Index, Self, FMinWidth);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetAutoSize(const AValue: Boolean);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FAutoSize = AValue then Exit;
|
||||
|
||||
FAutoSize := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetAutosize(LV, Index, Self, FAutosize);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetImageIndex(const AValue: TImageIndex);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FImageIndex = AValue then Exit;
|
||||
FImageIndex := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetImage(LV, Index, Self, FImageIndex);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetIndex(AValue: Integer);
|
||||
var
|
||||
OldIndex: Integer;
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
OldIndex := Index;
|
||||
inherited;
|
||||
|
||||
if OldIndex = Index then Exit;
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnMove(LV, OldIndex, Index, Self);
|
||||
end;
|
||||
|
||||
procedure TListColumn.SetVisible(const AValue: Boolean);
|
||||
var
|
||||
LV: TCustomListView;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if FVisible = AValue then Exit;
|
||||
|
||||
FVisible := AValue;
|
||||
Changed(False);
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
|
||||
LV := TListColumns(Collection).FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
WSC.ColumnSetVisible(LV, Index, Self, FVisible);
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.8 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.7 2004/04/10 17:58:57 mattias
|
||||
implemented mainunit hints for include files
|
||||
|
||||
|
@ -93,6 +93,7 @@ end;
|
||||
|
||||
procedure TListColumns.Update(AnItem: TCollectionItem);
|
||||
begin
|
||||
(*
|
||||
if FUpdateCount>0 then begin
|
||||
FNeedsUpdate:=true;
|
||||
if FItemNeedsUpdate=nil then
|
||||
@ -108,6 +109,7 @@ begin
|
||||
// always recreating window
|
||||
if FOwner <>nil then
|
||||
FOwner.ColumnsChanged;
|
||||
*)
|
||||
end;
|
||||
|
||||
// included by comctrls.pp
|
||||
@ -115,6 +117,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.9 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.8 2004/04/10 17:58:57 mattias
|
||||
implemented mainunit hints for include files
|
||||
|
||||
|
@ -14,18 +14,285 @@
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
{==============================================================================}
|
||||
(*
|
||||
* TListItemSubItems is a helper class to notify only changed subitems to the IF
|
||||
*)
|
||||
{==============================================================================}
|
||||
type
|
||||
TSubItemUpdate = (siuText, siuImage);
|
||||
|
||||
TListItemSubItems = class(TStringList)
|
||||
private
|
||||
FChangeIndex: Integer;
|
||||
FOwner: TListItem;
|
||||
FUpdate: set of TSubItemUpdate;
|
||||
function GetImageIndex(const AIndex: Integer): Integer;
|
||||
procedure SetImageIndex(const AIndex, AValue: Integer);
|
||||
protected
|
||||
procedure Changed; override;
|
||||
function GetObject(AIndex: Integer): TObject; override;
|
||||
procedure Put(AIndex: Integer; const S: string); override;
|
||||
procedure PutObject(AIndex: Integer; AObject: TObject); override;
|
||||
public
|
||||
function Add(const S: string): Integer; override;
|
||||
procedure Clear; override;
|
||||
constructor Create(const AOwner: TListItem);
|
||||
procedure Delete(AIndex: Integer); override;
|
||||
procedure Insert(AIndex: Integer; const S: string); override;
|
||||
property ImageIndex[const AIndex: Integer]: Integer read GetImageIndex write SetImageIndex;
|
||||
end;
|
||||
|
||||
PListItemImageObject = ^ TListItemImageObject;
|
||||
TListItemImageObject = record
|
||||
FImage: Integer;
|
||||
FObject: TObject;
|
||||
end;
|
||||
|
||||
{ TListItemSubItems }
|
||||
|
||||
function TListItemSubItems.Add(const S: string): Integer;
|
||||
begin
|
||||
FChangeIndex := Count;
|
||||
FUpdate := [siuText];
|
||||
try
|
||||
Result := inherited Add(S);
|
||||
finally
|
||||
FUpdate := [];
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.Changed;
|
||||
var
|
||||
LV: TCustomListView;
|
||||
n, Idx, Cnt, ColCnt: Integer;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
if (FOwner <> nil)
|
||||
and FOwner.IntfUpdateAllowed
|
||||
and ((FChangeIndex = -1) or (FUpdate <> []))
|
||||
then begin
|
||||
LV := FOwner.FOwner.FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
idx := FOwner.GetIndex;
|
||||
|
||||
if FChangeIndex = -1
|
||||
then begin
|
||||
// We don't know what changed, so update all
|
||||
ColCnt := LV.Columns.Count - 1; // skip main column
|
||||
if ColCnt > 0
|
||||
then begin
|
||||
Cnt := Count;
|
||||
if Cnt > ColCnt then Cnt := ColCnt;
|
||||
|
||||
// set text
|
||||
for n := 0 to Cnt - 1 do
|
||||
WSC.ItemSetText(LV, idx, FOwner, n + 1, Get(n));
|
||||
// whipe others
|
||||
for n := Cnt to ColCnt - 1 do
|
||||
WSC.ItemSetText(LV, idx, FOwner, n + 1, '');
|
||||
// set image
|
||||
for n := 0 to Cnt - 1 do
|
||||
WSC.ItemSetImage(LV, idx, FOwner, n + 1, GetImageIndex(n));
|
||||
// whipe others
|
||||
for n := Cnt to ColCnt - 1 do
|
||||
WSC.ItemSetImage(LV, idx, FOwner, n + 1, -1);
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
if siuText in FUpdate
|
||||
then begin
|
||||
if (FChangeIndex >= 0) and (FChangeIndex < Count)
|
||||
then WSC.ItemSetText(LV, idx, FOwner, FChangeIndex + 1, Get(FChangeIndex))
|
||||
else WSC.ItemSetText(LV, idx, FOwner, FChangeIndex + 1, '');
|
||||
end;
|
||||
|
||||
if siuImage in FUpdate
|
||||
then begin
|
||||
if (FChangeIndex >= 0) and (FChangeIndex < Count)
|
||||
then WSC.ItemSetImage(LV, idx, FOwner, FChangeIndex + 1, GetImageIndex(FChangeIndex))
|
||||
else WSC.ItemSetImage(LV, idx, FOwner, FChangeIndex + 1, -1);
|
||||
end
|
||||
end;
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.Clear;
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
for n := 0 to Count - 1 do
|
||||
Dispose(PListItemImageObject(inherited GetObject(n)));
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
constructor TListItemSubItems.Create(const AOwner: TListItem);
|
||||
begin
|
||||
inherited Create;
|
||||
FOwner := AOwner;
|
||||
FChangeIndex := -1;
|
||||
FUpdate := [];
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.Delete(AIndex: Integer);
|
||||
begin
|
||||
if AIndex = Count
|
||||
then FChangeIndex := AIndex
|
||||
else FChangeIndex := -1;
|
||||
FUpdate := [siuText, siuImage];
|
||||
try
|
||||
Dispose(PListItemImageObject(inherited GetObject(AIndex)));
|
||||
inherited;
|
||||
finally
|
||||
FUpdate := [];
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TListItemSubItems.GetImageIndex(const AIndex: Integer): Integer;
|
||||
var
|
||||
io: PListItemImageObject;
|
||||
begin
|
||||
io := PListItemImageObject(inherited GetObject(AIndex));
|
||||
if io = nil
|
||||
then Result := -1
|
||||
else Result := io^.FImage;
|
||||
end;
|
||||
|
||||
function TListItemSubItems.GetObject(AIndex: Integer): TObject;
|
||||
var
|
||||
io: PListItemImageObject;
|
||||
begin
|
||||
io := PListItemImageObject(inherited GetObject(AIndex));
|
||||
if io = nil
|
||||
then Result := nil
|
||||
else Result := io^.FObject;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.Insert(AIndex: Integer; const S: string);
|
||||
begin
|
||||
if AIndex = Count
|
||||
then FChangeIndex := AIndex
|
||||
else FChangeIndex := -1;
|
||||
FUpdate := [siuText];
|
||||
try
|
||||
inherited;
|
||||
finally
|
||||
FUpdate := [];
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.Put(AIndex: Integer; const S: string);
|
||||
begin
|
||||
FChangeIndex := AIndex;
|
||||
FUpdate := [siuText];
|
||||
try
|
||||
inherited;
|
||||
finally
|
||||
FUpdate := [];
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.PutObject(AIndex: Integer; AObject: TObject);
|
||||
var
|
||||
io: PListItemImageObject;
|
||||
begin
|
||||
io := PListItemImageObject(inherited GetObject(AIndex));
|
||||
if (io = nil) and (AObject <> nil)
|
||||
then begin
|
||||
New(io);
|
||||
io^.FImage := -1;
|
||||
end;
|
||||
|
||||
if io <> nil
|
||||
then begin
|
||||
if (AObject = nil) and (io^.FImage = -1)
|
||||
then begin
|
||||
Dispose(io);
|
||||
io := nil;
|
||||
end
|
||||
else io^.FObject := AObject;
|
||||
end;
|
||||
|
||||
FChangeIndex := AIndex;
|
||||
FUpdate := [];
|
||||
try
|
||||
inherited PutObject(AIndex, TObject(io));
|
||||
finally
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TListItemSubItems.SetImageIndex(const AIndex, AValue: Integer);
|
||||
var
|
||||
io: PListItemImageObject;
|
||||
begin
|
||||
io := PListItemImageObject(inherited GetObject(AIndex));
|
||||
if (io = nil) and (AValue >= 0)
|
||||
then begin
|
||||
New(io);
|
||||
io^.FObject := nil;
|
||||
end;
|
||||
|
||||
if io <> nil
|
||||
then begin
|
||||
if (AValue < 0) and (io^.FObject = nil)
|
||||
then begin
|
||||
Dispose(io);
|
||||
io := nil;
|
||||
end
|
||||
else begin
|
||||
if AValue < 0
|
||||
then io^.FImage := -1
|
||||
else io^.FImage := AValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
FChangeIndex := AIndex;
|
||||
FUpdate := [siuImage];
|
||||
try
|
||||
inherited PutObject(AIndex, TObject(io));
|
||||
finally
|
||||
FUpdate := [];
|
||||
FChangeIndex := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
{==============================================================================}
|
||||
{==============================================================================}
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem.Assign }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.Assign(ASource: TPersistent);
|
||||
begin
|
||||
if ASource is TListItem
|
||||
then begin
|
||||
Caption := TListItem(ASource).Caption;
|
||||
Data := TListItem(ASource).Data;
|
||||
ImageIndex := TListItem(ASource).ImageIndex;
|
||||
SubItems := TListItem(ASource).SubItems;
|
||||
end
|
||||
else inherited Assign(ASource);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem Constructor }
|
||||
{ TListItem Constructor }
|
||||
{------------------------------------------------------------------------------}
|
||||
constructor TListItem.Create(AOwner : TListItems);
|
||||
begin
|
||||
Inherited Create;
|
||||
inherited Create;
|
||||
FOwner := AOwner;
|
||||
FSubItems := TStringList.Create;
|
||||
TStringList(FSubItems).OnChange := @ItemChanged;
|
||||
FDestroying := False;
|
||||
FState:=0;
|
||||
FStates := [];
|
||||
FImageIndex := -1;
|
||||
FSubItems := nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -33,12 +300,14 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetCaption(const AValue : String);
|
||||
begin
|
||||
if FCaption = AValue then Exit;
|
||||
FCaption := AValue;
|
||||
FOwner.ItemChanged(self);
|
||||
if IntfUpdateAllowed
|
||||
then TWSCustomListViewClass(FOwner.FOwner.WidgetSetClass).ItemSetText(FOwner.FOwner, GetIndex, Self, 0, FCaption);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetData }
|
||||
{ TListItem SetData }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetData(const AValue: Pointer);
|
||||
begin
|
||||
@ -51,19 +320,9 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.GetIndex : Integer;
|
||||
begin
|
||||
if Assigned(FOwner) then
|
||||
Result := FOwner.FItems.IndexOf(self)
|
||||
else
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetSubItemImages }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetSubItemImages(AnIndex: Integer; const AValue: Integer);
|
||||
begin
|
||||
if (AnIndex >= 0) and (AnIndex < SubItems.Count) then
|
||||
SubItems.Objects[AnIndex] := TObject(Pointer(aValue));
|
||||
if Assigned(FOwner)
|
||||
then Result := FOwner.IndexOf(self)
|
||||
else Result := -1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -74,20 +333,91 @@ begin
|
||||
if not FDestroying then Free;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem ItemChanged }
|
||||
{ TListItem IntfUpdateText }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.ItemChanged(sender : TObject);
|
||||
procedure TListItem.IntfUpdateText;
|
||||
var
|
||||
LV: TCustomListView;
|
||||
n, Idx, Cnt, ColCnt: Integer;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
FOwner.ItemChanged(self);
|
||||
LV := FOwner.FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
idx := GetIndex;
|
||||
|
||||
WSC.ItemSetText(LV, idx, Self, 0, FCaption);
|
||||
|
||||
ColCnt := LV.Columns.Count - 1; // skip main column
|
||||
if ColCnt > 0
|
||||
then begin
|
||||
if FSubItems = nil
|
||||
then Cnt := 0
|
||||
else Cnt := FSubItems.Count;
|
||||
if Cnt > ColCnt then Cnt := ColCnt;
|
||||
|
||||
// set text
|
||||
for n := 0 to Cnt - 1 do
|
||||
WSC.ItemSetText(LV, idx, Self, n + 1, FSubItems[n]);
|
||||
// whipe others
|
||||
for n := Cnt to ColCnt - 1 do
|
||||
WSC.ItemSetText(LV, idx, Self, n + 1, '');
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem IntfUpdateImages }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.IntfUpdateImages;
|
||||
var
|
||||
LV: TCustomListView;
|
||||
n, Idx, Cnt, ColCnt: Integer;
|
||||
WSC: TWSCustomListViewClass;
|
||||
begin
|
||||
LV := FOwner.FOwner;
|
||||
WSC := TWSCustomListViewClass(LV.WidgetSetClass);
|
||||
idx := GetIndex;
|
||||
|
||||
WSC.ItemSetImage(LV, idx, Self, 0, FImageIndex);
|
||||
|
||||
ColCnt := LV.Columns.Count - 1; // skip main column
|
||||
if ColCnt > 0
|
||||
then begin
|
||||
if FSubItems = nil
|
||||
then Cnt := 0
|
||||
else Cnt := FSubItems.Count;
|
||||
if Cnt > ColCnt then Cnt := ColCnt;
|
||||
|
||||
// set image
|
||||
for n := 0 to Cnt - 1 do
|
||||
WSC.ItemSetImage(LV, idx, Self, n + 1, TListItemSubItems(FSubItems).ImageIndex[n]);
|
||||
// whipe others
|
||||
for n := Cnt to ColCnt - 1 do
|
||||
WSC.ItemSetImage(LV, idx, Self, n + 1, -1);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem IntfUpdateAllowed }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.IntfUpdateAllowed: Boolean;
|
||||
begin
|
||||
Result := not FDestroying
|
||||
and (FOwner <> nil)
|
||||
and (FOwner.FOwner <> nil)
|
||||
and FOwner.FOwner.HandleAllocated
|
||||
and not (csDestroying in FOwner.FOwner.ComponentState);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem IsEqual }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.IsEqual(Item: TListItem): Boolean;
|
||||
function TListItem.IsEqual(const AItem: TListItem): Boolean;
|
||||
begin
|
||||
Result:=(Caption = Item.Caption) and (Data = Item.Data);
|
||||
Result := (Caption = AItem.Caption)
|
||||
and (Data = AItem.Data)
|
||||
and (FStates = AItem.FStates);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -99,7 +429,7 @@ begin
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemDeleted(Self);
|
||||
|
||||
FreeThenNil(FSubItems);
|
||||
FreeAndNil(FSubItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -108,56 +438,106 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetImageIndex(const AValue: Integer);
|
||||
begin
|
||||
if AValue <> FImageIndex then
|
||||
Begin
|
||||
FImageIndex := AValue;
|
||||
ItemChanged(Self);
|
||||
end;
|
||||
if AValue = FImageIndex then Exit;
|
||||
|
||||
FImageIndex := AValue;
|
||||
|
||||
if IntfUpdateAllowed
|
||||
then TWSCustomListViewClass(FOwner.FOwner.WidgetSetClass).ItemSetImage(FOwner.FOwner, GetIndex, Self, 0, FImageIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem GetState }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.GetState(const AnIndex: Integer): Boolean;
|
||||
function TListItem.GetState(const ALisOrd: Integer): Boolean;
|
||||
var
|
||||
AState: TListItemState;
|
||||
begin
|
||||
Result := ((FState AND (1 shl AnIndex))<>0);
|
||||
AState := TListItemState(ALisOrd);
|
||||
|
||||
if IntfUpdateAllowed
|
||||
and TWSCustomListViewClass(FOwner.FOwner.WidgetSetClass).ItemGetState(FOwner.FOwner, GetIndex, Self, AState, Result)
|
||||
then begin
|
||||
// update FStates
|
||||
if Result
|
||||
then Include(FStates, AState)
|
||||
else Exclude(FStates, AState);
|
||||
end
|
||||
else Result := AState in FStates;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem GetSubItemImages }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.GetSubItemImages(ANIndex: Integer): Integer;
|
||||
function TListItem.GetSubItemImages(const AIndex: Integer): Integer;
|
||||
begin
|
||||
if (AnIndex >= 0) and (AnIndex < SubItems.Count) then
|
||||
Result := Integer(SubItems.Objects[AnIndex])
|
||||
else
|
||||
Result := -1;
|
||||
Result := TListItemSubItems(SubItems).ImageIndex[AIndex];
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem GetSubItems }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItem.GetSubItems: TStrings;
|
||||
begin
|
||||
if FSubItems = nil
|
||||
then FSubItems := TListItemSubItems.Create(Self);
|
||||
Result := FSubItems;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem MakeVisible }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.MakeVisible(PartialOK: Boolean);
|
||||
begin
|
||||
if FOwner <> nil then
|
||||
if FOwner.Fowner <> nil then
|
||||
FOwner.FOwner.SetItemVisible(Self);
|
||||
if (FOwner <> nil)
|
||||
and (FOwner.Fowner <> nil)
|
||||
then FOwner.FOwner.SetItemVisible(Self);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetState }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetState(const AnIndex: Integer; const AState: Boolean);
|
||||
procedure TListItem.SetState(const ALisOrd: Integer; const AIsSet: Boolean);
|
||||
var
|
||||
AState: TListItemState;
|
||||
LV: TCustomListView;
|
||||
begin
|
||||
if AState then
|
||||
FState:=FState or (1 shl AnIndex)
|
||||
else
|
||||
FState:=FState AND (not (1 shl AnIndex));
|
||||
AState := TListItemState(ALisOrd);
|
||||
|
||||
if (AState in FStates) = AIsSet then Exit;
|
||||
|
||||
if AIsSet
|
||||
then Include(FStates, AState)
|
||||
else Exclude(FStates, AState);
|
||||
|
||||
if not IntfUpdateAllowed then Exit;
|
||||
LV := FOwner.FOwner;
|
||||
TWSCustomListViewClass(LV.WidgetSetClass).ItemSetState(LV, GetIndex, Self, AState, AIsSet);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetSubItemImages }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetSubItemImages(const AIndex, AValue: Integer);
|
||||
begin
|
||||
TListItemSubItems(SubItems).ImageIndex[AIndex] := AValue;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItem SetSubItems }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItem.SetSubItems(const AValue: TStrings);
|
||||
begin
|
||||
if (AValue = nil) and (FSubItems = nil) then Exit;
|
||||
SubItems.Assign(AValue);
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.18 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.17 2004/04/10 17:58:57 mattias
|
||||
implemented mainunit hints for include files
|
||||
|
||||
|
@ -23,6 +23,7 @@ begin
|
||||
Inherited Create;
|
||||
FItems := TList.Create;
|
||||
FOwner := AOwner;
|
||||
FCacheIndex := -1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -38,25 +39,48 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.GetItem(const AIndex: Integer): TListItem;
|
||||
begin
|
||||
if (FCacheIndex <> -1) and (FCacheIndex = AIndex)
|
||||
then begin
|
||||
Result := FCacheItem;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if FItems.Count - 1 < AIndex
|
||||
then Result := nil
|
||||
else Result := TListItem(FItems.Items[AIndex]);
|
||||
else begin
|
||||
Result := TListItem(FItems.Items[AIndex]);
|
||||
FCacheItem := Result;
|
||||
FCacheIndex := AIndex;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems SetItem }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItems.SetItem(const AIndex: Integer; const AValue: TListItem);
|
||||
var
|
||||
OldItem: TListItem;
|
||||
begin
|
||||
if FItems.Count - 1 < AIndex then Exit;
|
||||
|
||||
OldItem := GetItem(AIndex);
|
||||
if OldItem = AValue then Exit;
|
||||
|
||||
FItems.Items[AIndex] := AValue;
|
||||
FOwner.ItemChanged(AValue, AIndex);
|
||||
FCacheIndex := AIndex;
|
||||
FCacheItem := AValue;
|
||||
|
||||
if AValue.IntfUpdateAllowed
|
||||
then begin
|
||||
AValue.IntfUpdateText;
|
||||
AValue.IntfUpdateImages;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems Add }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.Add:TListItem;
|
||||
function TListItems.Add: TListItem;
|
||||
begin
|
||||
Result := TListItem.Create(self);
|
||||
AddItem(Result);
|
||||
@ -67,18 +91,20 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItems.AddItem(AItem: TListItem);
|
||||
begin
|
||||
FItems.Add(AItem);
|
||||
FCacheIndex := FItems.Add(AItem);
|
||||
FCacheItem := AItem;
|
||||
|
||||
//Notify parent TListView that something was added.
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemInserted(AItem, -1);
|
||||
then FOwner.ItemInserted(AItem, FCacheIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TListItems Delete
|
||||
TListItems Clear
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TListItems.Clear;
|
||||
begin
|
||||
while Count>0 do Delete(Count-1);
|
||||
while Count > 0 do Delete(Count-1);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -99,9 +125,30 @@ begin
|
||||
idx := FItems.IndexOf(AItem);
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemDeleted(idx);
|
||||
if FCacheIndex = idx
|
||||
then FCacheIndex := -1;
|
||||
FItems.Remove(AItem);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems IndexOf }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.IndexOf(const AItem: TListItem): Integer;
|
||||
begin
|
||||
if (FCacheIndex <> -1)
|
||||
and (FCacheItem = AItem)
|
||||
then begin
|
||||
Result := FCacheIndex;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
Result := FItems.IndexOf(AItem);
|
||||
if Result = -1 then Exit;
|
||||
|
||||
FCacheIndex := Result;
|
||||
FCacheItem := AItem;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems Insert }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -117,8 +164,12 @@ end;
|
||||
procedure TListItems.InsertItem(AItem: TListItem; const AIndex: Integer);
|
||||
begin
|
||||
FItems.Insert(AIndex, AItem);
|
||||
FCacheIndex := AIndex;
|
||||
FCacheItem := AItem;
|
||||
|
||||
//Notify parent TListView that something was added.
|
||||
FOwner.ItemInserted(AItem, AIndex);
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemInserted(AItem, AIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -126,41 +177,49 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
destructor TListItems.Destroy;
|
||||
begin
|
||||
while FItems.Count>0 do
|
||||
TListItem(FItems[0]).Free;
|
||||
FreeThenNil(FItems);
|
||||
FCacheIndex := 0;
|
||||
while FItems.Count > 0 do
|
||||
begin
|
||||
FCacheItem := TListItem(FItems[0]);
|
||||
FCacheItem.Free;
|
||||
end;
|
||||
FCacheIndex := -1;
|
||||
FreeAndNil(FItems);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems FindData }
|
||||
{ TListItems FindData }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.FindData(const AData: Pointer): TListItem;
|
||||
var
|
||||
n: Integer;
|
||||
begin
|
||||
if (FCacheIndex <> -1)
|
||||
and (FCacheItem <> nil)
|
||||
and (FCacheItem.Data = AData)
|
||||
then begin
|
||||
Result := FCacheItem;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
for n := 0 to FItems.Count - 1 do
|
||||
begin
|
||||
Result := TListItem(FItems[n]);
|
||||
if Result.Data = AData then Exit;
|
||||
if Result.Data = AData
|
||||
then begin
|
||||
FCacheIndex := n;
|
||||
FCacheItem := Result;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TListItems ItemChanged }
|
||||
{ TListItems DefineProperties }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TListItems.ItemChanged(Sender : TObject); //called by the onchange of the tstringlist in TListItem
|
||||
var
|
||||
idx : Integer;
|
||||
begin
|
||||
idx := FItems.IndexOf(sender);
|
||||
if idx >= 0
|
||||
then FOwner.ItemChanged(TListItem(Sender), idx)
|
||||
else DebugLN('TListItems.ItemChanged for unknown item');
|
||||
end;
|
||||
|
||||
procedure TListItems.DefineProperties(Filer: TFiler);
|
||||
|
||||
function WriteItems: Boolean;
|
||||
@ -186,7 +245,7 @@ procedure TListItems.DefineProperties(Filer: TFiler);
|
||||
|
||||
begin
|
||||
inherited DefineProperties(Filer);
|
||||
Filer.DefineBinaryProperty('Data', @ReadData, @WriteData,WriteItems);
|
||||
Filer.DefineBinaryProperty('Data', @ReadData, @WriteData, WriteItems);
|
||||
end;
|
||||
|
||||
type
|
||||
@ -254,10 +313,13 @@ begin
|
||||
PInt := Pointer(PStr);
|
||||
for I := 0 to Count - 1 do
|
||||
begin
|
||||
for J := 0 to Item[I].SubItems.Count - 1 do
|
||||
begin
|
||||
Item[I].SubItemImages[J] := PInt^;
|
||||
Inc(PInt);
|
||||
if Item[I].FSubItems <> nil
|
||||
then begin
|
||||
for J := 0 to Item[I].SubItems.Count - 1 do
|
||||
begin
|
||||
Item[I].SubItemImages[J] := PInt^;
|
||||
Inc(PInt);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -349,6 +411,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.23 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.22 2004/06/28 23:16:24 mattias
|
||||
added TListView.AddItems from Andrew Haines
|
||||
|
||||
|
@ -991,11 +991,23 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TWinControl ReCreateWnd }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TWinControl.ReCreateWnd;
|
||||
Begin
|
||||
//send a message to inform the interface that we need to destroy and recreate this control
|
||||
if HandleAllocated then
|
||||
CNSendMessage(LM_RECREATEWND,Self,Nil);
|
||||
procedure TWinControl.ReCreateWnd;
|
||||
var
|
||||
IsFocused: Boolean;
|
||||
begin
|
||||
if csDestroying in ComponentState then Exit;
|
||||
|
||||
if not HandleAllocated
|
||||
then begin
|
||||
// since the interface should only call us, the handle is always created
|
||||
DebugLN('WARNING: obsolete call to RecreateWnd for %s', [ClassName]);
|
||||
end;
|
||||
|
||||
IsFocused := Focused;
|
||||
DestroyHandle;
|
||||
UpdateControlState;
|
||||
if IsFocused and HandleAllocated
|
||||
then LCLIntf.SetFocus(FHandle);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -3756,6 +3768,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.255 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.254 2004/07/10 18:17:30 mattias
|
||||
added Delphi ToDo support, Application.WndProc, small bugfixes from Colin
|
||||
|
||||
|
@ -2114,7 +2114,7 @@ begin
|
||||
GDK_VISUAL_DIRECT_COLOR: Desc^.Format:=ricfRGBA;
|
||||
else
|
||||
DebugLn('TGtkWidgetSet.GetWindowRawImageDescription unknown Visual type ',
|
||||
dbgs({$ifdef gtk2}Pointer{$endif gtk2}(Visual^.thetype)));
|
||||
dbgs(Integer(Visual^.thetype)));
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -9197,6 +9197,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.513 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.512 2004/07/05 15:48:31 mazen
|
||||
* fix compilation error with gtk2 platform
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
{ $Id$}
|
||||
{
|
||||
*****************************************************************************
|
||||
* GtkWSComCtrls.pp *
|
||||
* ---------------- *
|
||||
* GtkWSComCtrls.pp *
|
||||
* ---------------- *
|
||||
* *
|
||||
* *
|
||||
*****************************************************************************
|
||||
@ -29,13 +29,13 @@ interface
|
||||
uses
|
||||
// libs
|
||||
{$IFDEF GTK2}
|
||||
GLib2, Gtk2,
|
||||
GLib2, Gtk2, Gdk2,
|
||||
{$ELSE}
|
||||
GLib, Gtk, Gdk,
|
||||
{$ENDIF}
|
||||
// LCL
|
||||
ComCtrls, Classes, LCLType, LMessages, Controls, Graphics,
|
||||
LCLProc,
|
||||
LCLProc,
|
||||
// widgetset
|
||||
WSComCtrls, WSLCLClasses, WSProc,
|
||||
// interface
|
||||
@ -70,15 +70,32 @@ type
|
||||
{ TGtkWSCustomListView }
|
||||
|
||||
TGtkWSCustomListView = class(TWSCustomListView)
|
||||
{$IFDEF GTK1}
|
||||
private
|
||||
class procedure InternalChangeItem(const ACListWidget: PGtkCList; const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
class procedure ItemChangeInternal(const ACListWidget: PGtkCList; const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
protected
|
||||
public
|
||||
class procedure ChangeItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
class procedure DeleteItem(const ALV: TCustomListView; const AIndex: Integer); override;
|
||||
class procedure InsertItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
class procedure SelectItem(const ALV: TCustomListView; const AItem: TListItem); override;
|
||||
class procedure ShowItem(const ALV: TCustomListView; const AItem: TListItem); override;
|
||||
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
||||
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer; override;
|
||||
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
|
||||
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
|
||||
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment); override;
|
||||
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean); override;
|
||||
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String); override;
|
||||
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer); override;
|
||||
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer); override;
|
||||
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer); override;
|
||||
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer); override;
|
||||
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean); override;
|
||||
|
||||
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
||||
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean; override; // returns True if supported
|
||||
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
|
||||
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
|
||||
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
|
||||
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ TGtkWSListView }
|
||||
@ -154,77 +171,265 @@ type
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
SysUtils,
|
||||
GtkProc, GtkInt, GtkGlobals,
|
||||
GtkWSControls
|
||||
{$ifdef gtk2}
|
||||
, gdk2
|
||||
{$endif gtk2}
|
||||
;
|
||||
GtkWSControls;
|
||||
|
||||
const
|
||||
DEFAULT_IMAGE_SPACING = 3;
|
||||
|
||||
|
||||
{ TGtkWSCustomListView }
|
||||
|
||||
procedure TGtkWSCustomListView.ChangeItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ChangeItem')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
InternalChangeItem(CListWidget, ALV, AIndex, AItem);
|
||||
end;
|
||||
|
||||
|
||||
procedure TGtkWSCustomListView.DeleteItem(const ALV: TCustomListView; const AIndex: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'DeleteItem')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_remove(CListWidget, AIndex);
|
||||
end;
|
||||
|
||||
type
|
||||
type
|
||||
TLVHack = class(TCustomListView)
|
||||
{$IFDEF VER1_0}
|
||||
protected
|
||||
property MultiSelect;
|
||||
property SmallImages;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.InternalChangeItem(const ACListWidget: PGtkCList; const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
|
||||
{$IFDEF GTK1}
|
||||
procedure TGtkWSCustomListView.ColumnDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnDelete')
|
||||
then Exit;
|
||||
|
||||
TLVHack(ALV).RecreateWnd;
|
||||
end;
|
||||
|
||||
function TGtkWSCustomListView.ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer;
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
CListColumn: PGtkCListColumn;
|
||||
begin
|
||||
Result := -1;
|
||||
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnGetSize')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
// there is no get width function, so we need some internal hacking
|
||||
if AIndex >= CListWidget^.columns then Exit;
|
||||
CListColumn := CListWidget^.Column;
|
||||
Inc(CListColumn, AIndex);
|
||||
Result := CListColumn^.width;
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnInsert')
|
||||
then Exit;
|
||||
|
||||
TLVHack(ALV).RecreateWnd;
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
|
||||
procedure CopyColumn(const AList: PGtkCList; const AIndex: Integer; const ASrc: PGtkCListColumn);
|
||||
begin
|
||||
gtk_clist_set_column_title(AList, AIndex, ASrc^.title);
|
||||
gtk_clist_set_column_min_width(AList, AIndex, ASrc^.min_width);
|
||||
gtk_clist_set_column_max_width(AList, AIndex, ASrc^.max_width);
|
||||
gtk_clist_set_column_width(AList, AIndex, ASrc^.width);
|
||||
gtk_clist_set_column_justification(AList, AIndex, ASrc^.justification);
|
||||
gtk_clist_set_column_visibility(AList, AIndex, (ASrc^.flag0 and bm_TGtkCListColumn_visible) <> 0);
|
||||
gtk_clist_set_column_resizeable(AList, AIndex, (ASrc^.flag0 and bm_TGtkCListColumn_resizeable) <> 0);
|
||||
gtk_clist_set_column_auto_resize(AList, AIndex, (ASrc^.flag0 and bm_TGtkCListColumn_auto_resize) <> 0);
|
||||
if (ASrc^.flag0 and bm_TGtkCListColumn_button_passive) <> 0
|
||||
then gtk_clist_column_title_passive(AList, AIndex)
|
||||
else gtk_clist_column_title_active(AList, AIndex);
|
||||
end;
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
CListColumn: PGtkCListColumn;
|
||||
OldCListColumn: TGtkCListColumn;
|
||||
Count: Integer;
|
||||
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnMove')
|
||||
then Exit;
|
||||
|
||||
if AOldIndex = ANewIndex then Exit;
|
||||
if AOldIndex < 0 then Exit;
|
||||
if ANewIndex < 0 then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
if AOldIndex >= CListWidget^.columns then Exit;
|
||||
if ANewIndex >= CListWidget^.columns then Exit;
|
||||
|
||||
Count := AOldIndex - ANewIndex;
|
||||
|
||||
// Fetch old column values
|
||||
CListColumn := CListWidget^.Column;
|
||||
Inc(CListColumn, AOldIndex);
|
||||
OldCListColumn := CListColumn^;
|
||||
// Create copy of the title
|
||||
OldCListColumn.title := StrNew(OldCListColumn.title);
|
||||
|
||||
while Count <> 0 do
|
||||
begin
|
||||
// move to next source
|
||||
if Count < 0
|
||||
then Inc(CListColumn)
|
||||
else Dec(CListColumn);
|
||||
|
||||
CopyColumn(CListWidget, ANewIndex + Count, CListColumn);
|
||||
|
||||
if Count < 0
|
||||
then Inc(Count)
|
||||
else Dec(Count);
|
||||
end;
|
||||
// finally copy original data to new column
|
||||
CopyColumn(CListWidget, ANewIndex, @OldCListColumn);
|
||||
// dispose copy of the title
|
||||
StrDispose(OldCListColumn.title);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment);
|
||||
const
|
||||
JUSTIFICATION: array[TAlignment] of TGtkJustification = (
|
||||
GTK_JUSTIFY_LEFT,
|
||||
GTK_JUSTIFY_RIGHT,
|
||||
GTK_JUSTIFY_CENTER
|
||||
);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetAlignment')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_justification(CListWidget, AIndex, JUSTIFICATION[AAlignment]);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetAutoSize')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_auto_resize(CListWidget, AIndex, AAutoSize);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetCaption')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_title(CListWidget, AIndex, PChar(ACaption));
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetImage')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
//TODO
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetMaxWidth')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_max_width(CListWidget, AIndex, AMaxWidth);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetMinWidth')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_min_width(CListWidget, AIndex, AMinWidth);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetWidth')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_width(CListWidget, AIndex, AWidth);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetVisible')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_set_column_visibility(CListWidget, AIndex, AVisible);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ItemChangeInternal(const ACListWidget: PGtkCList; const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
var
|
||||
ImageBitmap, MaskBitmap: TBitmap;
|
||||
ImageRect: TRect;
|
||||
Pixmap: PGdkPixmap;
|
||||
Mask: PGdkBitmap;
|
||||
n, Count: integer;
|
||||
// pStr: PChar;
|
||||
begin
|
||||
// pStr:=PChar(ListItem.Caption);
|
||||
// if pStr=nil then pStr:=#0;
|
||||
|
||||
if (TLVHack(ALV).SmallImages <> nil)
|
||||
if (TLVHack(ALV).SmallImages <> nil)
|
||||
and (AItem.ImageIndex >= 0)
|
||||
and (AItem.ImageIndex < TLVHack(ALV).SmallImages.Count)
|
||||
then begin
|
||||
// set image & caption
|
||||
TLVHack(ALV).SmallImages.GetInternalImage(AItem.ImageIndex, ImageBitmap, MaskBitmap, ImageRect);
|
||||
if (ImageRect.Left <> 0)
|
||||
or (ImageRect.Top <> 0)
|
||||
then DebugLn('WARNING: TGtkWidgetSet.ListViewChangeItem does not support combined imagelists');
|
||||
if (ImageRect.Left <> 0)
|
||||
or (ImageRect.Top <> 0)
|
||||
then DebugLn('WARNING: TGtkWSCustomListView.ItemChangeInternal does not support combined imagelists');
|
||||
Pixmap := PGDIObject(ImageBitmap.Handle)^.GDIPixmapObject;
|
||||
Mask := PGdkBitmap(PGDIObject(ImageBitmap.Handle)^.GDIBitmapMaskObject);
|
||||
gtk_clist_set_pixtext(ACListWidget, AIndex, 0, PChar(AItem.Caption), 3, Pixmap, Mask);
|
||||
@ -246,77 +451,299 @@ begin
|
||||
gtk_clist_set_text(ACListWidget, AIndex, n, #0);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ItemDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemDelete')
|
||||
then Exit;
|
||||
|
||||
procedure TGtkWSCustomListView.InsertItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_remove(CListWidget, AIndex);
|
||||
end;
|
||||
|
||||
function TGtkWSCustomListView.ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean;
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemGetState')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
if (AIndex < 0) or (AIndex >= CListWidget^.rows)
|
||||
then begin
|
||||
DebugLN('[TGtkWSCustomListView.ItemGetState] Invalid row index: %d', [Aindex]);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
case AState of
|
||||
lisCut,
|
||||
lisDropTarget: begin
|
||||
//TODO: do something with the rowcolor ?
|
||||
end;
|
||||
|
||||
lisFocused: begin
|
||||
AIsSet := CListWidget^.focus_row = AIndex;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
lisSelected: begin
|
||||
AIsSet := (CListWidget^.selection <> nil)
|
||||
and (g_list_find(CListWidget^.selection, Pointer(Aindex)) <> nil);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
Titles: PPGChar;
|
||||
idx, Count: Integer;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'InsertItem')
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemInsert')
|
||||
then Exit;
|
||||
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
Count := CListWidget^.columns;
|
||||
|
||||
if Count = 0
|
||||
|
||||
if Count = 0
|
||||
then begin
|
||||
DebugLn('WARNING: TGtkWSCustomListView.InsertItem CListWidget^.columns = 0');
|
||||
DebugLn('WARNING: TGtkWSCustomListView.ItemInsert CListWidget^.columns = 0');
|
||||
Exit;
|
||||
end;
|
||||
|
||||
GetMem(Titles, SizeOf(PGChar) * Count);
|
||||
FillChar(Titles^, SizeOf(PGChar) * Count, 0);
|
||||
Titles[0] := #0;
|
||||
|
||||
|
||||
idx := AIndex;
|
||||
if idx = -1
|
||||
if idx = -1
|
||||
then idx := gtk_clist_append(CListWidget, Titles)
|
||||
else gtk_clist_insert(CListWidget, idx, Titles);
|
||||
FreeMem(Titles);
|
||||
|
||||
InternalChangeItem(CListWidget, ALV, idx, AItem);
|
||||
|
||||
ItemChangeInternal(CListWidget, ALV, idx, AItem);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.SelectItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
procedure TGtkWSCustomListView.ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
ImageBitmap, MaskBitmap: TBitmap;
|
||||
ImageRect: TRect;
|
||||
Pixmap: PGdkPixmap;
|
||||
Mask: PGdkBitmap;
|
||||
Spacing: guint8;
|
||||
Text: PChar;
|
||||
Dummy1, Dummy2: Pointer;
|
||||
CellType: TGtkCellType;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetImage')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
if (TLVHack(ALV).SmallImages <> nil)
|
||||
and (AImageIndex >= 0)
|
||||
and (AImageIndex < TLVHack(ALV).SmallImages.Count)
|
||||
then begin
|
||||
// set image & caption
|
||||
TLVHack(ALV).SmallImages.GetInternalImage(AImageIndex, ImageBitmap, MaskBitmap, ImageRect);
|
||||
if (ImageRect.Left <> 0)
|
||||
or (ImageRect.Top <> 0)
|
||||
then DebugLn('WARNING: TGtkWSCustomListView.ItemSetImage does not support combined imagelists');
|
||||
Pixmap := PGDIObject(ImageBitmap.Handle)^.GDIPixmapObject;
|
||||
Mask := PGdkBitmap(PGDIObject(ImageBitmap.Handle)^.GDIBitmapMaskObject);
|
||||
end
|
||||
else begin
|
||||
Pixmap := nil;
|
||||
Mask := nil;
|
||||
end;
|
||||
|
||||
CellType := gtk_clist_get_cell_type(CListWidget, AIndex, ASubIndex);
|
||||
// Sigh.
|
||||
// gtk returns -1 for an invalid cell (which is not part of the enum)
|
||||
// so to handle it, we need a case based on integer
|
||||
case Ord(CellType) of
|
||||
Ord(GTK_CELL_TEXT),
|
||||
Ord(GTK_CELL_PIXTEXT),
|
||||
Ord(GTK_CELL_EMPTY),
|
||||
Ord(GTK_CELL_PIXMAP): begin
|
||||
if pixmap <> nil
|
||||
then begin
|
||||
case CellType of
|
||||
GTK_CELL_TEXT: begin
|
||||
// convert the cell
|
||||
Text := nil;
|
||||
gtk_clist_get_text(CListWidget, AIndex, ASubIndex, @Text);
|
||||
gtk_clist_set_pixtext(CListWidget, AIndex, ASubIndex, Text, DEFAULT_IMAGE_SPACING, Pixmap, Mask);
|
||||
end;
|
||||
GTK_CELL_PIXTEXT: begin
|
||||
if gtk_clist_get_pixtext(CListWidget, AIndex, ASubIndex, @Text, @Spacing, @Dummy2, @Dummy1) <> 0
|
||||
then gtk_clist_set_pixtext(CListWidget, AIndex, ASubIndex, Text, Spacing, Pixmap, Mask)
|
||||
else gtk_clist_set_pixmap(CListWidget, AIndex, ASubIndex, Pixmap, Mask);
|
||||
end;
|
||||
GTK_CELL_EMPTY,
|
||||
GTK_CELL_PIXMAP: begin
|
||||
gtk_clist_set_pixtext(CListWidget, AIndex, ASubIndex, '', DEFAULT_IMAGE_SPACING, Pixmap, Mask);
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
case CellType of
|
||||
GTK_CELL_EMPTY,
|
||||
GTK_CELL_TEXT:; // nothing to do
|
||||
GTK_CELL_PIXTEXT: begin
|
||||
Text := nil;
|
||||
if gtk_clist_get_pixtext(CListWidget, AIndex, ASubIndex, @Text, @Spacing, @Dummy2, @Dummy1) <> 0
|
||||
then gtk_clist_set_text(CListWidget, AIndex, ASubIndex, Text)
|
||||
else gtk_clist_set_text(CListWidget, AIndex, ASubIndex, '');
|
||||
end;
|
||||
GTK_CELL_PIXMAP: begin
|
||||
gtk_clist_set_text(CListWidget, AIndex, ASubIndex, '');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Ord(GTK_CELL_WIDGET): DebugLN('[TGtkWSCustomListView.ItemSetImage] Setting text of widget cell');
|
||||
-1: DebugLN('[TGtkWSCustomListView.ItemSetText] Cell (%d,%d) not created', [AIndex, ASubIndex]);
|
||||
else
|
||||
DebugLN('[TGtkWSCustomListView.ItemSetImage] Unknown celltype %d', [Ord(CellType)]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SelectItem')
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetState')
|
||||
then Exit;
|
||||
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
if (AIndex < 0) or (AIndex >= CListWidget^.rows)
|
||||
then begin
|
||||
DebugLN('[TGtkWSCustomListView.ItemSetState] Invalid row index: %d', [Aindex]);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
case AState of
|
||||
lisCut,
|
||||
lisDropTarget: begin
|
||||
//TODO: do something with the rowcolor ?
|
||||
end;
|
||||
|
||||
gtk_clist_unselect_all(CListWidget);
|
||||
if AItem <> nil
|
||||
then gtk_clist_select_row(CListWidget, AItem.Index, 0);
|
||||
lisFocused: begin
|
||||
if AIsSet = (CListWidget^.focus_row = AIndex) then Exit;
|
||||
// reset old focus
|
||||
if (CListWidget^.focus_row <> -1)
|
||||
and (gtk_widget_has_focus(PGtkWidget(CListWidget)))
|
||||
then gtk_widget_draw_focus(PGtkWidget(CListWidget));
|
||||
|
||||
if AIsSet
|
||||
then begin
|
||||
CListWidget^.focus_row := AIndex;
|
||||
if gtk_widget_has_focus(PGtkWidget(CListWidget))
|
||||
then gtk_widget_draw_focus(PGtkWidget(CListWidget));
|
||||
end
|
||||
else CListWidget^.focus_row := -1;
|
||||
end;
|
||||
|
||||
lisSelected: begin
|
||||
if AIsSet
|
||||
then begin
|
||||
if (CListWidget^.selection_mode = GTK_SELECTION_SINGLE)
|
||||
or (CListWidget^.selection_mode = GTK_SELECTION_BROWSE)
|
||||
then begin
|
||||
// check if the row is are already selected
|
||||
// since we are in singleselect, the first item is checked
|
||||
if (CListWidget^.selection <> nil)
|
||||
and (Integer(CListWidget^.selection^.Data) = AIndex)
|
||||
then Exit;
|
||||
gtk_clist_unselect_all(CListWidget);
|
||||
end;
|
||||
gtk_clist_select_row(CListWidget, AIndex, 0);
|
||||
end
|
||||
else gtk_clist_unselect_row(CListWidget, AIndex, 0);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ShowItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
procedure TGtkWSCustomListView.ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
idx: Integer;
|
||||
Pixmap: PGdkPixmap;
|
||||
Mask: PGdkBitmap;
|
||||
Spacing: guint8;
|
||||
Dummy: Pointer;
|
||||
CellType: TGtkCellType;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ShowItem')
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetText')
|
||||
then Exit;
|
||||
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
|
||||
CellType := gtk_clist_get_cell_type(CListWidget, AIndex, ASubIndex);
|
||||
// Sigh.
|
||||
// gtk returns -1 for an invalid cell (which is not part of the enum)
|
||||
// so to handle it, we need a case based on integer
|
||||
case Ord(CellType) of
|
||||
Ord(GTK_CELL_EMPTY),
|
||||
Ord(GTK_CELL_TEXT): begin
|
||||
// simply set the text
|
||||
gtk_clist_set_text(CListWidget, AIndex, ASubIndex, PChar(AText));
|
||||
end;
|
||||
Ord(GTK_CELL_PIXTEXT): begin
|
||||
if gtk_clist_get_pixtext(CListWidget, AIndex, ASubIndex, @Dummy, @Spacing, @Pixmap, @Mask) <> 0
|
||||
then gtk_clist_set_pixtext(CListWidget, AIndex, ASubIndex, PChar(AText), Spacing, Pixmap, Mask)
|
||||
else gtk_clist_set_text(CListWidget, AIndex, ASubIndex, PChar(AText));
|
||||
end;
|
||||
Ord(GTK_CELL_PIXMAP): begin
|
||||
if gtk_clist_get_pixmap(CListWidget, AIndex, ASubIndex, @Pixmap, @Mask) <> 0
|
||||
then gtk_clist_set_pixtext(CListWidget, AIndex, ASubIndex, PChar(AText), DEFAULT_IMAGE_SPACING, Pixmap, Mask)
|
||||
else gtk_clist_set_text(CListWidget, AIndex, ASubIndex, PChar(AText));
|
||||
end;
|
||||
Ord(GTK_CELL_WIDGET): DebugLN('[TGtkWSCustomListView.ItemSetText] Setting text of widget cell');
|
||||
-1: DebugLN('[TGtkWSCustomListView.ItemSetText] Cell (%d,%d) not created', [AIndex, ASubIndex]);
|
||||
else
|
||||
DebugLN('[TGtkWSCustomListView.ItemSetText] Unknown celltype %d', [Ord(CellType)]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemShow')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
//0=NotVisible
|
||||
//1=PartiallyVisible
|
||||
//2=Fully Visible
|
||||
idx := AItem.Index;
|
||||
if gtk_clist_row_is_visible(CListWidget, idx) < 2
|
||||
then gtk_clist_moveto(CListWidget, idx, 0, 1, 0);
|
||||
if gtk_clist_row_is_visible(CListWidget, AIndex) < 2
|
||||
then gtk_clist_moveto(CListWidget, AIndex, 0, 1, 0);
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
|
||||
|
@ -222,7 +222,7 @@ Uses
|
||||
// Win32WSCalendar,
|
||||
// Win32WSCheckLst,
|
||||
// Win32WSCListBox,
|
||||
// Win32WSComCtrls,
|
||||
Win32WSComCtrls,
|
||||
Win32WSControls,
|
||||
// Win32WSDbCtrls,
|
||||
// Win32WSDBGrids,
|
||||
@ -285,6 +285,9 @@ End.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.90 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.89 2004/06/30 20:59:11 micha
|
||||
initialize common controls: date picker
|
||||
|
||||
|
@ -26,16 +26,14 @@ unit Win32WSComCtrls;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
////////////////////////////////////////////////////
|
||||
// I M P O R T A N T
|
||||
////////////////////////////////////////////////////
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
// ComCtrls,
|
||||
////////////////////////////////////////////////////
|
||||
WSComCtrls, WSLCLClasses;
|
||||
uses
|
||||
// FCL
|
||||
Classes, Windows,
|
||||
// LCL
|
||||
ComCtrls, LCLType, Controls, Graphics,
|
||||
LCLProc,
|
||||
// widgetset
|
||||
WSComCtrls, WSLCLClasses, WSProc;
|
||||
|
||||
type
|
||||
|
||||
@ -69,6 +67,26 @@ type
|
||||
private
|
||||
protected
|
||||
public
|
||||
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
||||
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer; override;
|
||||
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
|
||||
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
|
||||
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment); override;
|
||||
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean); override;
|
||||
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String); override;
|
||||
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer); override;
|
||||
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer); override;
|
||||
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer); override;
|
||||
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer); override;
|
||||
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean); override;
|
||||
|
||||
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
|
||||
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean; override; // returns True if supported
|
||||
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
|
||||
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
|
||||
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
|
||||
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
|
||||
end;
|
||||
|
||||
{ TWin32WSListView }
|
||||
@ -119,22 +137,6 @@ type
|
||||
public
|
||||
end;
|
||||
|
||||
{ TWin32WSToolButton }
|
||||
|
||||
TWin32WSToolButton = class(TWSToolButton)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
|
||||
{ TWin32WSToolBar }
|
||||
|
||||
TWin32WSToolBar = class(TWSToolBar)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
|
||||
{ TWin32WSTrackBar }
|
||||
|
||||
TWin32WSTrackBar = class(TWSTrackBar)
|
||||
@ -162,6 +164,292 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
{ TWin32WSCustomListView }
|
||||
|
||||
|
||||
const
|
||||
// TODO: move to windows unit
|
||||
LVCFMT_JUSTIFYMASK = LVCFMT_LEFT or LVCFMT_RIGHT or LVCFMT_CENTER;
|
||||
LVCF_IMAGE = $0010;
|
||||
LVCF_ORDER = $0020;
|
||||
|
||||
LVM_GETHEADER = $1000 + 31;
|
||||
|
||||
type
|
||||
// TODO: add iImage and iOrder to exiting TLvColumn
|
||||
// this is a hack !!!
|
||||
TLvColumn_v4_7 = record
|
||||
lvc: TLvColumn;
|
||||
iImage: Integer;
|
||||
iOrder: Integer;
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
var
|
||||
H: THandle;
|
||||
Count: Integer;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnDelete')
|
||||
then Exit;
|
||||
|
||||
// Move column to the last, otherwise out items get shuffeled
|
||||
|
||||
// H := ListView_GetHeader(Handle);
|
||||
H := SendMessage(ALV.Handle, LVM_GETHEADER, 0, 0);
|
||||
Count := Header_GetItemCount(H);
|
||||
if Count <= Aindex then Exit;
|
||||
|
||||
ColumnMove(ALV, AIndex, Count - 1, nil);
|
||||
ListView_DeleteColumn(ALV.Handle, Count - 1);
|
||||
end;
|
||||
|
||||
function TWin32WSCustomListView.ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer;
|
||||
var
|
||||
lvc: TLvColumn;
|
||||
begin
|
||||
Result := -1;
|
||||
// this implementation uses columnwidht = 0 for invisible
|
||||
// so fallback to default (= AColumn.FWidth)
|
||||
// Don't return AColumn.Width, this will cause a loop
|
||||
if not AColumn.Visible then Exit;
|
||||
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnGetSize')
|
||||
then Exit;
|
||||
|
||||
// dont use ListView_GetColumnWidth since we cant detect errors
|
||||
lvc.Mask := LVCF_WIDTH;
|
||||
if ListView_GetColumn(ALV.Handle, AIndex, lvc) <> 0
|
||||
then Result := lvc.cx;
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn);
|
||||
var
|
||||
lvc: TLvColumn;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnInsert')
|
||||
then Exit;
|
||||
|
||||
lvc.Mask := LVCF_TEXT;
|
||||
lvc.pszText := PChar(AColumn.Caption);
|
||||
|
||||
ListView_InsertColumn(ALV.Handle, AIndex, lvc);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
|
||||
var
|
||||
lvc, oldlvc: TLvColumn_v4_7;
|
||||
buf, oldbuf: array[0..1024] of Char;
|
||||
Count, idx: Integer;
|
||||
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnMove')
|
||||
then Exit;
|
||||
|
||||
Count := AOldIndex - ANewIndex;
|
||||
|
||||
// Fetch old column values
|
||||
oldlvc.lvc.Mask := LVCF_FMT or LVCF_IMAGE or LVCF_TEXT or LVCF_WIDTH;
|
||||
oldlvc.lvc.pszText := @oldbuf;
|
||||
oldlvc.lvc.cchTextMax := SizeOF(oldbuf);
|
||||
ListView_GetColumn(ALV.Handle, AOldIndex, oldlvc.lvc);
|
||||
|
||||
idx := AOldIndex;
|
||||
while Count <> 0 do
|
||||
begin
|
||||
// get next index
|
||||
if Count < 0
|
||||
then Inc(idx)
|
||||
else Dec(idx);
|
||||
// and data
|
||||
lvc.lvc.Mask := LVCF_FMT or LVCF_IMAGE or LVCF_TEXT or LVCF_WIDTH;
|
||||
lvc.lvc.pszText := @buf;
|
||||
lvc.lvc.cchTextMax := SizeOF(buf);
|
||||
ListView_GetColumn(ALV.Handle, idx, lvc.lvc);
|
||||
// set data
|
||||
ListView_SetColumn(ALV.Handle, ANewIndex + Count, lvc.lvc);
|
||||
|
||||
if Count < 0
|
||||
then Inc(Count)
|
||||
else Dec(Count);
|
||||
end;
|
||||
// finally copy original data to new column
|
||||
ListView_SetColumn(ALV.Handle, ANewIndex, oldlvc.lvc);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment);
|
||||
const
|
||||
JUSTIFICATION: array[TAlignment] of Integer = (
|
||||
LVCFMT_LEFT,
|
||||
LVCFMT_RIGHT,
|
||||
LVCFMT_CENTER
|
||||
);
|
||||
var
|
||||
lvc: TLvColumn;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetAlignment')
|
||||
then Exit;
|
||||
|
||||
lvc.Mask := LVCF_FMT;
|
||||
ListView_GetColumn(ALV.Handle, AIndex, lvc);
|
||||
lvc.fmt := (lvc.fmt and not LVCFMT_JUSTIFYMASK) or JUSTIFICATION[AAlignment];
|
||||
ListView_SetColumn(ALV.Handle, AIndex, lvc);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetAutoSize')
|
||||
then Exit;
|
||||
|
||||
if AAutoSize
|
||||
then ListView_SetColumnWidth(ALV.Handle, AIndex, LVSCW_AUTOSIZE)
|
||||
else ListView_SetColumnWidth(ALV.Handle, AIndex, AColumn.Width);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String);
|
||||
var
|
||||
lvc: TLvColumn;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetCaption')
|
||||
then Exit;
|
||||
|
||||
lvc.Mask := LVCF_TEXT;
|
||||
lvc.pszText := PChar(ACaption);
|
||||
|
||||
ListView_SetColumn(ALV.Handle, AIndex, lvc);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer);
|
||||
var
|
||||
lvc: TLvColumn_v4_7;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetImage')
|
||||
then Exit;
|
||||
|
||||
lvc.lvc.Mask := LVCF_IMAGE;
|
||||
lvc.iImage := AImageIndex;
|
||||
|
||||
ListView_SetColumn(ALV.Handle, AIndex, lvc.lvc);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetMaxWidth')
|
||||
then Exit;
|
||||
|
||||
// TODO: in messageHandler
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetMinWidth')
|
||||
then Exit;
|
||||
|
||||
// TODO: in messageHandler
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetWidth')
|
||||
then Exit;
|
||||
|
||||
ListView_SetColumnWidth(ALV.Handle, AIndex, AWidth)
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ColumnSetVisible')
|
||||
then Exit;
|
||||
|
||||
// TODO: implement with LV_COLUMN.subitem (associate different columns and insert/delete last.
|
||||
|
||||
if AVisible
|
||||
then ListView_SetColumnWidth(ALV.Handle, AIndex, AColumn.Width)
|
||||
else ListView_SetColumnWidth(ALV.Handle, AIndex, 0);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemDelete')
|
||||
then Exit;
|
||||
|
||||
ListView_DeleteItem(ALV.Handle, AIndex);
|
||||
end;
|
||||
|
||||
function TWin32WSCustomListView.ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean;
|
||||
const
|
||||
// lisCut, lisDropTarget, lisFocused, lisSelected
|
||||
FLAGS: array[TListItemState] of Integer = (LVIS_CUT, LVIS_DROPHILITED, LVIS_FOCUSED, LVIS_SELECTED);
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemGetState')
|
||||
then Exit;
|
||||
|
||||
AIsSet := 0 <> ListView_GetItemState(ALV.Handle, AIndex, FLAGS[AState]);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
var
|
||||
lvi: TLvItem;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemInsert')
|
||||
then Exit;
|
||||
|
||||
lvi.Mask := LVIF_TEXT;
|
||||
lvi.iItem := AIndex;
|
||||
lvi.iSubItem := 0;
|
||||
lvi.pszText := PChar(AItem.Caption);
|
||||
|
||||
ListView_InsertItem(ALV.Handle, lvi);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer);
|
||||
var
|
||||
lvi: TLvItem;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetImage')
|
||||
then Exit;
|
||||
|
||||
lvi.Mask := LVIF_IMAGE;
|
||||
lvi.iItem := AIndex;
|
||||
lvi.iSubItem := ASubIndex;
|
||||
lvi.iImage := AImageIndex;
|
||||
|
||||
ListView_SetItem(ALV.Handle, lvi);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean);
|
||||
const
|
||||
// lisCut, lisDropTarget, lisFocused, lisSelected
|
||||
FLAGS: array[TListItemState] of Integer = (LVIS_CUT, LVIS_DROPHILITED, LVIS_FOCUSED, LVIS_SELECTED);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetState')
|
||||
then Exit;
|
||||
|
||||
if AIsSet
|
||||
then ListView_SetItemState(ALV.Handle, AIndex, FLAGS[AState], FLAGS[AState])
|
||||
else ListView_SetItemState(ALV.Handle, AIndex, 0, FLAGS[AState]);
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemSetText')
|
||||
then Exit;
|
||||
|
||||
ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText));
|
||||
end;
|
||||
|
||||
procedure TWin32WSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemShow')
|
||||
then Exit;
|
||||
|
||||
ListView_EnsureVisible(ALV.Handle, AIndex, 1);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@ -173,7 +461,7 @@ initialization
|
||||
// RegisterWSComponent(TStatusBar, TWin32WSStatusBar);
|
||||
// RegisterWSComponent(TTabSheet, TWin32WSTabSheet);
|
||||
// RegisterWSComponent(TPageControl, TWin32WSPageControl);
|
||||
// RegisterWSComponent(TCustomListView, TWin32WSCustomListView);
|
||||
RegisterWSComponent(TCustomListView, TWin32WSCustomListView);
|
||||
// RegisterWSComponent(TListView, TWin32WSListView);
|
||||
// RegisterWSComponent(TProgressBar, TWin32WSProgressBar);
|
||||
// RegisterWSComponent(TCustomUpDown, TWin32WSCustomUpDown);
|
||||
|
@ -38,11 +38,18 @@ type
|
||||
FWidgetSetClass: TWSLCLComponentClass;
|
||||
protected
|
||||
property WidgetSetClass: TWSLCLComponentClass read FWidgetSetClass;
|
||||
public
|
||||
public
|
||||
procedure BeforeDestruction; override; // fixes missing call to Destroying in FPC
|
||||
class function NewInstance: TObject; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
implementation
|
||||
|
||||
procedure TLCLComponent.BeforeDestruction;
|
||||
begin
|
||||
inherited;
|
||||
Destroying;
|
||||
end;
|
||||
|
||||
function TLCLComponent.NewInstance: TObject;
|
||||
begin
|
||||
|
@ -99,6 +99,7 @@ function StrToDouble(const s: string): double;
|
||||
// debugging
|
||||
procedure RaiseGDBException(const Msg: string);
|
||||
|
||||
procedure DebugLn(const S: String; Args: array of const);
|
||||
procedure DebugLn;
|
||||
procedure DebugLn(const s: string);
|
||||
procedure DebugLn(const s1,s2: string);
|
||||
@ -618,6 +619,11 @@ begin
|
||||
Result:=Double(StrToFloat(s));
|
||||
end;
|
||||
|
||||
procedure DebugLn(const S: String; Args: array of const);
|
||||
begin
|
||||
DebugLn(Format(S, Args));
|
||||
end;
|
||||
|
||||
procedure DebugLn;
|
||||
begin
|
||||
DebugLn('');
|
||||
|
@ -127,8 +127,8 @@ const
|
||||
LM_LV_ADDITEM = LM_LV_FIRST+0;
|
||||
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_SELECTITEM = LM_LV_FIRST+3;
|
||||
// LM_LV_SHOWITEM = LM_LV_FIRST+4;
|
||||
LM_LV_LAST = LM_LV_FIRST+9; // LM_COMUSER+89
|
||||
|
||||
// TComboBox
|
||||
@ -959,8 +959,8 @@ begin
|
||||
LM_LV_ADDITEM :Result:='LM_LV_ADDITEM';
|
||||
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_SELECTITEM :Result:='LM_LV_SELECTITEM';
|
||||
// LM_LV_SHOWITEM :Result:='LM_LV_SHOWITEM';
|
||||
//LM_LV_LAST :Result:='LM_LV_LAST';
|
||||
|
||||
// TComboBox
|
||||
@ -1078,6 +1078,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.66 2004/07/11 17:20:47 marc
|
||||
* Implemented most of TListColoum/Item in the Ws for gtk and win32
|
||||
|
||||
Revision 1.65 2004/06/18 20:15:06 micha
|
||||
remove obsolete LM_LOADXPM message
|
||||
|
||||
|
@ -40,6 +40,7 @@ interface
|
||||
// the uses clause of the XXXintf.pp
|
||||
////////////////////////////////////////////////////
|
||||
uses
|
||||
Classes,
|
||||
////////////////////////////////////////////////////
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
@ -65,15 +66,32 @@ type
|
||||
TWSPageControl = class(TWSCustomNotebook)
|
||||
end;
|
||||
|
||||
{ TWSCustomListView }
|
||||
|
||||
{ TWSCustomListView }
|
||||
TWSListViewItemChange = (lvicText, lvicImage);
|
||||
TWSListViewItemChanges = set of TWSListViewItemChange;
|
||||
|
||||
TWSCustomListViewClass = class of TWSCustomListView;
|
||||
TWSCustomListView = class(TWSWinControl)
|
||||
class procedure ChangeItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); virtual;
|
||||
class procedure DeleteItem(const ALV: TCustomListView; const AIndex: Integer); virtual;
|
||||
class procedure InsertItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); virtual;
|
||||
class procedure SelectItem(const ALV: TCustomListView; const AItem: TListItem); virtual;
|
||||
class procedure ShowItem(const ALV: TCustomListView; const AItem: TListItem); virtual;
|
||||
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); virtual;
|
||||
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer; virtual;
|
||||
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); virtual;
|
||||
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); virtual;
|
||||
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment); virtual;
|
||||
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean); virtual;
|
||||
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String); virtual;
|
||||
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer); virtual;
|
||||
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer); virtual;
|
||||
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer); virtual;
|
||||
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer); virtual;
|
||||
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean); virtual;
|
||||
|
||||
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); virtual;
|
||||
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean; virtual; // returns True if supported
|
||||
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); virtual;
|
||||
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); virtual;
|
||||
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); virtual;
|
||||
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); virtual;
|
||||
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); virtual;
|
||||
end;
|
||||
|
||||
{ TWSListView }
|
||||
@ -131,34 +149,87 @@ uses
|
||||
|
||||
{ TWSCustomListView }
|
||||
|
||||
procedure TWSCustomListView.ChangeItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
procedure TWSCustomListView.ColumnDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_CHANGEITEM, ALV, @AIndex);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.DeleteItem(const ALV: TCustomListView; const AIndex: Integer);
|
||||
function TWSCustomListView.ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer;
|
||||
begin
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ItemDelete(const ALV: TCustomListView; const AIndex: Integer);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_DELETEITEM, ALV ,@AIndex);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.InsertItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
function TWSCustomListView.ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; var AIsSet: Boolean): Boolean;
|
||||
begin
|
||||
// returns True if supported
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_ADDITEM, ALV, @AIndex);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.SelectItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
procedure TWSCustomListView.ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_SELECTITEM, ALV, AItem);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ShowItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
procedure TWSCustomListView.ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_SHOWITEM, ALV, AItem);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user