Gtk2: implemented SM_CYCAPTION system metrics.

git-svn-id: trunk@35300 -
This commit is contained in:
zeljko 2012-02-11 11:56:20 +00:00
parent 8faf58e8d5
commit 045a3558a4
3 changed files with 43 additions and 2 deletions

View File

@ -79,9 +79,11 @@ type
FLastFocusOut: PGtkWidget;
StayOnTopList: TMap;
FAppActive: Boolean;
FCachedTitleBarHeight: Integer;
FCachedBorderSize: Integer;
function GetAppActive: Boolean;
function GetTitleBarHeight: Integer;
procedure SetAppActive(const AValue: Boolean);
protected
procedure AppendText(Sender: TObject; Str: PChar);
function GetText(Sender: TComponent; var Text: String): Boolean;

View File

@ -1088,6 +1088,8 @@ end;
constructor TGtk2WidgetSet.Create;
begin
inherited Create;
FCachedTitleBarHeight := -1;
FCachedBorderSize := 4;
Gtk2Create;
{$IFNDEF USE_GTK_MAIN_OLD_ITERATION}
FMainPoll := nil;
@ -2622,6 +2624,42 @@ begin
Result := FAppActive;
end;
function TGtk2WidgetSet.GetTitleBarHeight: Integer;
var
I: Integer;
AForm: TCustomForm;
AWindow: PGdkWindow;
ARect: TGdkRectangle;
AW, AH: GInt;
begin
Result := 30;
if FCachedTitleBarHeight > 0 then
Result := FCachedTitleBarHeight
else
if Assigned(Application) and not Application.Terminated and
Assigned(Application.MainForm) then
begin
for i := 0 to Screen.CustomFormZOrderCount - 1 do
begin
AForm := Screen.CustomFormsZOrdered[i];
if (AForm.HandleAllocated) and (AForm.Visible) and (AForm.Parent = nil) and
(AForm.BorderStyle <> bsNone) then
begin
AWindow := PGtkWidget(AForm.Handle)^.window;
if GDK_IS_WINDOW(AWindow) then
begin
gdk_window_get_frame_extents(AWindow, @ARect);
gdk_window_get_size(AWindow, @AW, @AH);
FCachedTitleBarHeight := ARect.Height - AH - 1;
FCachedBorderSize := (ARect.Width - AW) div 2;
Result := ARect.Height - AH - 1;
break;
end;
end;
end;
end;
end;
procedure TGtk2WidgetSet.SetAppActive(const AValue: Boolean);
begin
if AValue <> FAppActive then

View File

@ -5542,7 +5542,7 @@ begin
SM_CXSIZEFRAME,
SM_CYSIZEFRAME:
begin
Result := 4;
Result := FCachedBorderSize;
end;
SM_CXSMICON,
SM_CYSMICON:
@ -5570,6 +5570,7 @@ begin
SM_CYCAPTION:
begin
//DebugLn('Trace:TODO: [TGtk2WidgetSet.GetSystemMetrics] --> SM_CYCAPTION ');
Result := GetTitleBarHeight;
end;
SM_CYKANJIWINDOW:
begin