mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 17:19:15 +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 FormWidget: Pointer; AWidgetInfo: PWidgetInfo = nil): Pointer;
|
||||||
var
|
var
|
||||||
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
ScrolledWidget, ClientAreaWidget: PGtkWidget;
|
||||||
WindowStyle: PGtkStyle;
|
// WindowStyle: PGtkStyle;
|
||||||
Adjustment: PGtkAdjustment;
|
Adjustment: PGtkAdjustment;
|
||||||
begin
|
begin
|
||||||
// Create the VBox. We need that to place controls outside
|
// Create the VBox. We need that to place controls outside
|
||||||
@ -7592,8 +7592,10 @@ begin
|
|||||||
gtk_widget_show(ScrolledWidget);
|
gtk_widget_show(ScrolledWidget);
|
||||||
|
|
||||||
ClientAreaWidget := gtk_layout_new(nil, nil);
|
ClientAreaWidget := gtk_layout_new(nil, nil);
|
||||||
WindowStyle := GetStyle(lgsWindow);
|
// issue #16183: not sure why the GtkLayout is given a GtkWindow style here,
|
||||||
gtk_widget_set_style(ClientAreaWidget, WindowStyle);
|
// this prevents setting color to the GtkLayout
|
||||||
|
// WindowStyle := GetStyle(lgsWindow);
|
||||||
|
// gtk_widget_set_style(ClientAreaWidget, WindowStyle);
|
||||||
//debugln('CreateFormContents Style=',GetStyleDebugReport(WindowStyle));
|
//debugln('CreateFormContents Style=',GetStyleDebugReport(WindowStyle));
|
||||||
gtk_container_add(PGtkContainer(ScrolledWidget), ClientAreaWidget);
|
gtk_container_add(PGtkContainer(ScrolledWidget), ClientAreaWidget);
|
||||||
|
|
||||||
|
@ -2307,7 +2307,10 @@ begin
|
|||||||
|
|
||||||
if ChangeBGColor then
|
if ChangeBGColor then
|
||||||
begin
|
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
|
NewColor := nil
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
@ -863,8 +863,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomForm.SetColor(const AWinControl: TWinControl);
|
class procedure TGtk2WSCustomForm.SetColor(const AWinControl: TWinControl);
|
||||||
|
var
|
||||||
|
AScrolled: PGtkWidget;
|
||||||
|
AColor: TColor;
|
||||||
begin
|
begin
|
||||||
TGtk2WSWinControl.SetColor(AWinControl);
|
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;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomForm.SetRealPopupParent(
|
class procedure TGtk2WSCustomForm.SetRealPopupParent(
|
||||||
@ -970,12 +989,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSScrollingWinControl.SetColor(const AWinControl: TWinControl);
|
class procedure TGtk2WSScrollingWinControl.SetColor(const AWinControl: TWinControl);
|
||||||
|
var
|
||||||
|
AColor: TColor;
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'SetColor')
|
if not WSCheckHandleAllocated(AWinControl, 'SetColor')
|
||||||
then Exit;
|
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,
|
Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AWinControl.Handle)^.child,
|
||||||
clNone, AWinControl.Color,
|
clNone, AColor,
|
||||||
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
||||||
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
||||||
end;
|
end;
|
||||||
|
@ -50,6 +50,7 @@ type
|
|||||||
TWSScrollingWinControl = class(TWSWinControl)
|
TWSScrollingWinControl = class(TWSWinControl)
|
||||||
published
|
published
|
||||||
// procedure ScrollBy is moved to TWSWinControl.
|
// procedure ScrollBy is moved to TWSWinControl.
|
||||||
|
class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWSScrollBox }
|
{ TWSScrollBox }
|
||||||
@ -140,6 +141,19 @@ type
|
|||||||
|
|
||||||
implementation
|
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 }
|
{ TWSCustomForm }
|
||||||
|
|
||||||
class procedure TWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
|
class procedure TWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
|
||||||
|
Loading…
Reference in New Issue
Block a user