mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 16:59:20 +02:00
LCL-GTK3: Display Listview icons in vsIcon mode. Issue #38942, patch by Anton Kavalenka.
git-svn-id: trunk@65215 -
This commit is contained in:
parent
229352c40d
commit
dadb9c7e8d
@ -592,9 +592,11 @@ type
|
|||||||
procedure SetColumnVisible(AIndex: Integer; {%H-}AColumn: TListColumn; AVisible: Boolean);
|
procedure SetColumnVisible(AIndex: Integer; {%H-}AColumn: TListColumn; AVisible: Boolean);
|
||||||
procedure ColumnSetSortIndicator(const AIndex: Integer; const {%H-}AColumn: TListColumn; const ASortIndicator: TSortIndicator);
|
procedure ColumnSetSortIndicator(const AIndex: Integer; const {%H-}AColumn: TListColumn; const ASortIndicator: TSortIndicator);
|
||||||
|
|
||||||
|
procedure UpdateItem(AIndex:integer;AItem: TListItem);
|
||||||
procedure ItemDelete(AIndex: Integer);
|
procedure ItemDelete(AIndex: Integer);
|
||||||
procedure ItemInsert(AIndex: Integer; AItem: TListItem);
|
procedure ItemInsert(AIndex: Integer; AItem: TListItem);
|
||||||
procedure ItemSetText(AIndex, ASubIndex: Integer; AItem: TListItem; const AText: String);
|
procedure ItemSetText(AIndex, ASubIndex: Integer; AItem: TListItem; const AText: String);
|
||||||
|
procedure ItemSetImage(AIndex, ASubIndex: Integer; AItem: TListItem);
|
||||||
procedure ItemSetState(const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState;
|
procedure ItemSetState(const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState;
|
||||||
const AIsSet: Boolean);
|
const AIsSet: Boolean);
|
||||||
function ItemGetState(const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState;
|
function ItemGetState(const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState;
|
||||||
@ -1153,8 +1155,7 @@ begin
|
|||||||
if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
|
if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
|
||||||
|
|
||||||
|
|
||||||
TGtk3Widget(Data).GtkEventMouse(Widget , Event);
|
Result:=TGtk3Widget(Data).GtkEventMouse(Widget , Event);
|
||||||
Result:=true;
|
|
||||||
end;
|
end;
|
||||||
GDK_2BUTTON_PRESS:
|
GDK_2BUTTON_PRESS:
|
||||||
begin
|
begin
|
||||||
@ -6261,11 +6262,46 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGtk3ListView.UpdateItem(AIndex:integer;AItem: TListItem);
|
||||||
|
var
|
||||||
|
Path: PGtkTreePath;
|
||||||
|
ItemRect: TGdkRectangle;
|
||||||
|
AModel: PGtkTreeModel;
|
||||||
|
Iter: TGtkTreeIter;
|
||||||
|
bmp:TBitmap;
|
||||||
|
pxb:PGdkPixbuf;
|
||||||
|
begin
|
||||||
|
if IsTreeView then
|
||||||
|
begin
|
||||||
|
Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
|
||||||
|
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
|
||||||
|
gtk_tree_path_free(Path);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
|
||||||
|
AModel:=PGtkIconView(GetContainerWidget)^.get_model;
|
||||||
|
AModel^.get_iter(@iter,path);
|
||||||
|
|
||||||
|
bmp:=TBitmap.Create;
|
||||||
|
TListView(LCLObject).LargeImages.GetBitmap(AItem.ImageIndex,bmp);
|
||||||
|
pxb:=TGtk3Image(bmp.Handle).Handle;
|
||||||
|
gtk_list_store_set(PGtkListStore(AModel), @Iter,
|
||||||
|
[0, Pointer(AItem),
|
||||||
|
1, PChar(AItem.Caption),
|
||||||
|
2, pxb, -1] );
|
||||||
|
fImages.Add(bmp);
|
||||||
|
|
||||||
|
gtk_tree_path_free(Path);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGtk3ListView.ItemSetText(AIndex, ASubIndex: Integer;
|
procedure TGtk3ListView.ItemSetText(AIndex, ASubIndex: Integer;
|
||||||
AItem: TListItem; const AText: String);
|
AItem: TListItem; const AText: String);
|
||||||
var
|
var
|
||||||
Path: PGtkTreePath;
|
Path: PGtkTreePath;
|
||||||
ItemRect: TGdkRectangle;
|
ItemRect: TGdkRectangle;
|
||||||
|
AModel: PGtkTreeModel;
|
||||||
|
Iter: TGtkTreeIter;
|
||||||
begin
|
begin
|
||||||
if not IsWidgetOK then
|
if not IsWidgetOK then
|
||||||
exit;
|
exit;
|
||||||
@ -6276,7 +6312,32 @@ begin
|
|||||||
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
|
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
|
||||||
gtk_tree_path_free(Path);
|
gtk_tree_path_free(Path);
|
||||||
end else
|
end else
|
||||||
ItemRect.Height := 1;
|
begin
|
||||||
|
UpdateItem(AIndex,AItem);
|
||||||
|
end;
|
||||||
|
if GetContainerWidget^.get_visible and (ItemRect.height <> 0) then // item is visible
|
||||||
|
GetContainerWidget^.queue_draw;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGtk3ListView.ItemSetImage(AIndex, ASubIndex: Integer; AItem: TListItem);
|
||||||
|
var
|
||||||
|
Path: PGtkTreePath;
|
||||||
|
ItemRect: TGdkRectangle;
|
||||||
|
AModel: PGtkTreeModel;
|
||||||
|
Iter: TGtkTreeIter;
|
||||||
|
begin
|
||||||
|
if not IsWidgetOK then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
if IsTreeView then
|
||||||
|
begin
|
||||||
|
Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
|
||||||
|
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
|
||||||
|
gtk_tree_path_free(Path);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
UpdateItem(AIndex,AItem);
|
||||||
|
end;
|
||||||
if GetContainerWidget^.get_visible and (ItemRect.height <> 0) then // item is visible
|
if GetContainerWidget^.get_visible and (ItemRect.height <> 0) then // item is visible
|
||||||
GetContainerWidget^.queue_draw;
|
GetContainerWidget^.queue_draw;
|
||||||
end;
|
end;
|
||||||
|
@ -689,8 +689,11 @@ class procedure TGtk3WSCustomListView.ItemSetImage(const ALV: TCustomListView;
|
|||||||
const AIndex: Integer; const AItem: TListItem; const ASubIndex,
|
const AIndex: Integer; const AItem: TListItem; const ASubIndex,
|
||||||
AImageIndex: Integer);
|
AImageIndex: Integer);
|
||||||
begin
|
begin
|
||||||
// DebugLn('TGtk3WSCustomListView.ItemSetImage ');
|
if not WSCheckHandleAllocated(ALV, 'ItemSetImage') then
|
||||||
// inherited ItemSetImage(ALV, AIndex, AItem, ASubIndex, AImageIndex);
|
Exit;
|
||||||
|
TGtk3ListView(ALV.Handle).BeginUpdate;
|
||||||
|
TGtk3ListView(ALV.Handle).ItemSetImage(AIndex,ASubIndex, AItem);
|
||||||
|
TGtk3ListView(ALV.Handle).EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk3WSCustomListView.ItemSetState(const ALV: TCustomListView;
|
class procedure TGtk3WSCustomListView.ItemSetState(const ALV: TCustomListView;
|
||||||
|
Loading…
Reference in New Issue
Block a user