mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-29 15:09:36 +02:00
Gtk2: implemented TGtk2CustomListView.ItemDisplayRect, implemented editor for listview with style vsSmallIcon, vsIcon. issue #23015
git-svn-id: trunk@38897 -
This commit is contained in:
parent
0eef8e9087
commit
53848b11b5
@ -323,6 +323,7 @@ function gtk_icon_view_get_cursor(icon_view: PGtkIconView; var path: PGtkTreePat
|
|||||||
procedure gtk_icon_view_set_cursor(icon_view: PGtkIconView; path: PGtkTreePath; cell: PGtkCellRenderer; start_editing: gboolean); cdecl; external gtklib;
|
procedure gtk_icon_view_set_cursor(icon_view: PGtkIconView; path: PGtkTreePath; cell: PGtkCellRenderer; start_editing: gboolean); cdecl; external gtklib;
|
||||||
function gtk_tree_view_get_visible_range(tree_view: PGtkTreeView; out start_path, endpath: PGtkTreePath): gboolean; cdecl; external gtklib;
|
function gtk_tree_view_get_visible_range(tree_view: PGtkTreeView; out start_path, endpath: PGtkTreePath): gboolean; cdecl; external gtklib;
|
||||||
function gtk_icon_view_get_visible_range(tree_view: PGtkTreeView; out start_path, endpath: PGtkTreePath): gboolean; cdecl; external gtklib;
|
function gtk_icon_view_get_visible_range(tree_view: PGtkTreeView; out start_path, endpath: PGtkTreePath): gboolean; cdecl; external gtklib;
|
||||||
|
function gtk_icon_view_get_item_at_pos(icon_view: PGtkIconView; x: gint; y: gint; var path: PGtkTreePath; var cell: PGtkCellRenderer): gboolean; cdecl; external gtklib;
|
||||||
|
|
||||||
procedure gtk_tree_view_column_queue_resize(tree_column: PGtkTreeViewColumn); cdecl; external gtklib;
|
procedure gtk_tree_view_column_queue_resize(tree_column: PGtkTreeViewColumn); cdecl; external gtklib;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ uses
|
|||||||
GLib2, Gtk2, Gdk2, Gdk2pixbuf,
|
GLib2, Gtk2, Gdk2, Gdk2pixbuf,
|
||||||
// RTL, FCL, LCL
|
// RTL, FCL, LCL
|
||||||
ComCtrls, Classes, LCLType, LMessages, Controls, Graphics,
|
ComCtrls, Classes, LCLType, LMessages, Controls, Graphics,
|
||||||
StdCtrls, Forms, LCLProc, ImgList, Math, Sysutils, InterfaceBase,
|
StdCtrls, Forms, LCLProc, LCLIntf, ImgList, Math, Sysutils, InterfaceBase,
|
||||||
// widgetset
|
// widgetset
|
||||||
WSComCtrls, WSLCLClasses, WSControls, WSProc,
|
WSComCtrls, WSLCLClasses, WSControls, WSProc,
|
||||||
// GtkWidgetset
|
// GtkWidgetset
|
||||||
|
@ -470,6 +470,8 @@ function Gtk2TreeViewEditorEvent(widget: PGtkWidget; event: PGdkEvent; data: GPo
|
|||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
Alloc: TGtkAllocation;
|
Alloc: TGtkAllocation;
|
||||||
|
w: PGtkWidget;
|
||||||
|
AOrientation: TGtkOrientation;
|
||||||
begin
|
begin
|
||||||
Result := CallBackDefaultReturn;
|
Result := CallBackDefaultReturn;
|
||||||
case event^._type of
|
case event^._type of
|
||||||
@ -490,6 +492,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
gtk_widget_size_allocate(Widget, @Alloc);
|
gtk_widget_size_allocate(Widget, @Alloc);
|
||||||
end;
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
w := gtk_widget_get_parent(Widget);
|
||||||
|
if Assigned(w) and GTK_IS_ICON_VIEW(w) then
|
||||||
|
begin
|
||||||
|
//gtk2 does not layout items correctly when iconArrangement is iaTop.
|
||||||
|
//so we force it to do so.
|
||||||
|
AOrientation := gtk_icon_view_get_orientation(PGtkIconView(w));
|
||||||
|
if AOrientation = GTK_ORIENTATION_HORIZONTAL then
|
||||||
|
gtk_icon_view_set_orientation(PGtkIconView(w), GTK_ORIENTATION_VERTICAL)
|
||||||
|
else
|
||||||
|
gtk_icon_view_set_orientation(PGtkIconView(w), GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
gtk_icon_view_set_orientation(PGtkIconView(w), AOrientation)
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -520,8 +536,7 @@ begin
|
|||||||
|
|
||||||
// gtk2 is pretty tricky about adding editor into control
|
// gtk2 is pretty tricky about adding editor into control
|
||||||
if (AParent.FCompStyle = csListView) and
|
if (AParent.FCompStyle = csListView) and
|
||||||
(TWinControl(AControl).FCompStyle = csEdit) and
|
(TWinControl(AControl).FCompStyle = csEdit) then
|
||||||
GTK_IS_TREE_VIEW(gtk_bin_get_child(PGtkBin(PFixed))) then
|
|
||||||
begin
|
begin
|
||||||
ChildWidget := {%H-}PGtkWidget(TWinControl(AControl).Handle);
|
ChildWidget := {%H-}PGtkWidget(TWinControl(AControl).Handle);
|
||||||
ParentWidget := gtk_bin_get_child(PGtkBin(PFixed)); // treeview
|
ParentWidget := gtk_bin_get_child(PGtkBin(PFixed)); // treeview
|
||||||
|
@ -1055,8 +1055,11 @@ var
|
|||||||
ItemRect: TGdkRectangle;
|
ItemRect: TGdkRectangle;
|
||||||
Column: PGtkTreeViewColumn;
|
Column: PGtkTreeViewColumn;
|
||||||
Path: PGtkTreePath;
|
Path: PGtkTreePath;
|
||||||
L, T, W, H: GInt;
|
X, Y, L, T, W, H: GInt;
|
||||||
ARect: TGdkRectangle;
|
ARect: TGdkRectangle;
|
||||||
|
R: TRect;
|
||||||
|
ANewCell: PGtkCellRenderer;
|
||||||
|
ANewPath: PGtkTreePath;
|
||||||
begin
|
begin
|
||||||
Result := Rect(0, 0, 0, 0);
|
Result := Rect(0, 0, 0, 0);
|
||||||
if not WSCheckHandleAllocated(ALV, 'ItemDisplayRect') then
|
if not WSCheckHandleAllocated(ALV, 'ItemDisplayRect') then
|
||||||
@ -1083,11 +1086,46 @@ begin
|
|||||||
else
|
else
|
||||||
if GTK_IS_ICON_VIEW(MainView) then
|
if GTK_IS_ICON_VIEW(MainView) then
|
||||||
begin
|
begin
|
||||||
// TODO: iconview
|
|
||||||
ItemRect.x := 0;
|
ItemRect.x := 0;
|
||||||
ItemRect.y := 0;
|
ItemRect.y := 0;
|
||||||
ItemRect.width := gtk_icon_view_get_item_width(PGtkIconView(MainView));
|
ItemRect.width := gtk_icon_view_get_item_width(PGtkIconView(MainView));
|
||||||
ItemRect.height := 0;
|
ItemRect.height := 0;
|
||||||
|
if Path <> nil then
|
||||||
|
begin
|
||||||
|
ANewPath := nil;
|
||||||
|
ANewCell := nil;
|
||||||
|
R := ALV.ClientRect;
|
||||||
|
l := 0;
|
||||||
|
t := 0;
|
||||||
|
Result := Rect(0, 0, 0, 0);
|
||||||
|
while t < R.Bottom - 1 do
|
||||||
|
begin
|
||||||
|
l := 0;
|
||||||
|
while l < R.Right - 1 do
|
||||||
|
begin
|
||||||
|
if gtk_icon_view_get_item_at_pos(PGtkIconView(MainView), l, t, ANewPath, ANewCell) then
|
||||||
|
begin
|
||||||
|
if (ANewPath <> nil) and (gtk_tree_path_compare(Path, ANewPath) = 0) then
|
||||||
|
begin
|
||||||
|
gtk_cell_renderer_get_size(ANewCell, PGtkWidget(MainView), @ItemRect, @x,@y,@w,@h);
|
||||||
|
Result := Rect(l, t, w + l, h + t);
|
||||||
|
ItemRect := GdkRectFromRect(Result);
|
||||||
|
if ANewPath <> nil then
|
||||||
|
gtk_tree_path_free(ANewPath);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if ANewPath <> nil then
|
||||||
|
gtk_tree_path_free(ANewPath);
|
||||||
|
end;
|
||||||
|
inc(l, 1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
inc(t, 1);
|
||||||
|
|
||||||
|
if not IsRectEmpty(Result) then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
gtk_tree_path_free(Path);
|
gtk_tree_path_free(Path);
|
||||||
|
Loading…
Reference in New Issue
Block a user