mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 15:47:18 +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)
|
TGtkWSCustomFrame = class(TWSCustomFrame)
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
|
||||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtkWSFrame }
|
{ TGtkWSFrame }
|
||||||
@ -517,60 +515,4 @@ begin
|
|||||||
SetCallbacks(P, WidgetInfo);
|
SetCallbacks(P, WidgetInfo);
|
||||||
end;
|
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.
|
end.
|
||||||
|
@ -304,9 +304,16 @@ begin
|
|||||||
// Only do the scrollbars, leave the core to the default (we might have a viewport)
|
// Only do the scrollbars, leave the core to the default (we might have a viewport)
|
||||||
TGtkPrivateWidget.SetZPosition(AWinControl, APosition);
|
TGtkPrivateWidget.SetZPosition(AWinControl, APosition);
|
||||||
|
|
||||||
if GtkWidgetIsA(Widget,gtk_frame_get_type) then begin
|
if GtkWidgetIsA(Widget, gtk_frame_get_type) then
|
||||||
ScrollWidget := PGtkScrolledWindow(PGtkFrame(Widget)^.Bin.Child);
|
ScrollWidget := PGtkScrolledWindow(PGtkFrame(Widget)^.Bin.Child)
|
||||||
if ScrollWidget<>nil then begin
|
else
|
||||||
|
if GtkWidgetIsA(Widget, gtk_scrolled_window_get_type) then
|
||||||
|
ScrollWidget := PGtkScrolledWindow(Widget)
|
||||||
|
else
|
||||||
|
ScrollWidget := nil;
|
||||||
|
|
||||||
|
if ScrollWidget <> nil then
|
||||||
|
begin
|
||||||
case APosition of
|
case APosition of
|
||||||
wszpBack: begin
|
wszpBack: begin
|
||||||
// gdk_window_lower(WidgetInfo^.CoreWidget^.Window);
|
// gdk_window_lower(WidgetInfo^.CoreWidget^.Window);
|
||||||
@ -324,7 +331,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$I gtkprivatewidget.inc}
|
{$I gtkprivatewidget.inc}
|
||||||
|
@ -540,8 +540,7 @@ end;
|
|||||||
// Forms
|
// Forms
|
||||||
function RegisterScrollingWinControl: Boolean; alias : 'WSRegisterScrollingWinControl';
|
function RegisterScrollingWinControl: Boolean; alias : 'WSRegisterScrollingWinControl';
|
||||||
begin
|
begin
|
||||||
RegisterWSComponent(TScrollingWinControl, TGtkWSScrollingWinControl, TGtkPrivateScrollingWinControl); { GTK1 }
|
RegisterWSComponent(TScrollingWinControl, TGtk2WSScrollingWinControl, TGtkPrivateScrollingWinControl);
|
||||||
// RegisterWSComponent(TScrollingWinControl, TGtk2WSScrollingWinControl);
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ type
|
|||||||
|
|
||||||
TGtk2WSScrollingWinControl = class(TGtkWSScrollingWinControl)
|
TGtk2WSScrollingWinControl = class(TGtkWSScrollingWinControl)
|
||||||
published
|
published
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
|
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtk2WSScrollBox }
|
{ TGtk2WSScrollBox }
|
||||||
@ -263,4 +265,64 @@ begin
|
|||||||
gtk_window_get_modal();
|
gtk_window_get_modal();
|
||||||
end;}
|
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.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user