mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 16:59:20 +02:00
LCL-GTK2: Paint a form with one color also after scrolling. Issue #16183, patch from Joeny Ang.
git-svn-id: trunk@64167 -
This commit is contained in:
parent
b1afd41fb2
commit
51302252eb
@ -7575,7 +7575,7 @@ function CreateFormContents(AForm: TCustomForm;
|
||||
var FormWidget: Pointer; AWidgetInfo: PWidgetInfo = nil): Pointer;
|
||||
var
|
||||
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
||||
WindowStyle: PGtkStyle;
|
||||
// WindowStyle: PGtkStyle;
|
||||
Adjustment: PGtkAdjustment;
|
||||
begin
|
||||
// Create the VBox. We need that to place controls outside
|
||||
@ -7592,8 +7592,10 @@ begin
|
||||
gtk_widget_show(ScrolledWidget);
|
||||
|
||||
ClientAreaWidget := gtk_layout_new(nil, nil);
|
||||
WindowStyle := GetStyle(lgsWindow);
|
||||
gtk_widget_set_style(ClientAreaWidget, WindowStyle);
|
||||
// issue #16183: not sure why the GtkLayout is given a GtkWindow style here,
|
||||
// this prevents setting color to the GtkLayout
|
||||
// WindowStyle := GetStyle(lgsWindow);
|
||||
// gtk_widget_set_style(ClientAreaWidget, WindowStyle);
|
||||
//debugln('CreateFormContents Style=',GetStyleDebugReport(WindowStyle));
|
||||
gtk_container_add(PGtkContainer(ScrolledWidget), ClientAreaWidget);
|
||||
|
||||
|
@ -2307,7 +2307,10 @@ begin
|
||||
|
||||
if ChangeBGColor then
|
||||
begin
|
||||
if (BGColor = clDefault) or (BGColor = clBtnFace) then
|
||||
// setting bg color to nil will cancel previous calls to gtk_widget_modify_bg()
|
||||
// cannot use nil on a GtkLayout (issue #16183)
|
||||
if not GTK_IS_LAYOUT(AWidget) and
|
||||
((BGColor = clDefault) or (BGColor = clBtnFace)) then
|
||||
NewColor := nil
|
||||
else
|
||||
begin
|
||||
|
@ -863,8 +863,27 @@ begin
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomForm.SetColor(const AWinControl: TWinControl);
|
||||
var
|
||||
AScrolled: PGtkWidget;
|
||||
AColor: TColor;
|
||||
begin
|
||||
TGtk2WSWinControl.SetColor(AWinControl);
|
||||
|
||||
// Forms: GtkWindow->GtkVBox->gtkScrolledWindow->GtkLayout
|
||||
// we need to set the color of the GtkLayout so that the whole viewport
|
||||
// will be filled (issue #16183)
|
||||
AScrolled := g_object_get_data({%H-}PGObject(AWinControl.Handle), odnScrollArea);
|
||||
if GTK_IS_SCROLLED_WINDOW(AScrolled) and
|
||||
GTK_IS_LAYOUT({%H-}PGtkBin(AScrolled)^.child) then
|
||||
begin
|
||||
AColor := AWinControl.Color;
|
||||
if AColor = clDefault then
|
||||
AColor := GetDefaultColor(AWinControl, dctBrush);
|
||||
Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AScrolled)^.child,
|
||||
clNone, AColor,
|
||||
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
||||
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomForm.SetRealPopupParent(
|
||||
@ -970,12 +989,20 @@ begin
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSScrollingWinControl.SetColor(const AWinControl: TWinControl);
|
||||
var
|
||||
AColor: TColor;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'SetColor')
|
||||
then Exit;
|
||||
|
||||
// ScrollingWinControl: GtkScrolledWindow->GtkLayout
|
||||
// we need to set the color of the GtkLayout so that the whole viewport
|
||||
// will be filled (issue #16183)
|
||||
AColor := AWinControl.Color;
|
||||
if AColor = clDefault then
|
||||
AColor := GetDefaultColor(AWinControl, dctBrush);
|
||||
Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AWinControl.Handle)^.child,
|
||||
clNone, AWinControl.Color,
|
||||
clNone, AColor,
|
||||
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
||||
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
||||
end;
|
||||
|
@ -50,6 +50,7 @@ type
|
||||
TWSScrollingWinControl = class(TWSWinControl)
|
||||
published
|
||||
// procedure ScrollBy is moved to TWSWinControl.
|
||||
class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
|
||||
end;
|
||||
|
||||
{ TWSScrollBox }
|
||||
@ -140,6 +141,19 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
{ TWSScrollingWinControl }
|
||||
|
||||
class function TWSScrollingWinControl.GetDefaultColor(const AControl: TControl;
|
||||
const ADefaultColorType: TDefaultColorType): TColor;
|
||||
const
|
||||
DefColors: array[TDefaultColorType] of TColor = (
|
||||
{ dctBrush } clForm,
|
||||
{ dctFont } clBtnText
|
||||
);
|
||||
begin
|
||||
Result := DefColors[ADefaultColorType];
|
||||
end;
|
||||
|
||||
{ TWSCustomForm }
|
||||
|
||||
class procedure TWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
|
||||
|
Loading…
Reference in New Issue
Block a user