mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-04 12:56:00 +02:00
gtk2 intf: moving a widget without resizing now sets the allocation.x/y
git-svn-id: trunk@11246 -
This commit is contained in:
parent
fe1ca96a65
commit
20a3fd2a24
@ -5494,14 +5494,13 @@ procedure TGtkWidgetSet.ShowHide(Sender : TObject);
|
|||||||
RaiseGDBException('TGtkWidgetSet.ShowHide Sender.ClassName='+Sender.ClassName);
|
RaiseGDBException('TGtkWidgetSet.ShowHide Sender.ClassName='+Sender.ClassName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var FormIconGdiObject: PGDIObject;
|
var
|
||||||
|
FormIconGdiObject: PGDIObject;
|
||||||
SenderWidget: PGTKWidget;
|
SenderWidget: PGTKWidget;
|
||||||
LCLControl: TWinControl;
|
LCLControl: TWinControl;
|
||||||
Decor, Func : Longint;
|
Decor, Func : Longint;
|
||||||
AWindow: PGdkWindow;
|
AWindow: PGdkWindow;
|
||||||
ACustomForm: TCustomForm;
|
ACustomForm: TCustomForm;
|
||||||
ParentFixed: PGTKWidget;
|
|
||||||
ParentWidget: PGTKWidget;
|
|
||||||
{$IFDEF Gtk1}
|
{$IFDEF Gtk1}
|
||||||
AWindowPrivate: PGdkWindowPrivate;
|
AWindowPrivate: PGdkWindowPrivate;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -5546,18 +5545,7 @@ begin
|
|||||||
{$IFDEF VerboseSizeMsg}
|
{$IFDEF VerboseSizeMsg}
|
||||||
DebugLn(['TGtkWidgetSet.ShowHide ',DbgSName(LCLControl)]);
|
DebugLn(['TGtkWidgetSet.ShowHide ',DbgSName(LCLControl)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
SetWidgetSize(SenderWidget,LCLControl.Width,LCLControl.Height);
|
SetWidgetSizeAndPosition(LCLControl);
|
||||||
// move widget on the fixed widget of parent control
|
|
||||||
ParentWidget:=pgtkWidget(LCLControl.Parent.Handle);
|
|
||||||
ParentFixed := GetFixedWidget(ParentWidget);
|
|
||||||
if GtkWidgetIsA(ParentFixed,GTK_FIXED_GET_TYPE)
|
|
||||||
or GtkWidgetIsA(ParentFixed,GTK_LAYOUT_GET_TYPE) then begin
|
|
||||||
FixedMoveControl(ParentFixed, SenderWidget,
|
|
||||||
LCLControl.Left, LCLControl.Top);
|
|
||||||
end else if not (LCLControl.Parent is TCustomNoteBook) then begin
|
|
||||||
DebugLn('WARNING: TGtkWidgetSet.ShowHide - no Fixed Widget found');
|
|
||||||
DebugLn(' Control=',LCLControl.Name,':',LCLControl.ClassName);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
UnsetResizeRequest(SenderWidget);
|
UnsetResizeRequest(SenderWidget);
|
||||||
end;
|
end;
|
||||||
|
@ -3770,21 +3770,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Procedure FixedMoveControl(Parent, Child : PGTKWIdget; Left, Top : Longint);
|
Procedure FixedMoveControl(Parent, Child : PGTKWidget; Left, Top : Longint);
|
||||||
|
|
||||||
Move a childwidget on a client area (fixed or layout widget).
|
Move a childwidget on a client area (fixed or layout widget).
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
Procedure FixedMoveControl(Parent, Child : PGTKWIdget; Left, Top : Longint);
|
Procedure FixedMoveControl(Parent, Child : PGTKWidget; Left, Top : Longint);
|
||||||
begin
|
begin
|
||||||
If GTKWidgetIsA(Parent, GTK_Layout_Get_Type) then
|
If GTKWidgetIsA(Parent, GTK_Layout_Get_Type) then begin
|
||||||
// parent is layout
|
// parent is layout
|
||||||
gtk_Layout_move(PGtkLayout(Parent), Child, Left, Top)
|
gtk_Layout_move(PGtkLayout(Parent), Child, Left, Top)
|
||||||
else If GTKWidgetIsA(Parent, GTK_Fixed_Get_Type) then begin
|
end else If GTKWidgetIsA(Parent, GTK_Fixed_Get_Type) then begin
|
||||||
// parent is fixed
|
// parent is fixed
|
||||||
gtk_fixed_move(PGtkFixed(Parent), Child, gint16(Left), gint16(Top))
|
gtk_fixed_move(PGtkFixed(Parent), Child, gint16(Left), gint16(Top));
|
||||||
end else
|
end else begin
|
||||||
// parent is invalid
|
// parent is invalid
|
||||||
DebugLn('[FixedMoveControl] WARNING: Invalid Fixed Widget');
|
DebugLn('[FixedMoveControl] WARNING: Invalid Fixed Widget');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -6770,90 +6771,24 @@ begin
|
|||||||
SetResizeRequest(Widget);
|
SetResizeRequest(Widget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
procedure SetWidgetSizeAndPosition(LCLControl: TWinControl);
|
||||||
procedure SetWidgetSize(Widget: PGtkWidget; NewWidth,
|
|
||||||
NewHeight: integer);
|
|
||||||
|
|
||||||
Note: gtk_window is resized in SetWindowSizeAndPosition
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure SetWidgetSize(Widget: PGtkWidget; NewWidth,
|
|
||||||
NewHeight: integer);
|
|
||||||
var
|
var
|
||||||
Requisition: TGtkRequisition;
|
Requisition: TGtkRequisition;
|
||||||
{$IFDEF VerboseSizeMsg}
|
|
||||||
LCLObject: TObject;
|
|
||||||
{$ENDIF}
|
|
||||||
FixedWidget: PGtkWidget;
|
FixedWidget: PGtkWidget;
|
||||||
{$IFDEF Gtk2}
|
{$IFDEF Gtk2}
|
||||||
allocation: TGtkAllocation;
|
allocation: TGtkAllocation;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
LCLLeft: LongInt;
|
||||||
if NewWidth<=0 then NewWidth:=1;
|
LCLTop: LongInt;
|
||||||
if NewHeight<=0 then NewHeight:=1;
|
|
||||||
|
|
||||||
{$IFDEF VerboseSizeMsg}
|
|
||||||
LCLObject:=GetNearestLCLObject(Widget);
|
|
||||||
DbgOut('TGtkWidgetSet.SetWidgetSize Widget='+DbgS(Widget)+WidgetFlagsToString(Widget)+
|
|
||||||
' New='+dbgs(NewWidth)+','+dbgs(NewHeight));
|
|
||||||
if (LCLObject<>nil) and (LCLObject is TControl) then begin
|
|
||||||
with TControl(LCLObject) do
|
|
||||||
DebugLn(' LCL=',Name,':',ClassName,' ',dbgs(Left),',',dbgs(Top),',',dbgs(Width),',',dbgs(Height));
|
|
||||||
end else begin
|
|
||||||
DebugLn(' LCL=',DbgS(LCLObject));
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
if GtkWidgetIsA(Widget,GTK_TYPE_SCROLLBAR) then
|
|
||||||
begin
|
|
||||||
// the width of a scrollbar is fixed and depends only on the theme
|
|
||||||
gtk_widget_size_request(widget, @Requisition);
|
|
||||||
if GtkWidgetIsA(Widget, GTK_TYPE_HSCROLLBAR) then
|
|
||||||
begin
|
|
||||||
NewHeight:=Requisition.height;
|
|
||||||
end else begin
|
|
||||||
NewWidth:=Requisition.width;
|
|
||||||
end;
|
|
||||||
//DebugLn('TGtkWidgetSet.SetWidgetSize A ',Newwidth,',',Newheight);
|
|
||||||
end;
|
|
||||||
|
|
||||||
gtk_widget_set_usize(Widget, NewWidth, NewHeight);
|
|
||||||
//DebugLn(['TGtkWidgetSet.SetWidgetSize ',GetWidgetDebugReport(Widget),' NewWidth=',NewWidth,' NewHeight=',NewHeight]);
|
|
||||||
|
|
||||||
{$IFDEF Gtk1}
|
|
||||||
if GtkWidgetIsA(Widget, GTK_TYPE_COMBO) then
|
|
||||||
begin
|
|
||||||
// the combobox has an entry, which height is not resized
|
|
||||||
// automatically. Do it manually.
|
|
||||||
gtk_widget_set_usize(PGtkCombo(Widget)^.entry,
|
|
||||||
PGtkCombo(Widget)^.entry^.allocation.width, NewHeight);
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
if GtkWidgetIsA(Widget,gtk_toolbar_get_type) then begin
|
|
||||||
FixedWidget:=GetFixedWidget(Widget);
|
|
||||||
if (FixedWidget<>nil) and (FixedWidget<>Widget) then begin
|
|
||||||
//DebugLn('WARNING: ToDo TGtkWidgetSet.SetWidgetSize for TToolBar ',NewWidth,',',NewHeight);
|
|
||||||
gtk_widget_set_usize(FixedWidget,NewWidth,NewHeight);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$IFDEF Gtk2}
|
|
||||||
// commit size
|
|
||||||
allocation:=Widget^.allocation;
|
|
||||||
allocation.width:=NewWidth;
|
|
||||||
allocation.height:=NewHeight;
|
|
||||||
gtk_widget_size_allocate(Widget,@allocation);// Beware: this triggers callbacks
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure SetWidgetSizeAndPosition(LCLControl: TWinControl);
|
|
||||||
var
|
|
||||||
LCLWidth: LongInt;
|
LCLWidth: LongInt;
|
||||||
LCLHeight: LongInt;
|
LCLHeight: LongInt;
|
||||||
Widget: PGtkWidget;
|
Widget: PGtkWidget;
|
||||||
ParentWidget: PGtkWidget;
|
ParentWidget: PGtkWidget;
|
||||||
ParentFixed: PGtkWidget;
|
ParentFixed: PGtkWidget;
|
||||||
WinWidgetInfo: PWidgetInfo;
|
WinWidgetInfo: PWidgetInfo;
|
||||||
|
{$IFDEF VerboseSizeMsg}
|
||||||
|
LCLObject: TObject;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure WriteBigWarning;
|
procedure WriteBigWarning;
|
||||||
begin
|
begin
|
||||||
@ -6878,6 +6813,9 @@ begin
|
|||||||
DebugLn(['SetWidgetSizeAndPosition ',DbgSName(LCLControl)]);
|
DebugLn(['SetWidgetSizeAndPosition ',DbgSName(LCLControl)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Widget:=PGtkWidget(LCLControl.Handle);
|
Widget:=PGtkWidget(LCLControl.Handle);
|
||||||
|
|
||||||
|
LCLLeft:=LCLControl.Left;
|
||||||
|
LCLTop:=LCLControl.Top;
|
||||||
|
|
||||||
// move widget on the fixed widget of parent control
|
// move widget on the fixed widget of parent control
|
||||||
if (LCLControl.Parent<>nil) and (LCLControl.Parent.HandleAllocated) then
|
if (LCLControl.Parent<>nil) and (LCLControl.Parent.HandleAllocated) then
|
||||||
@ -6886,8 +6824,7 @@ begin
|
|||||||
ParentFixed := GetFixedWidget(ParentWidget);
|
ParentFixed := GetFixedWidget(ParentWidget);
|
||||||
if GtkWidgetIsA(ParentFixed,GTK_FIXED_GET_TYPE)
|
if GtkWidgetIsA(ParentFixed,GTK_FIXED_GET_TYPE)
|
||||||
or GtkWidgetIsA(ParentFixed,GTK_LAYOUT_GET_TYPE) then begin
|
or GtkWidgetIsA(ParentFixed,GTK_LAYOUT_GET_TYPE) then begin
|
||||||
FixedMoveControl(ParentFixed, Widget,
|
FixedMoveControl(ParentFixed, Widget,LCLLeft,LCLTop);
|
||||||
LCLControl.Left,LCLControl.Top);
|
|
||||||
end else begin
|
end else begin
|
||||||
WinWidgetInfo:=GetWidgetInfo(Widget,false);
|
WinWidgetInfo:=GetWidgetInfo(Widget,false);
|
||||||
if (WinWidgetInfo=nil)
|
if (WinWidgetInfo=nil)
|
||||||
@ -6906,11 +6843,66 @@ begin
|
|||||||
if (LCLWidth>10000) or (LCLHeight>10000) then begin
|
if (LCLWidth>10000) or (LCLHeight>10000) then begin
|
||||||
WriteBigWarning;
|
WriteBigWarning;
|
||||||
if LCLWidth>10000 then
|
if LCLWidth>10000 then
|
||||||
LCLWidth:=10000
|
LCLWidth:=10000;
|
||||||
else
|
if LCLHeight>10000 then
|
||||||
LCLHeight:=10000;
|
LCLHeight:=10000;
|
||||||
end;
|
end;
|
||||||
SetWidgetSize(Widget,LCLWidth, LCLHeight);
|
|
||||||
|
{$IFDEF VerboseSizeMsg}
|
||||||
|
LCLObject:=GetNearestLCLObject(Widget);
|
||||||
|
DbgOut('TGtkWidgetSet.SetWidgetSizeAndPosition Widget='+DbgS(Widget)+WidgetFlagsToString(Widget)+
|
||||||
|
' New='+dbgs(LCLWidth)+','+dbgs(LCLHeight));
|
||||||
|
if (LCLObject<>nil) and (LCLObject is TControl) then begin
|
||||||
|
with TControl(LCLObject) do
|
||||||
|
DebugLn(' LCL=',Name,':',ClassName,' ',dbgs(Left),',',dbgs(Top),',',dbgs(Width),',',dbgs(Height));
|
||||||
|
end else begin
|
||||||
|
DebugLn(' LCL=',DbgS(LCLObject));
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
if GtkWidgetIsA(Widget,GTK_TYPE_SCROLLBAR) then
|
||||||
|
begin
|
||||||
|
// the width of a scrollbar is fixed and depends only on the theme
|
||||||
|
gtk_widget_size_request(widget, @Requisition);
|
||||||
|
if GtkWidgetIsA(Widget, GTK_TYPE_HSCROLLBAR) then
|
||||||
|
begin
|
||||||
|
LCLHeight:=Requisition.height;
|
||||||
|
end else begin
|
||||||
|
LCLWidth:=Requisition.width;
|
||||||
|
end;
|
||||||
|
//DebugLn('TGtkWidgetSet.SetWidgetSizeAndPosition A ',LCLwidth,',',LCLheight);
|
||||||
|
end;
|
||||||
|
|
||||||
|
gtk_widget_set_usize(Widget, LCLWidth, LCLHeight);
|
||||||
|
//DebugLn(['TGtkWidgetSet.SetWidgetSizeAndPosition ',GetWidgetDebugReport(Widget),' LCLWidth=',LCLWidth,' LCLHeight=',LCLHeight]);
|
||||||
|
|
||||||
|
{$IFDEF Gtk1}
|
||||||
|
if GtkWidgetIsA(Widget, GTK_TYPE_COMBO) then
|
||||||
|
begin
|
||||||
|
// the combobox has an entry, which height is not resized
|
||||||
|
// automatically. Do it manually.
|
||||||
|
gtk_widget_set_usize(PGtkCombo(Widget)^.entry,
|
||||||
|
PGtkCombo(Widget)^.entry^.allocation.width, LCLHeight);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
if GtkWidgetIsA(Widget,gtk_toolbar_get_type) then begin
|
||||||
|
FixedWidget:=GetFixedWidget(Widget);
|
||||||
|
if (FixedWidget<>nil) and (FixedWidget<>Widget) then begin
|
||||||
|
//DebugLn('WARNING: ToDo TGtkWidgetSet.SetWidgetSizeAndPosition for TToolBar ',LCLWidth,',',LCLHeight);
|
||||||
|
gtk_widget_set_usize(FixedWidget,LCLWidth,LCLHeight);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IFDEF Gtk2}
|
||||||
|
// commit size and position
|
||||||
|
allocation:=Widget^.allocation;
|
||||||
|
allocation.x:=LCLLeft;
|
||||||
|
allocation.y:=LCLTop;
|
||||||
|
allocation.width:=LCLWidth;
|
||||||
|
allocation.height:=LCLHeight;
|
||||||
|
gtk_widget_size_allocate(Widget,@allocation);// Beware: this triggers callbacks
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -357,7 +357,7 @@ function GetFixedChildListWidget(Item: PGList): PGtkWidget;
|
|||||||
|
|
||||||
// fixed widgets
|
// fixed widgets
|
||||||
function CreateFixedClientWidget: PGTKWidget;
|
function CreateFixedClientWidget: PGTKWidget;
|
||||||
Procedure FixedMoveControl(Parent, Child: PGTKWIdget; Left, Top: Longint);
|
Procedure FixedMoveControl(Parent, Child: PGTKWidget; Left, Top: Longint);
|
||||||
Procedure FixedPutControl(Parent, Child: PGTKWidget; Left, Top: Longint);
|
Procedure FixedPutControl(Parent, Child: PGTKWidget; Left, Top: Longint);
|
||||||
|
|
||||||
// caret
|
// caret
|
||||||
@ -707,7 +707,6 @@ procedure GetGTKDefaultWidgetSize(AWinControl: TWinControl;
|
|||||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
procedure SendCachedGtkResizeNotifications;
|
procedure SendCachedGtkResizeNotifications;
|
||||||
procedure ResizeHandle(LCLControl: TWinControl);
|
procedure ResizeHandle(LCLControl: TWinControl);
|
||||||
procedure SetWidgetSize(Widget: PGtkWidget; NewWidth, NewHeight: integer);
|
|
||||||
procedure SetWidgetSizeAndPosition(LCLControl: TWinControl);// for child controls
|
procedure SetWidgetSizeAndPosition(LCLControl: TWinControl);// for child controls
|
||||||
procedure SetWindowSizeAndPosition(Window: PGtkWindow; AWinControl: TWinControl);// for top level control
|
procedure SetWindowSizeAndPosition(Window: PGtkWindow; AWinControl: TWinControl);// for top level control
|
||||||
procedure GetWidgetRelativePosition(aWidget: PGtkWidget; var Left, Top: integer);
|
procedure GetWidgetRelativePosition(aWidget: PGtkWidget; var Left, Top: integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user