mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 14:39:09 +02:00
Gtk3: fixed TPageControl with customized image index. Patch by Anton Kavalenka. issue #41579
This commit is contained in:
parent
a4bfdfc8ff
commit
16f6a8bc06
@ -5297,16 +5297,34 @@ var
|
|||||||
Gtk3Page: TGtk3Page;
|
Gtk3Page: TGtk3Page;
|
||||||
AMinSize, ANaturalSize: gint;
|
AMinSize, ANaturalSize: gint;
|
||||||
Bmp: TBitmap;
|
Bmp: TBitmap;
|
||||||
|
ImageIndex:integer;
|
||||||
|
HasIcon: Boolean;
|
||||||
|
IconSize: Types.TSize;
|
||||||
|
TheNotebook:TCustomTabControl;
|
||||||
|
Appi:integer;
|
||||||
begin
|
begin
|
||||||
if IsWidgetOK then
|
if IsWidgetOK then
|
||||||
begin
|
begin
|
||||||
Gtk3Page := TGtk3Page(ACustomPage.Handle);
|
Gtk3Page := TGtk3Page(ACustomPage.Handle);
|
||||||
Gtk3Page.CloseButtonVisible := nboShowCloseButtons in TCustomTabControl(LCLObject).Options;
|
Gtk3Page.CloseButtonVisible := nboShowCloseButtons in TCustomTabControl(LCLObject).Options;
|
||||||
if Assigned(TCustomTabControl(LCLObject).Images) and (ACustomPage.ImageIndex >= 0) and
|
|
||||||
(ACustomPage.ImageIndex < TCustomTabControl(LCLObject).Images.Count) then
|
TheNoteBook:=TCustomTabControl(LCLObject);
|
||||||
|
HasIcon:=false;
|
||||||
|
IconSize:=Size(0,0);
|
||||||
|
ImageIndex := TheNoteBook.GetImageIndex(AIndex);
|
||||||
|
Appi:=TheNoteBook.Font.PixelsPerInch;
|
||||||
|
if (TheNoteBook.Images<>nil)
|
||||||
|
and (ImageIndex >= 0)
|
||||||
|
and (ImageIndex < TheNoteBook.Images.Count) then
|
||||||
|
begin
|
||||||
|
// page has valid image
|
||||||
|
IconSize := TheNoteBook.Images.SizeForPPI[TheNoteBook.ImagesWidth, Appi];
|
||||||
|
HasIcon := (IconSize.cx>0) and (IconSize.cy>0);
|
||||||
|
end;
|
||||||
|
if HasIcon then
|
||||||
begin
|
begin
|
||||||
Bmp := TBitmap.Create;
|
Bmp := TBitmap.Create;
|
||||||
TCustomTabControl(LCLObject).Images.GetBitmap(ACustomPage.ImageIndex, Bmp);
|
TCustomTabControl(LCLObject).Images.ResolutionForPPI[IconSize.cx,Appi,1].GetBitmap(ImageIndex, Bmp);
|
||||||
Gtk3Page.setTabImage(Bmp);
|
Gtk3Page.setTabImage(Bmp);
|
||||||
Bmp.Free;
|
Bmp.Free;
|
||||||
end else
|
end else
|
||||||
|
Loading…
Reference in New Issue
Block a user