mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 02:20:40 +02:00
gtk2 intf: fixed resizing windows, fixed creation and position of hint windows
git-svn-id: trunk@11017 -
This commit is contained in:
parent
c650a06f6d
commit
c902aecea7
@ -203,7 +203,7 @@ end;//GetAbsolutePath
|
||||
|
||||
procedure TDirSelDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
TV.HandleNeeded;
|
||||
|
||||
end;
|
||||
|
||||
procedure TDirSelDlg.FormShow(Sender: TObject);
|
||||
|
@ -23,7 +23,7 @@ const
|
||||
DefHintPause = 500; { default pause before hint window displays (ms) }
|
||||
DefHintShortPause = 0; { default reshow pause }
|
||||
DefHintHidePause = 5*DefHintPause; { default pause before hint is hidden (ms) }
|
||||
DefHintHidePausePerChar = 100; { added to DefHintHidePause (ms) }
|
||||
DefHintHidePausePerChar = 200; { added to DefHintHidePause (ms) }
|
||||
|
||||
function FindApplicationComponent(const ComponentName: string): TComponent;
|
||||
begin
|
||||
@ -568,8 +568,6 @@ end;
|
||||
function TApplication.IsHintMsg(var Msg: TMsg): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
{if (FHintWindow <> nil) and FHintWindow.IsHintMsg(Msg) then
|
||||
CancelHint;}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -678,6 +676,7 @@ begin
|
||||
with HintInfo do
|
||||
HintWinRect := FHintWindow.CalcHintRect(HintMaxWidth, HintStr, HintData);
|
||||
OffsetRect(HintWinRect, HintInfo.HintPos.X, HintInfo.HintPos.Y);
|
||||
//DebugLn(['TApplication.ShowHintWindow HintStr="',HintInfo.HintStr,'" HintWinRect=',dbgs(HintWinRect)]);
|
||||
{if FHintWindow.UseRightToLeftAlignment then
|
||||
with HintWinRect do
|
||||
begin
|
||||
|
@ -1753,8 +1753,6 @@ var
|
||||
Control: TWinControl;
|
||||
begin
|
||||
inherited Loaded;
|
||||
if FMenu<>nil then
|
||||
FMenu.HandleNeeded;
|
||||
if (ActiveControl <> nil) and (Parent=nil) then
|
||||
begin
|
||||
Control := ActiveControl;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
{ $DEFINE CHECK_POSITION}
|
||||
{ $IFDEF CHECK_POSITION}
|
||||
const CheckPostionClassName = 'TButtonX';
|
||||
const CheckPostionClassName = 'THintWindow';
|
||||
const CheckPostionName = 'ListBox1';
|
||||
|
||||
function CheckPosition(AControl: TControl): boolean;
|
||||
@ -4802,7 +4802,7 @@ begin
|
||||
{$IFDEF VerboseSizeMsg}
|
||||
DebugLn(['TWinControl.WMMove A ',DbgSName(Self),' Message=',Message.XPos,',',Message.YPos,
|
||||
' BoundsRealized=',FBoundsRealized.Left,',',FBoundsRealized.Top,
|
||||
' SourceIsInterface=',Message.MoveType=Move_SourceIsInterface,
|
||||
' FromIntf=',Message.MoveType=Move_SourceIsInterface,
|
||||
',',FBoundsRealized.Right-FBoundsRealized.Left,
|
||||
'x',FBoundsRealized.Bottom-FBoundsRealized.Top]);
|
||||
{$ENDIF}
|
||||
@ -4838,7 +4838,7 @@ begin
|
||||
{$IFDEF VerboseSizeMsg}
|
||||
if CheckPosition(Self) then
|
||||
DebugLn('TWinControl.WMSize A ',Name,':',ClassName,' Message=',dbgs(Message.Width),',',dbgs(Message.Height),
|
||||
' BoundsRealized=',dbgs(FBoundsRealized));
|
||||
' BoundsRealized=',dbgs(FBoundsRealized),' FromIntf=',(Message.SizeType and Size_SourceIsInterface)>0));
|
||||
{$ENDIF}
|
||||
NewLeft:=Left;
|
||||
NewTop:=Top;
|
||||
@ -5717,7 +5717,7 @@ begin
|
||||
' Lock=',BoundsLockCount,
|
||||
' Realized=',dbgs(FBoundsRealized)
|
||||
]);
|
||||
if CheckPosition(Self) and (AWidth=128) then
|
||||
if CheckPosition(Self) and (AWidth=1) then
|
||||
DumpStack;
|
||||
{$ENDIF}
|
||||
if BoundsLockCount<>0 then exit;
|
||||
|
@ -634,28 +634,33 @@ begin
|
||||
//if (Info^.default_width<>Width) or (Info^.default_height<>Height) then
|
||||
gtk_window_set_default_size(Window,Width,Height);
|
||||
|
||||
{$IFDEF Gtk2}
|
||||
// resize
|
||||
gtk_window_set_default_size(Window,Width,Height);
|
||||
gtk_window_resize(Window,Width,Height);
|
||||
// reposition
|
||||
gtk_window_move(Window,AWinControl.Left,AWinControl.Top);
|
||||
{$ELSE}
|
||||
// resize
|
||||
if assigned(PGtkWidget(Window)^.Window) then
|
||||
// widget is realized, resize gdkwindow directly
|
||||
gdk_window_move_resize(PGtkWidget(Window)^.Window,AWinControl.Left,
|
||||
AWinControl.Top,Width,Height)
|
||||
else
|
||||
// widget is not yet realized, force resize needed for shrinking under gtk1)
|
||||
else begin
|
||||
// widget is not yet realized, force resize needed for shrinking under gtk1
|
||||
gtk_widget_set_usize(PGtkWidget(Window), -1,-1);
|
||||
//if (PGtkWidget(Window)^.allocation.Width<>Width)
|
||||
//and (PGtkWidget(Window)^.allocation.Height<>Height) then begin
|
||||
//gtk_widget_set_usize(PGtkWidget(Window), -1,-1);
|
||||
gtk_widget_set_usize(PGtkWidget(Window),Width,Height);
|
||||
//end;
|
||||
|
||||
end;
|
||||
// reposition
|
||||
{$IFDEF VerboseSizeMsg}
|
||||
DebugLn('TGtkWidgetSet.SetWindowSizeAndPosition B ',AWinControl.Name,':',AWinControl.ClassName,
|
||||
' Visible=',dbgs(AWinControl.Visible),
|
||||
' Old=',dbgs(PGtkWidget(Window)^.allocation.X)+','+dbgs(PGtkWidget(Window)^.allocation.Y),
|
||||
' New=',dbgs(AWinControl.Left)+','+dbgs(AWinControl.Top)+','+dbgs(Width)+'x'+dbgs(Height));
|
||||
{$ENDIF}
|
||||
gtk_widget_set_usize(PGtkWidget(Window),Width,Height);
|
||||
gtk_widget_set_uposition(PGtkWidget(Window),AWinControl.Left,AWinControl.Top);
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VerboseSizeMsg}
|
||||
DebugLn(['TGtkWidgetSet.SetWindowSizeAndPosition B ',DbgSName(AWinControl),
|
||||
' Visible=',AWinControl.Visible,
|
||||
' Old=',PGtkWidget(Window)^.allocation.X,',',PGtkWidget(Window)^.allocation.Y,
|
||||
' New=',AWinControl.Left,',',AWinControl.Top,',',Width,'x',Height]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1115,6 +1120,10 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
|
||||
// -> ignore
|
||||
exit;
|
||||
end;
|
||||
if (GtkWidth=1) and (GtkHeight=1) then begin
|
||||
// this is default size of the gtk. Ignore.
|
||||
exit;
|
||||
end;
|
||||
if GetControlWindow(MainWidget)<>nil then begin
|
||||
gdk_window_get_root_origin(GetControlWindow(MainWidget), @GtkLeft, @GtkTop);
|
||||
end else begin
|
||||
@ -1122,8 +1131,8 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
|
||||
GtkTop:=LCLControl.Top;
|
||||
end;
|
||||
{$IFDEF VerboseFormPositioning}
|
||||
DebugLn('VFP SendSizeNotificationToLCL ',LCLControl.ClassName,' ',
|
||||
GtkLeft,',',GtkTop,',',GtkWidth,',',GtkHeight);
|
||||
DebugLn(['VFP SendSizeNotificationToLCL ',DbgSName(LCLControl),' ',
|
||||
GtkLeft,',',GtkTop,',',GtkWidth,',',GtkHeight,' ',GetWidgetDebugReport(MainWidget)]);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
@ -1493,6 +1502,8 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TGtkWidgetSet.RealizeWidgetSize(Widget: PGtkWidget; NewWidth,
|
||||
NewHeight: integer);
|
||||
|
||||
Note: gtk_window is resized in TGtkWidgetSet.SetWindowSizeAndPosition
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TGtkWidgetSet.RealizeWidgetSize(Widget: PGtkWidget; NewWidth,
|
||||
NewHeight: integer);
|
||||
@ -1532,6 +1543,7 @@ begin
|
||||
end;
|
||||
|
||||
gtk_widget_set_usize(Widget, NewWidth, NewHeight);
|
||||
//DebugLn(['TGtkWidgetSet.RealizeWidgetSize ',GetWidgetDebugReport(Widget),' NewWidth=',NewWidth,' NewHeight=',NewHeight]);
|
||||
|
||||
if GtkWidgetIsA(Widget, GTK_TYPE_COMBO) then
|
||||
begin
|
||||
@ -4425,6 +4437,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
csHintWindow:
|
||||
begin
|
||||
if (TControl(ALCLObject).Parent=nil) then begin
|
||||
SetCallback(LM_CONFIGUREEVENT, AGTKObject, ALCLObject);
|
||||
end;
|
||||
end;
|
||||
|
||||
csStaticText:
|
||||
Begin
|
||||
SetCallback(LM_GRABFOCUS, AGTKObject, ALCLObject);
|
||||
@ -5087,8 +5106,11 @@ begin
|
||||
gtk_window_set_title(pGtkWindow(Result), PCaption);
|
||||
|
||||
// Shows in taskbar only Main Form.
|
||||
// MG: on some systems like the default under ubuntu, this also removes
|
||||
// it from the window cycle list, so you can no longer switch to each window.
|
||||
// So I disabled it until a better solution is found.
|
||||
{$IFDEF HasGTK2_2}
|
||||
if Assigned(ACustomForm) then
|
||||
{if Assigned(ACustomForm) then
|
||||
if (ACustomForm=Application.MainForm) OR (Application.MainForm = Nil) then
|
||||
begin
|
||||
gtk_window_set_skip_taskbar_hint(pGtkWindow(Result),False); //SHOW
|
||||
@ -5096,7 +5118,7 @@ begin
|
||||
else
|
||||
begin
|
||||
gtk_window_set_skip_taskbar_hint(pGtkWindow(Result),True); //HIDE
|
||||
end;
|
||||
end;}
|
||||
{$ENDIF}
|
||||
|
||||
// the clipboard needs a widget
|
||||
@ -5535,7 +5557,7 @@ begin
|
||||
gdk_window_set_functions(AWindow,
|
||||
GetWindowFunction(TCustomForm(Sender)));
|
||||
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
|
||||
gtk_widget_show_all(p);
|
||||
gtk_widget_show_all(TempWidget);// Important: do not show the window yet, only make its content visible
|
||||
end;
|
||||
|
||||
csImage :
|
||||
|
@ -6378,6 +6378,7 @@ var
|
||||
begin
|
||||
Widget := PGtkWidget(AWinControl.Handle);
|
||||
// set size to default
|
||||
//DebugLn(['GetGTKDefaultWidgetSize ',GetWidgetDebugReport(Widget)]);
|
||||
gtk_widget_set_usize(Widget,-1,-1);
|
||||
// ask default size
|
||||
gtk_widget_size_request(Widget,@Requisition);
|
||||
|
Loading…
Reference in New Issue
Block a user