mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 03:41:41 +02:00
Gtk2: use better approach for RecreateWnd in TGtk2WSCustomListView, fix rendering of icon view. issue #23171
git-svn-id: trunk@39147 -
This commit is contained in:
parent
5c4e6dcd6c
commit
37eaddb272
@ -175,9 +175,14 @@ begin
|
|||||||
|
|
||||||
ColumnIndex := PLCLIntfCellRenderer(cell)^.ColumnIndex;
|
ColumnIndex := PLCLIntfCellRenderer(cell)^.ColumnIndex;
|
||||||
|
|
||||||
|
AWinControl := GetControl(cell, widget);
|
||||||
|
if (ColumnIndex = -1) and (AWinControl <> nil) and
|
||||||
|
(AWinControl.FCompStyle = csListView) then
|
||||||
|
ColumnIndex := 0;
|
||||||
|
|
||||||
|
|
||||||
if ColumnIndex > -1 then // listview
|
if ColumnIndex > -1 then // listview
|
||||||
begin
|
begin
|
||||||
AWinControl := GetControl(cell, widget);
|
|
||||||
AreaRect := Bounds(background_area^.x, background_area^.y,
|
AreaRect := Bounds(background_area^.x, background_area^.y,
|
||||||
background_area^.Width, background_area^.Height);
|
background_area^.Width, background_area^.Height);
|
||||||
|
|
||||||
@ -218,7 +223,6 @@ begin
|
|||||||
// do not call DefaultGtkRender when we are custom drawn listbox.issue #23093
|
// do not call DefaultGtkRender when we are custom drawn listbox.issue #23093
|
||||||
if ColumnIndex < 0 then
|
if ColumnIndex < 0 then
|
||||||
begin
|
begin
|
||||||
AWinControl := GetControl(cell, widget);
|
|
||||||
if [csDestroying,csLoading,csDesigning]*AWinControl.ComponentState<>[] then
|
if [csDestroying,csLoading,csDesigning]*AWinControl.ComponentState<>[] then
|
||||||
AWinControl := nil;
|
AWinControl := nil;
|
||||||
if AWinControl is TCustomListbox then
|
if AWinControl is TCustomListbox then
|
||||||
@ -227,7 +231,7 @@ begin
|
|||||||
if AWinControl is TCustomCombobox then
|
if AWinControl is TCustomCombobox then
|
||||||
AWinControl := nil;
|
AWinControl := nil;
|
||||||
end;
|
end;
|
||||||
// do default draw only if we are customdrawn.
|
// do default draw only if we are not customdrawn.
|
||||||
if (ColumnIndex > -1) or ((ColumnIndex < 0) and (AWinControl = nil)) then
|
if (ColumnIndex > -1) or ((ColumnIndex < 0) and (AWinControl = nil)) then
|
||||||
CellClass^.DefaultGtkRender(cell, Window, Widget, background_area, cell_area,
|
CellClass^.DefaultGtkRender(cell, Window, Widget, background_area, cell_area,
|
||||||
expose_area, flags);
|
expose_area, flags);
|
||||||
|
@ -1341,7 +1341,10 @@ begin
|
|||||||
with Widgets^ do
|
with Widgets^ do
|
||||||
begin
|
begin
|
||||||
if not gtk_widget_realized(MainView) then
|
if not gtk_widget_realized(MainView) then
|
||||||
|
begin
|
||||||
|
// DebugLn('WARNING: TGtk2WSCustomListView.ItemSetImage: MainView is not realized.');
|
||||||
Exit;
|
Exit;
|
||||||
|
end;
|
||||||
Path := gtk_tree_path_new_from_indices(AIndex, -1);
|
Path := gtk_tree_path_new_from_indices(AIndex, -1);
|
||||||
if GTK_IS_TREE_VIEW(MainView) then
|
if GTK_IS_TREE_VIEW(MainView) then
|
||||||
gtk_tree_view_get_cell_area(PGtkTreeView(MainView), Path, nil, @ItemRect)
|
gtk_tree_view_get_cell_area(PGtkTreeView(MainView), Path, nil, @ItemRect)
|
||||||
@ -1683,7 +1686,9 @@ begin
|
|||||||
TreeSelection := PGtkTreeSelection(gtk_tree_view_get_selection(PGtkTreeView(MainView)));
|
TreeSelection := PGtkTreeSelection(gtk_tree_view_get_selection(PGtkTreeView(MainView)));
|
||||||
end;
|
end;
|
||||||
g_object_unref(G_OBJECT(TreeModel));
|
g_object_unref(G_OBJECT(TreeModel));
|
||||||
//gtk_tree_view_set_fixed_height_mode(PGtkTreeView(MainView), True);
|
|
||||||
|
// we added +1 because Ord(vsIcon) returns 0, so it's nil ptr
|
||||||
|
g_object_set_data(PGObject(MainView),'lcllistviewstyle', gpointer(PtrInt(Ord(TLVHack(AWinControl).ViewStyle) + 1)));
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(ScrollWidget),PGtkWidget(MainView));
|
gtk_container_add(GTK_CONTAINER(ScrollWidget),PGtkWidget(MainView));
|
||||||
|
|
||||||
@ -1699,17 +1704,9 @@ begin
|
|||||||
Dispose(OrigScrollingData);
|
Dispose(OrigScrollingData);
|
||||||
WidgetInfo^.CoreWidget := PGtkWidget(MainView);
|
WidgetInfo^.CoreWidget := PGtkWidget(MainView);
|
||||||
g_object_set_data(Pointer(MainView), 'widgetinfo', WidgetInfo);
|
g_object_set_data(Pointer(MainView), 'widgetinfo', WidgetInfo);
|
||||||
//SetMainWidget(ScrollWidget, MainView);
|
|
||||||
//GetWidgetInfo(ScrollWidget, True)^.CoreWidget := PGtkWidget(MainView);
|
|
||||||
gtk_widget_show_all(PGtkWidget(MainView));
|
gtk_widget_show_all(PGtkWidget(MainView));
|
||||||
SetListCallbacks(PGtkWidget(ScrollWidget), Widgets, Widgets^.WidgetInfo);
|
SetListCallbacks(PGtkWidget(ScrollWidget), Widgets, Widgets^.WidgetInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
|
||||||
New(Widgets);
|
|
||||||
Widgets^.WidgetInfo := GetWidgetInfo(ScrollWidget);
|
|
||||||
SetCallbacks(PGtkWidget(ScrollWidget), Widgets^, Widgets^.WidgetInfo);
|
|
||||||
*)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomListView.DestroyHandle(const AWinControl: TWinControl);
|
class procedure TGtk2WSCustomListView.DestroyHandle(const AWinControl: TWinControl);
|
||||||
@ -2266,7 +2263,10 @@ end;
|
|||||||
|
|
||||||
class procedure TGtk2WSCustomListView.SetViewStyle(const ALV: TCustomListView;
|
class procedure TGtk2WSCustomListView.SetViewStyle(const ALV: TCustomListView;
|
||||||
const AValue: TViewStyle);
|
const AValue: TViewStyle);
|
||||||
|
|
||||||
|
var
|
||||||
|
APtrIntData: PtrInt;
|
||||||
|
|
||||||
procedure ShowColumns(const Widgets: PTVWidgets; const Show: Boolean);
|
procedure ShowColumns(const Widgets: PTVWidgets; const Show: Boolean);
|
||||||
var
|
var
|
||||||
List: PGList;
|
List: PGList;
|
||||||
@ -2297,9 +2297,11 @@ begin
|
|||||||
then Exit;
|
then Exit;
|
||||||
|
|
||||||
GetCommonTreeViewWidgets({%H-}PGtkWidget(ALV.Handle), Widgets{%H-});
|
GetCommonTreeViewWidgets({%H-}PGtkWidget(ALV.Handle), Widgets{%H-});
|
||||||
|
if g_object_get_data(PGObject(Widgets^.MainView),'lcllistviewstyle') <> nil then
|
||||||
if (GTK_IS_TREE_VIEW(Widgets^.MainView) and (AValue in [vsIcon, vsSmallIcon])) or
|
APtrIntData := PtrInt(g_object_get_data(PGObject(Widgets^.MainView),'lcllistviewstyle'))
|
||||||
(GTK_IS_ICON_VIEW(Widgets^.MainView) and (AValue in [vsReport, vsList])) then
|
else
|
||||||
|
APtrIntData := -1;
|
||||||
|
if (APtrIntData <> -1) and (APtrIntData - 1 <> Ord(AValue)) then
|
||||||
begin
|
begin
|
||||||
// we have to free the GtkTreeView and Create GtkIconView etc depending on the new style
|
// we have to free the GtkTreeView and Create GtkIconView etc depending on the new style
|
||||||
//RecreateMainView(ALV);
|
//RecreateMainView(ALV);
|
||||||
|
Loading…
Reference in New Issue
Block a user