mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 18:12:30 +02:00
gtk2: don't use GtkFrame for TScrollingWinControl since GtkScrolledWindow can draw shadow itself (fixes also #0013892)
git-svn-id: trunk@20365 -
This commit is contained in:
parent
d5c602d182
commit
72c3e1a908
@ -60,8 +60,6 @@ type
|
||||
|
||||
TGtkWSCustomFrame = class(TWSCustomFrame)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
end;
|
||||
|
||||
{ TGtkWSFrame }
|
||||
@ -517,60 +515,4 @@ begin
|
||||
SetCallbacks(P, WidgetInfo);
|
||||
end;
|
||||
|
||||
{ TGtkWSCustomFrame }
|
||||
|
||||
class function TGtkWSCustomFrame.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle;
|
||||
var
|
||||
Scrolled: PGtkScrolledWindow;
|
||||
Layout: PGtkWidget;
|
||||
WidgetInfo: PWidgetInfo;
|
||||
Adjustment: PGtkAdjustment;
|
||||
begin
|
||||
// create a gtk_scrolled_window for the scrollbars
|
||||
Scrolled := PGtkScrolledWindow(gtk_scrolled_window_new(nil, nil));
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS(Scrolled^.hscrollbar, GTK_CAN_FOCUS);
|
||||
GTK_WIDGET_UNSET_FLAGS(Scrolled^.vscrollbar, GTK_CAN_FOCUS);
|
||||
gtk_scrolled_window_set_policy(Scrolled, GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||
gtk_object_set_data(PGtkObject(Scrolled), odnScrollArea, Scrolled);
|
||||
|
||||
{$IFDEF DebugLCLComponents}
|
||||
DebugGtkWidgets.MarkCreated(Scrolled, dbgsName(AWinControl));
|
||||
{$ENDIF}
|
||||
|
||||
WidgetInfo := CreateWidgetInfo(Scrolled, AWinControl, AParams);
|
||||
|
||||
Adjustment := gtk_scrolled_window_get_vadjustment(Scrolled);
|
||||
if Adjustment <> nil then
|
||||
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar, Scrolled^.vscrollbar);
|
||||
|
||||
Adjustment := gtk_scrolled_window_get_hadjustment(Scrolled);
|
||||
if Adjustment <> nil then
|
||||
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar, Scrolled^.hscrollbar);
|
||||
|
||||
// create a gtk_layout for the client area, so childs can be added at
|
||||
// free x,y positions and the scrollbars automatically scrolls the childs
|
||||
Layout := gtk_layout_new(nil, nil);
|
||||
gtk_container_add(PGTKContainer(Scrolled), Layout);
|
||||
gtk_widget_show(Layout);
|
||||
SetFixedWidget(Scrolled, Layout);
|
||||
SetMainWidget(Scrolled, Layout);
|
||||
|
||||
Result := TLCLIntfHandle(PtrUInt(Scrolled));
|
||||
Set_RC_Name(AWinControl, PGtkWidget(Scrolled));
|
||||
TGtkWSScrollingWinControl.SetCallBacks(PGtkWidget(Scrolled), WidgetInfo);
|
||||
end;
|
||||
|
||||
class procedure TGtkWSCustomFrame.SetColor(const AWinControl: TWinControl);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'SetColor')
|
||||
then Exit;
|
||||
|
||||
GtkWidgetSet.SetWidgetColor(PGtkBin(AWinControl.Handle)^.child,
|
||||
clNone, AWinControl.Color,
|
||||
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
||||
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -304,24 +304,30 @@ begin
|
||||
// Only do the scrollbars, leave the core to the default (we might have a viewport)
|
||||
TGtkPrivateWidget.SetZPosition(AWinControl, APosition);
|
||||
|
||||
if GtkWidgetIsA(Widget,gtk_frame_get_type) then begin
|
||||
ScrollWidget := PGtkScrolledWindow(PGtkFrame(Widget)^.Bin.Child);
|
||||
if ScrollWidget<>nil then begin
|
||||
case APosition of
|
||||
wszpBack: begin
|
||||
// gdk_window_lower(WidgetInfo^.CoreWidget^.Window);
|
||||
if ScrollWidget^.hscrollbar <> nil
|
||||
then gdk_window_lower(ScrollWidget^.hscrollbar^.Window);
|
||||
if ScrollWidget^.vscrollbar <> nil
|
||||
then gdk_window_lower(ScrollWidget^.vscrollbar^.Window);
|
||||
end;
|
||||
wszpFront: begin
|
||||
// gdk_window_raise(WidgetInfo^.CoreWidget^.Window);
|
||||
if ScrollWidget^.hscrollbar <> nil
|
||||
then gdk_window_raise(ScrollWidget^.hscrollbar^.Window);
|
||||
if ScrollWidget^.vscrollbar <> nil
|
||||
then gdk_window_raise(ScrollWidget^.vscrollbar^.Window);
|
||||
end;
|
||||
if GtkWidgetIsA(Widget, gtk_frame_get_type) then
|
||||
ScrollWidget := PGtkScrolledWindow(PGtkFrame(Widget)^.Bin.Child)
|
||||
else
|
||||
if GtkWidgetIsA(Widget, gtk_scrolled_window_get_type) then
|
||||
ScrollWidget := PGtkScrolledWindow(Widget)
|
||||
else
|
||||
ScrollWidget := nil;
|
||||
|
||||
if ScrollWidget <> nil then
|
||||
begin
|
||||
case APosition of
|
||||
wszpBack: begin
|
||||
// gdk_window_lower(WidgetInfo^.CoreWidget^.Window);
|
||||
if ScrollWidget^.hscrollbar <> nil
|
||||
then gdk_window_lower(ScrollWidget^.hscrollbar^.Window);
|
||||
if ScrollWidget^.vscrollbar <> nil
|
||||
then gdk_window_lower(ScrollWidget^.vscrollbar^.Window);
|
||||
end;
|
||||
wszpFront: begin
|
||||
// gdk_window_raise(WidgetInfo^.CoreWidget^.Window);
|
||||
if ScrollWidget^.hscrollbar <> nil
|
||||
then gdk_window_raise(ScrollWidget^.hscrollbar^.Window);
|
||||
if ScrollWidget^.vscrollbar <> nil
|
||||
then gdk_window_raise(ScrollWidget^.vscrollbar^.Window);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -540,8 +540,7 @@ end;
|
||||
// Forms
|
||||
function RegisterScrollingWinControl: Boolean; alias : 'WSRegisterScrollingWinControl';
|
||||
begin
|
||||
RegisterWSComponent(TScrollingWinControl, TGtkWSScrollingWinControl, TGtkPrivateScrollingWinControl); { GTK1 }
|
||||
// RegisterWSComponent(TScrollingWinControl, TGtk2WSScrollingWinControl);
|
||||
RegisterWSComponent(TScrollingWinControl, TGtk2WSScrollingWinControl, TGtkPrivateScrollingWinControl);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
@ -44,6 +44,8 @@ type
|
||||
|
||||
TGtk2WSScrollingWinControl = class(TGtkWSScrollingWinControl)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
end;
|
||||
|
||||
{ TGtk2WSScrollBox }
|
||||
@ -263,4 +265,64 @@ begin
|
||||
gtk_window_get_modal();
|
||||
end;}
|
||||
|
||||
{ TGtk2WSScrollingWinControl }
|
||||
|
||||
class function TGtk2WSScrollingWinControl.CreateHandle(
|
||||
const AWinControl: TWinControl; const AParams: TCreateParams
|
||||
): TLCLIntfHandle;
|
||||
var
|
||||
Scrolled: PGtkScrolledWindow;
|
||||
Layout: PGtkWidget;
|
||||
WidgetInfo: PWidgetInfo;
|
||||
Adjustment: PGtkAdjustment;
|
||||
begin
|
||||
// create a gtk_scrolled_window for the scrollbars
|
||||
Scrolled := PGtkScrolledWindow(gtk_scrolled_window_new(nil, nil));
|
||||
gtk_scrolled_window_set_shadow_type(Scrolled,
|
||||
BorderStyleShadowMap[TScrollingWinControl(AWinControl).BorderStyle]);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS(Scrolled^.hscrollbar, GTK_CAN_FOCUS);
|
||||
GTK_WIDGET_UNSET_FLAGS(Scrolled^.vscrollbar, GTK_CAN_FOCUS);
|
||||
gtk_scrolled_window_set_policy(Scrolled, GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||
gtk_object_set_data(PGtkObject(Scrolled), odnScrollArea, Scrolled);
|
||||
|
||||
{$IFDEF DebugLCLComponents}
|
||||
DebugGtkWidgets.MarkCreated(Scrolled, dbgsName(AWinControl));
|
||||
{$ENDIF}
|
||||
|
||||
WidgetInfo := CreateWidgetInfo(Scrolled, AWinControl, AParams);
|
||||
|
||||
Adjustment := gtk_scrolled_window_get_vadjustment(Scrolled);
|
||||
if Adjustment <> nil then
|
||||
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar, Scrolled^.vscrollbar);
|
||||
|
||||
Adjustment := gtk_scrolled_window_get_hadjustment(Scrolled);
|
||||
if Adjustment <> nil then
|
||||
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar, Scrolled^.hscrollbar);
|
||||
|
||||
// create a gtk_layout for the client area, so childs can be added at
|
||||
// free x,y positions and the scrollbars automatically scrolls the childs
|
||||
Layout := gtk_layout_new(nil, nil);
|
||||
gtk_container_add(PGTKContainer(Scrolled), Layout);
|
||||
gtk_widget_show(Layout);
|
||||
SetFixedWidget(Scrolled, Layout);
|
||||
SetMainWidget(Scrolled, Layout);
|
||||
|
||||
Result := TLCLIntfHandle(PtrUInt(Scrolled));
|
||||
Set_RC_Name(AWinControl, PGtkWidget(Scrolled));
|
||||
SetCallBacks(PGtkWidget(Scrolled), WidgetInfo);
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSScrollingWinControl.SetColor(
|
||||
const AWinControl: TWinControl);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'SetColor')
|
||||
then Exit;
|
||||
|
||||
Gtk2WidgetSet.SetWidgetColor(PGtkBin(AWinControl.Handle)^.child,
|
||||
clNone, AWinControl.Color,
|
||||
[GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
|
||||
GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user