mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 23:49:28 +02:00
* Started to move TListview to the WS interface
git-svn-id: trunk@5483 -
This commit is contained in:
parent
ba6baf4a88
commit
ae6aebdfa7
@ -35,17 +35,23 @@ program ListViewTest;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, Classes, Buttons, ComCtrls, Forms, SysUtils;
|
||||
Interfaces, Classes, Buttons, Controls, ComCtrls, Forms, SysUtils, StdCtrls;
|
||||
|
||||
type
|
||||
TMyForm = class(TForm)
|
||||
private
|
||||
FItemIndex: Cardinal;
|
||||
FItemIndex: Cardinal;
|
||||
public
|
||||
ListView: TListView;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Edit1: TEdit;
|
||||
Edit2: TEdit;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Edit1Change(Sender: TObject);
|
||||
procedure Edit2Change(Sender: TObject);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -56,21 +62,27 @@ begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
Caption := 'List View Test';
|
||||
Width := 175;
|
||||
Height := 195;
|
||||
Width := 300;
|
||||
Height := 200;
|
||||
|
||||
ListView := TListView.Create(Self);
|
||||
ListView.Parent := Self;
|
||||
ListView.Height := 120;
|
||||
ListView.Width := 150;
|
||||
ListView.Height := 150;
|
||||
// ListView.Width := 250;
|
||||
ListView.Align := alTop;
|
||||
ListView.ViewStyle := vsReport;
|
||||
ListView.Show;
|
||||
|
||||
ListView.Columns.Add.Caption := 'Column 1';
|
||||
ListView.Columns.Add.Caption := 'Column 2';
|
||||
ListView.Columns.Add.Caption := 'Column 3';
|
||||
|
||||
Button1 := TButton.Create(Self);
|
||||
with Button1 do
|
||||
begin
|
||||
Parent := Self;
|
||||
Caption := 'Add Item';
|
||||
Top := 130;
|
||||
Top := 160;
|
||||
Left := 10;
|
||||
Height := 25;
|
||||
Width := 65;
|
||||
@ -78,16 +90,72 @@ begin
|
||||
Show;
|
||||
end;
|
||||
|
||||
Button2 := TButton.Create(Self);
|
||||
with Button2 do
|
||||
begin
|
||||
Parent := Self;
|
||||
Caption := 'Del Item';
|
||||
Top := 160;
|
||||
Left := 80;
|
||||
Height := 25;
|
||||
Width := 65;
|
||||
OnClick := @Button2Click;
|
||||
Show;
|
||||
end;
|
||||
|
||||
Edit1 := TEdit.Create(Self);
|
||||
with Edit1 do
|
||||
begin
|
||||
Parent := Self;
|
||||
Top := 160;
|
||||
Left := 150;
|
||||
Height := 25;
|
||||
Width := 65;
|
||||
OnChange := @Edit1Change;
|
||||
Show;
|
||||
end;
|
||||
|
||||
Edit2 := TEdit.Create(Self);
|
||||
with Edit2 do
|
||||
begin
|
||||
Parent := Self;
|
||||
Top := 160;
|
||||
Left := 220;
|
||||
Height := 25;
|
||||
Width := 65;
|
||||
OnChange := @Edit2Change;
|
||||
Show;
|
||||
end;
|
||||
|
||||
Show;
|
||||
end;
|
||||
|
||||
procedure TMyForm.Button1Click(Sender: TObject);
|
||||
var
|
||||
Item: TListItem;
|
||||
begin
|
||||
begin
|
||||
Inc(FItemIndex);
|
||||
Item := ListView.Items.Add;
|
||||
Item.Caption := Format('Item %D', [FItemIndex]);
|
||||
Item.Caption := Format('Item %d', [FItemIndex]);
|
||||
Item.SubItems.Add(Format('Sub %d.1', [FItemIndex]));
|
||||
Item.SubItems.Add(Format('Sub %d.2', [FItemIndex]));
|
||||
end;
|
||||
|
||||
procedure TMyForm.Button2Click(Sender: TObject);
|
||||
begin
|
||||
ListView.Selected.Free;
|
||||
end;
|
||||
|
||||
procedure TMyForm.Edit1Change(Sender: TObject);
|
||||
begin
|
||||
if ListView.Selected = nil then Exit;
|
||||
ListView.Selected.Caption := Edit1.Text;
|
||||
end;
|
||||
|
||||
procedure TMyForm.Edit2Change(Sender: TObject);
|
||||
begin
|
||||
if ListView.Selected = nil then Exit;
|
||||
ListView.Selected.SubItems[1] := Edit2.Text;
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -98,6 +166,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.4 2002/10/29 08:22:32 lazarus
|
||||
MG: added interfaces unit
|
||||
|
||||
|
@ -296,13 +296,7 @@ implementation
|
||||
uses
|
||||
WSButtons;
|
||||
|
||||
|
||||
const
|
||||
{BitbtnCaption : array[TBitBtnKind] of String = (
|
||||
'', rsmbOK, rsmbCancel, rsmbHelp, rsmbYes, rsmbNo,
|
||||
rsmbClose, rsmbAbort, rsmbRetry, rsmbIgnore, rsmbAll,
|
||||
rsmbNoToAll, rsmbYesToAll);}
|
||||
|
||||
BitBtnModalResults : array[TBitBtnKind] of TModalResult = (
|
||||
0, mrOK, mrCancel, 0, mrYes, mrNo,
|
||||
0, mrAbort, mrRetry, mrIgnore, mrAll,
|
||||
@ -334,6 +328,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.66 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.65 2004/05/16 23:24:41 marc
|
||||
+ Added WSBitBtn interface
|
||||
+ Implemented WSBitBtn interface for gtk
|
||||
|
@ -314,7 +314,7 @@ type
|
||||
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 Index : Integer read GetIndex;
|
||||
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;
|
||||
@ -486,6 +486,12 @@ type
|
||||
procedure CNNotify(var AMessage: TLMNotify); message CN_NOTIFY;
|
||||
procedure DoUpdate;
|
||||
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);
|
||||
|
||||
protected
|
||||
procedure InitializeWnd; override;
|
||||
procedure Loaded; override;
|
||||
@ -499,10 +505,7 @@ type
|
||||
function GetMaxScrolledLeft : Integer;
|
||||
function GetMaxScrolledTop : Integer;
|
||||
procedure ColumnsChanged; //called by TListColumns
|
||||
procedure ItemChanged(Index : Integer); //called by TListItems
|
||||
procedure ItemDeleted(Index : Integer); //called by TListItems
|
||||
procedure ImageChanged(Sender : TObject);
|
||||
procedure ItemAdded(Index: Integer); //called by TListItems
|
||||
procedure WMHScroll(var Msg: TLMScroll); message LM_HSCROLL;
|
||||
procedure WMVScroll(var Msg: TLMScroll); message LM_VSCROLL;
|
||||
// property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
|
||||
@ -2201,7 +2204,10 @@ procedure CheckCommonControl(CC: Integer);
|
||||
|
||||
procedure Register;
|
||||
|
||||
Implementation
|
||||
implementation
|
||||
|
||||
uses
|
||||
WSComCtrls;
|
||||
|
||||
const
|
||||
ScrollBarWidth=0;
|
||||
@ -2249,6 +2255,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.123 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.122 2004/05/11 09:49:46 mattias
|
||||
started sending CN_KEYUP
|
||||
|
||||
|
@ -167,8 +167,8 @@ procedure TCustomListView.InitializeWnd;
|
||||
begin
|
||||
inherited InitializeWnd;
|
||||
CNSendMessage(LM_SETPROPERTIES,Self,nil);
|
||||
if FSelected<>nil then
|
||||
CNSendMessage(LM_LV_SELECTITEM,Self,FSelected);
|
||||
if FSelected <> nil
|
||||
then TWSCustomListViewClass(WidgetSetClass).SelectItem(Self, FSelected);
|
||||
end;
|
||||
|
||||
procedure TCustomListView.Loaded;
|
||||
@ -197,7 +197,7 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ItemChanged }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TCustomListView.ItemChanged(Index : Integer); //called by TListItems
|
||||
procedure TCustomListView.ItemChanged(const AItem: TListItem; const AIndex: Integer); //called by TListItems
|
||||
Begin
|
||||
if csDestroying in Componentstate Then Exit;
|
||||
if FUpdateCount>0 then
|
||||
@ -205,39 +205,40 @@ Begin
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_CHANGEITEM,self,@Index);
|
||||
TWSCustomListViewClass(WidgetSetClass).ChangeItem(Self, AIndex, AItem);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ItemDeleted }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TCustomListView.ItemDeleted(Index : Integer); //called by TListItems
|
||||
Begin
|
||||
procedure TCustomListView.ItemDeleted(const AIndex : Integer); //called by TListItems
|
||||
begin
|
||||
if csDestroying in Componentstate Then Exit;
|
||||
if FSelected= FListItems[Index] then FSelected:=nil;
|
||||
DoDeletion(FListItems[Index]);
|
||||
if FSelected = FListItems[AIndex] then FSelected := nil;
|
||||
DoDeletion(FListItems[AIndex]);
|
||||
if FUpdateCount>0 then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_DELETEITEM,self,@Index);
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then Exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).DeleteItem(Self, AIndex);
|
||||
end;
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView ItemAdded }
|
||||
{ TCustomListView ItemInserted }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TCustomListView.ItemAdded(Index: Integer);
|
||||
Begin
|
||||
procedure TCustomListView.ItemInserted(const AItem: TListItem; const AIndex: Integer);
|
||||
begin
|
||||
if csDestroying in Componentstate Then Exit;
|
||||
if FUpdateCount>0 then
|
||||
if FUpdateCount > 0
|
||||
then
|
||||
Include(FStates,lvUpdateNeeded)
|
||||
else begin
|
||||
//notify the interface....
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_ADDITEM,self,@Index);
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then Exit;
|
||||
TWSCustomListViewClass(WidgetSetClass).InsertItem(Self, AIndex, AItem);
|
||||
end;
|
||||
End;
|
||||
|
||||
@ -246,14 +247,15 @@ End;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetItems(const AValue : TListItems);
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView SetItemVisible }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListView.SetItemVisible(const AValue : TListItem);
|
||||
begin
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_SHOWITEM,self,AValue);
|
||||
TWSCustomListViewClass(WidgetSetClass).ShowItem(Self, AValue);
|
||||
end;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TCustomListView Delete }
|
||||
@ -411,7 +413,9 @@ begin
|
||||
if FSelected=AValue then exit;
|
||||
FSelected := AValue;
|
||||
if (not HandleAllocated) or (csLoading in ComponentState) then exit;
|
||||
CNSendMessage(LM_LV_SELECTITEM,self,FSelected);
|
||||
|
||||
TWSCustomListViewClass(WidgetSetClass).SelectItem(Self, FSelected);
|
||||
|
||||
//DoSelectItem(FSelected, True);
|
||||
end;
|
||||
|
||||
@ -614,6 +618,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.35 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.34 2004/05/11 12:16:47 mattias
|
||||
replaced writeln by debugln
|
||||
|
||||
|
@ -38,9 +38,9 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
function TListItems.GetItem(const AIndex: Integer): TListItem;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (FItems.Count-1 < AIndex) then Exit;
|
||||
Result := TListItem(FItems.Items[AIndex]);
|
||||
if FItems.Count - 1 < AIndex
|
||||
then Result := nil
|
||||
else Result := TListItem(FItems.Items[AIndex]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -48,9 +48,9 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TListItems.SetItem(const AIndex: Integer; const AValue: TListItem);
|
||||
begin
|
||||
if FItems.Count-1 < AIndex then Exit;
|
||||
if FItems.Count - 1 < AIndex then Exit;
|
||||
FItems.Items[AIndex] := AValue;
|
||||
FOwner.ItemChanged(AIndex);
|
||||
FOwner.ItemChanged(AValue, AIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -61,7 +61,8 @@ begin
|
||||
Result := TListItem.Create(self);
|
||||
FItems.Add(Result);
|
||||
//Notify parent TListView that something was added.
|
||||
FOwner.ItemAdded(-1);
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemInserted(Result, -1);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -88,8 +89,8 @@ var
|
||||
idx: Integer;
|
||||
begin
|
||||
idx := FItems.IndexOf(AItem);
|
||||
if assigned(FOwner)
|
||||
then FOwner.ItemDeleted(idx);
|
||||
if FOwner <> nil
|
||||
then FOwner.ItemDeleted(idx);
|
||||
FItems.Remove(AItem);
|
||||
end;
|
||||
|
||||
@ -101,8 +102,7 @@ begin
|
||||
Result := TListItem.Create(self);
|
||||
FItems.Insert(AIndex, Result);
|
||||
//Notify parent TListView that something was added.
|
||||
FOwner.ItemAdded(AIndex);
|
||||
|
||||
FOwner.ItemInserted(Result, AIndex);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -137,13 +137,12 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TListItems.ItemChanged(Sender : TObject); //called by the onchange of the tstringlist in TListItem
|
||||
var
|
||||
Index : Integer;
|
||||
idx : Integer;
|
||||
begin
|
||||
// Writeln('ITEM CHANGED');
|
||||
Index := FItems.IndexOf(TListItem(sender));
|
||||
// Writeln('Calling Item Changed with Index ',Index);
|
||||
if Index > -1 then
|
||||
FOwner.ItemChanged(Index);
|
||||
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);
|
||||
@ -249,9 +248,11 @@ begin
|
||||
finally
|
||||
FreeMem(ItemHeader, Size);
|
||||
Owner.EndUpdate;
|
||||
|
||||
if Flag then
|
||||
Owner.ItemAdded(-1);
|
||||
|
||||
// MWE: Still needed ???
|
||||
// ENdUpdate already added all items.
|
||||
//if Flag then
|
||||
// Owner.ItemAdded(-1);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -332,6 +333,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.20 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.19 2004/04/10 17:58:57 mattias
|
||||
implemented mainunit hints for include files
|
||||
|
||||
|
@ -230,10 +230,6 @@ type
|
||||
procedure RemoveNBPage(ANoteBook: TObject; Index: Integer);virtual;
|
||||
procedure MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);virtual;
|
||||
|
||||
// listview
|
||||
procedure ListViewChangeItem(TheListView: TObject; Index: integer);
|
||||
procedure ListViewAddItem(TheListView: TObject; Index: Integer);
|
||||
|
||||
// listbox
|
||||
function GetTopIndex(Sender: TObject): integer;virtual;
|
||||
function SetTopIndex(Sender: TObject; NewTopIndex: integer): integer;virtual;
|
||||
@ -344,7 +340,7 @@ uses
|
||||
// GtkWSCalendar,
|
||||
// GtkWSCheckLst,
|
||||
// GtkWSCListBox,
|
||||
// GtkWSComCtrls,
|
||||
GtkWSComCtrls,
|
||||
GtkWSControls,
|
||||
// GtkWSDbCtrls,
|
||||
// GtkWSDBGrids,
|
||||
@ -464,6 +460,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.182 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.181 2004/04/18 23:55:39 marc
|
||||
* Applied patch from Ladislav Michl
|
||||
* Changed the way TControl.Text is resolved
|
||||
|
@ -2914,96 +2914,6 @@ begin
|
||||
gdk_pixmap_unref(TempMaskPixmap);
|
||||
end;
|
||||
|
||||
procedure TGtkWidgetSet.ListViewChangeItem(TheListView: TObject; Index: integer);
|
||||
{$IfDef GTK2}
|
||||
begin
|
||||
DebugLn('TODO: TGtkWidgetSet.ListViewChangeItem');
|
||||
end;
|
||||
{$Else}
|
||||
var
|
||||
ListView: TListView;
|
||||
LVWidget: PgtkCList;
|
||||
pStr: PChar;
|
||||
ListItem: TListItem;
|
||||
i, ColCount: integer;
|
||||
Pixmap: PGdkPixmap;
|
||||
Mask: PGdkBitmap;
|
||||
ImageBitmap, MaskBitmap: TBitmap;
|
||||
ImageRect: TRect;
|
||||
begin
|
||||
ListView:=TListView(TheListView);
|
||||
LVWidget:= PgtkCList(
|
||||
GetWidgetInfo(Pointer(ListView.Handle), True)^.CoreWidget);
|
||||
ListItem := ListView.Items[Index];
|
||||
// set caption (= first column text)
|
||||
pStr:=PChar(ListItem.Caption);
|
||||
if pStr=nil then pStr:=#0;
|
||||
gtk_clist_set_text(LVWidget,Index,0,pStr);
|
||||
|
||||
// set image
|
||||
if (ListView.SmallImages <> nil) and (ListItem.ImageIndex >= 0)
|
||||
and (ListItem.ImageIndex < Listview.SmallImages.Count)
|
||||
then begin
|
||||
//draw image
|
||||
ListView.SmallImages.GetInternalImage(ListItem.ImageIndex,
|
||||
ImageBitmap, MaskBitmap, ImageRect);
|
||||
if (ImageRect.Left<>0) or (ImageRect.Top<>0) then
|
||||
DebugLn('WARNING: TGtkWidgetSet.ListViewChangeItem does not support combined imagelists');
|
||||
Pixmap:=PgdiObject(ImageBitmap.Handle)^.GDIPixmapObject;
|
||||
Mask:=pgdkBitmap(PgdiObject(ImageBitmap.Handle)^.GDIBitmapMaskObject);
|
||||
gtk_clist_set_pixtext(LVWidget,Index,0,pStr,3,Pixmap,Mask);
|
||||
end;
|
||||
|
||||
// set the other column texts
|
||||
ColCount:=LVWidget^.Columns;
|
||||
for i := 1 to ColCount-1 do
|
||||
begin
|
||||
if i<=ListItem.SubItems.Count then begin
|
||||
// the first subitem is the second column
|
||||
pStr:=PChar(ListItem.SubItems.Strings[i-1]);
|
||||
if pStr=nil then pStr:=#0;
|
||||
end else begin
|
||||
pStr:=#0
|
||||
end;
|
||||
gtk_clist_set_text(LVWidget,Index,i,pStr);
|
||||
end;
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TGtkWidgetSet.ListViewAddItem(TheListView: TObject;Index: Integer);
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TGtkWidgetSet.ListViewAddItem(TheListView: TObject; Index: Integer);
|
||||
{$IfDef GTK2}
|
||||
begin
|
||||
DebugLn('TODO: TGtkWidgetSet.ListViewAddItem');
|
||||
end;
|
||||
{$Else}
|
||||
var
|
||||
ListView: TListView;
|
||||
ListViewWidget: PGtkCList;
|
||||
Titles: PPGChar;
|
||||
i, Count: integer;
|
||||
begin
|
||||
ListView:=TListView(TheListView);
|
||||
ListViewWidget:= PGtkCList(GetWidgetInfo(
|
||||
Pointer(ListView.Handle), True)^.CoreWidget);
|
||||
Count:=ListViewWidget^.columns;
|
||||
if Count=0 then begin
|
||||
DebugLn('WARNING: TGtkWidgetSet.ListViewAddItem ListViewWidget^.columns=0');
|
||||
exit;
|
||||
end;
|
||||
GetMem(Titles,SizeOf(PGChar)*Count);
|
||||
Titles[0]:=#0;
|
||||
for i:=1 to Count-1 do Titles[i]:=nil;
|
||||
if Index = -1 then
|
||||
gtk_clist_append(ListViewWidget,Titles)
|
||||
else
|
||||
gtk_clist_insert(ListViewWidget,Index,Titles);
|
||||
FreeMem(Titles);
|
||||
end;
|
||||
{$EndIf}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TGtkWidgetSet.GetTopIndex(Sender: TObject): integer;
|
||||
------------------------------------------------------------------------------}
|
||||
@ -3231,70 +3141,36 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
LM_LV_DELETEITEM :
|
||||
begin
|
||||
if (Sender is TListView) then
|
||||
begin
|
||||
{$IfDef GTK2}
|
||||
LM_LV_DELETEITEM:
|
||||
{$IfDef GTK2}
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_LV_DELETEITEM');
|
||||
{$Else}
|
||||
Num := Integer(data^);
|
||||
Widget:= GetWidgetInfo(Pointer(Handle), True)^.CoreWidget;
|
||||
gtk_clist_remove(PgtkCList(Widget),Num);
|
||||
{$EndIf}
|
||||
end;
|
||||
end;
|
||||
{$Else}
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LV_DELETEITEM for ', Sender.ClassName);
|
||||
{$EndIf}
|
||||
|
||||
LM_LV_CHANGEITEM :
|
||||
if (Sender is TListView) then
|
||||
ListViewChangeItem(Sender,Integer(data^));
|
||||
LM_LV_CHANGEITEM:
|
||||
{$IfDef GTK2}
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_LV_CHANGEITEM');
|
||||
{$Else}
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LV_CHANGEITEM for ', Sender.ClassName);
|
||||
{$EndIf}
|
||||
|
||||
LM_LV_ADDITEM :
|
||||
if (Sender is TListView) then
|
||||
begin
|
||||
if data <> nil then begin
|
||||
if Integer(data^) < 0 then begin
|
||||
ListViewAddItem(Sender, -1);
|
||||
ListViewChangeItem(Sender,TListView(Sender).Items.Count-1);
|
||||
end
|
||||
else begin
|
||||
ListViewAddItem(Sender,Integer(data^));
|
||||
ListViewChangeItem(Sender,Integer(data^));
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
ListViewAddItem(Sender,-1);
|
||||
ListViewChangeItem(Sender,TListView(Sender).Items.Count-1);
|
||||
end;
|
||||
end;
|
||||
LM_LV_ADDITEM:
|
||||
{$IfDef GTK2}
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_LV_ADDITEM');
|
||||
{$Else}
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LV_ADDITEM for ', Sender.ClassName);
|
||||
{$EndIf}
|
||||
|
||||
LM_LV_SELECTITEM:
|
||||
if (Sender is TListView) then
|
||||
begin
|
||||
{$IfDef GTK2}
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_LV_SELECTITEM');
|
||||
DebugLn('TODO: TGtkWidgetSet.IntSendMessage3 LM_LV_SELECTITEM');
|
||||
{$Else}
|
||||
Widget:= GetWidgetInfo(Pointer(Handle), True)^.CoreWidget;
|
||||
gtk_clist_unselect_all(PGtkCList(Widget));
|
||||
if Data<>nil then
|
||||
gtk_clist_select_row(PGtkCList(Widget),TListItem(Data).Index,0);
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LV_SELECTITEM for ', Sender.ClassName);
|
||||
{$EndIf}
|
||||
end;
|
||||
|
||||
LM_LV_SHOWITEM:
|
||||
if (Sender is TListView) then
|
||||
begin
|
||||
if Data<>nil
|
||||
then begin
|
||||
Widget:= GetWidgetInfo(Pointer(Handle), True)^.CoreWidget;
|
||||
//0=NotVisible
|
||||
//1=PartiallyVisible
|
||||
//2=Fully Visible
|
||||
if gtk_clist_row_is_visible(PGtkCList(Widget),
|
||||
TListItem(Data).Index) < 2
|
||||
then gtk_clist_moveto(PGtkCList(Widget),TListItem(Data).Index,0,1,0);
|
||||
|
||||
end;
|
||||
end;
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LV_SHOWITEM for ', Sender.ClassName);
|
||||
|
||||
LM_BRINGTOFRONT:
|
||||
begin
|
||||
@ -3379,7 +3255,7 @@ begin
|
||||
end;
|
||||
|
||||
//TBitBtn
|
||||
LM_IMAGECHANGED:
|
||||
LM_IMAGECHANGED:
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_IMAGECHANGED for ', Sender.ClassName);
|
||||
LM_LAYOUTCHANGED:
|
||||
DebugLn('[WARNING] Obsolete messagecall to LM_LAYOUTCHANGED for ', Sender.ClassName);
|
||||
@ -9323,6 +9199,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.503 2004/05/18 23:10:41 marc
|
||||
* Started to move TListview to the WS interface
|
||||
|
||||
Revision 1.502 2004/05/16 23:24:41 marc
|
||||
+ Added WSBitBtn interface
|
||||
+ Implemented WSBitBtn interface for gtk
|
||||
|
@ -27,15 +27,19 @@ unit GtkWSComCtrls;
|
||||
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;
|
||||
// libs
|
||||
{$IFDEF GTK2}
|
||||
GLib2, Gtk2,
|
||||
{$ELSE}
|
||||
GLib, Gtk, Gdk,
|
||||
{$ENDIF}
|
||||
// LCL
|
||||
ComCtrls, Classes, LCLType, LMessages, Controls, Graphics,
|
||||
LCLProc,
|
||||
// widgetset
|
||||
WSComCtrls, WSLCLClasses, WSProc,
|
||||
// interface
|
||||
GtkDef;
|
||||
|
||||
type
|
||||
|
||||
@ -67,8 +71,14 @@ type
|
||||
|
||||
TGtkWSCustomListView = class(TWSCustomListView)
|
||||
private
|
||||
class procedure InternalChangeItem(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;
|
||||
end;
|
||||
|
||||
{ TGtkWSListView }
|
||||
@ -119,22 +129,6 @@ type
|
||||
public
|
||||
end;
|
||||
|
||||
{ TGtkWSToolButton }
|
||||
|
||||
TGtkWSToolButton = class(TWSToolButton)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
|
||||
{ TGtkWSToolBar }
|
||||
|
||||
TGtkWSToolBar = class(TWSToolBar)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
|
||||
{ TGtkWSTrackBar }
|
||||
|
||||
TGtkWSTrackBar = class(TWSTrackBar)
|
||||
@ -160,7 +154,161 @@ type
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
GtkProc, GtkInt, GtkGlobals,
|
||||
GtkWSControls;
|
||||
|
||||
|
||||
{ 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
|
||||
TLVHack = class(TCustomListView)
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.InternalChangeItem(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)
|
||||
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');
|
||||
Pixmap := PGDIObject(ImageBitmap.Handle)^.GDIPixmapObject;
|
||||
Mask := PGdkBitmap(PGDIObject(ImageBitmap.Handle)^.GDIBitmapMaskObject);
|
||||
gtk_clist_set_pixtext(ACListWidget, AIndex, 0, PChar(AItem.Caption), 3, Pixmap, Mask);
|
||||
end
|
||||
else begin
|
||||
// set caption alone
|
||||
gtk_clist_set_text(ACListWidget, AIndex, 0, PChar(AItem.Caption));
|
||||
end;
|
||||
|
||||
// set the other column texts
|
||||
Count := AItem.SubItems.Count + 1;
|
||||
if Count > ACListWidget^.Columns
|
||||
then Count := ACListWidget^.Columns;
|
||||
// set the existing subitems
|
||||
for n := 1 to Count - 1 do
|
||||
gtk_clist_set_text(ACListWidget, AIndex, n, PChar(AItem.SubItems[n - 1]));
|
||||
// fill remaining
|
||||
for n := Count to ACListWidget^.Columns - 1 do
|
||||
gtk_clist_set_text(ACListWidget, AIndex, n, #0);
|
||||
end;
|
||||
|
||||
|
||||
procedure TGtkWSCustomListView.InsertItem(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')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
Count := CListWidget^.columns;
|
||||
|
||||
if Count = 0
|
||||
then begin
|
||||
DebugLn('WARNING: TGtkWSCustomListView.InsertItem CListWidget^.columns = 0');
|
||||
Exit;
|
||||
end;
|
||||
|
||||
GetMem(Titles, SizeOf(PGChar) * Count);
|
||||
FillChar(Titles^, SizeOf(PGChar) * Count, 0);
|
||||
Titles[0] := #0;
|
||||
|
||||
idx := AIndex;
|
||||
if idx = -1
|
||||
then idx := gtk_clist_append(CListWidget, Titles)
|
||||
else gtk_clist_insert(CListWidget, idx, Titles);
|
||||
FreeMem(Titles);
|
||||
|
||||
InternalChangeItem(CListWidget, ALV, idx, AItem);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.SelectItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SelectItem')
|
||||
then Exit;
|
||||
|
||||
WidgetInfo := GetWidgetInfo(Pointer(ALV.Handle));
|
||||
CListWidget := PGtkCList(WidgetInfo^.CoreWidget);
|
||||
|
||||
gtk_clist_unselect_all(CListWidget);
|
||||
if AItem <> nil
|
||||
then gtk_clist_select_row(CListWidget, AItem.Index, 0);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomListView.ShowItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
var
|
||||
WidgetInfo: PWidgetInfo;
|
||||
CListWidget: PGtkCList;
|
||||
idx: Integer;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ShowItem')
|
||||
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);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
@ -173,7 +321,7 @@ initialization
|
||||
// RegisterWSComponent(TStatusBar, TGtkWSStatusBar);
|
||||
// RegisterWSComponent(TTabSheet, TGtkWSTabSheet);
|
||||
// RegisterWSComponent(TPageControl, TGtkWSPageControl);
|
||||
// RegisterWSComponent(TCustomListView, TGtkWSCustomListView);
|
||||
RegisterWSComponent(TCustomListView, TGtkWSCustomListView);
|
||||
// RegisterWSComponent(TListView, TGtkWSListView);
|
||||
// RegisterWSComponent(TProgressBar, TGtkWSProgressBar);
|
||||
// RegisterWSComponent(TCustomUpDown, TGtkWSCustomUpDown);
|
||||
|
@ -44,7 +44,7 @@ uses
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
// ComCtrls,
|
||||
ComCtrls,
|
||||
////////////////////////////////////////////////////
|
||||
WSLCLClasses, WSControls, WSExtCtrls, WSStdCtrls,
|
||||
WSToolwin;
|
||||
@ -65,12 +65,18 @@ type
|
||||
TWSPageControl = class(TWSCustomNotebook)
|
||||
end;
|
||||
|
||||
{ TWSCustomListView }
|
||||
|
||||
{ TWSCustomListView }
|
||||
|
||||
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;
|
||||
end;
|
||||
|
||||
{ TWSListView }
|
||||
{ TWSListView }
|
||||
|
||||
TWSListView = class(TWSCustomListView)
|
||||
end;
|
||||
@ -118,6 +124,44 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
// TODO: remove when implemented on win32
|
||||
Controls, LMessages;
|
||||
|
||||
|
||||
{ TWSCustomListView }
|
||||
|
||||
procedure TWSCustomListView.ChangeItem(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_CHANGEITEM, ALV, @AIndex);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.DeleteItem(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);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_ADDITEM, ALV, @AIndex);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.SelectItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_SELECTITEM, ALV, AItem);
|
||||
end;
|
||||
|
||||
procedure TWSCustomListView.ShowItem(const ALV: TCustomListView; const AItem: TListItem);
|
||||
begin
|
||||
// TODO: remove when implemented on win32
|
||||
CNSendMessage(LM_LV_SHOWITEM, ALV, AItem);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@ -127,7 +171,7 @@ initialization
|
||||
// RegisterWSComponent(TStatusBar, TWSStatusBar);
|
||||
// RegisterWSComponent(TTabSheet, TWSTabSheet);
|
||||
// RegisterWSComponent(TPageControl, TWSPageControl);
|
||||
// RegisterWSComponent(TCustomListView, TWSCustomListView);
|
||||
RegisterWSComponent(TCustomListView, TWSCustomListView);
|
||||
// RegisterWSComponent(TListView, TWSListView);
|
||||
// RegisterWSComponent(TProgressBar, TWSProgressBar);
|
||||
// RegisterWSComponent(TCustomUpDown, TWSCustomUpDown);
|
||||
|
Loading…
Reference in New Issue
Block a user