mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 00:30:37 +02:00
Qt: implemented SM_CYMENU system metrics, also added todo for SM_CYMENUSIZE and SM_CXMENUSIZE.
git-svn-id: trunk@35298 -
This commit is contained in:
parent
5e1c1bbb19
commit
4160c140c1
@ -90,6 +90,12 @@ type
|
||||
FWindowManagerName: String; // Track various incompatibilities between WM. Initialized at WS start.
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
// qt style does not have pixel metric for themed menubar (menu) height
|
||||
// so we must calculate it somehow.
|
||||
FCachedMenuBarHeight: Integer;
|
||||
function GetMenuHeight: Integer;
|
||||
|
||||
procedure ClearCachedColors;
|
||||
procedure SetOverrideCursor(const AValue: TObject);
|
||||
procedure QtRemoveStayOnTop(const ASystemTopAlso: Boolean = False);
|
||||
|
@ -78,7 +78,6 @@ constructor TQtWidgetSet.Create;
|
||||
begin
|
||||
FLastWFPMousePos := Point(MaxInt, MaxInt);
|
||||
FLastWFPResult := 0;
|
||||
|
||||
inherited Create;
|
||||
FIsLibraryInstance := QCoreApplication_instance() <> nil;
|
||||
if FIsLibraryInstance then
|
||||
@ -88,7 +87,7 @@ begin
|
||||
{$J+}
|
||||
QtVersionInt(QtVersionMajor, QtVersionMinor, QtVersionMicro);
|
||||
{$J-}
|
||||
|
||||
FCachedMenuBarHeight := -1;
|
||||
FAppEvenFilterHook := nil;
|
||||
FAppFocusChangedHook := nil;
|
||||
|
||||
@ -499,6 +498,7 @@ procedure TQtWidgetSet.SetDefaultAppFontName;
|
||||
var
|
||||
AppFont: QFontH;
|
||||
begin
|
||||
FCachedMenuBarHeight := -1;
|
||||
AppFont := QFont_create();
|
||||
QApplication_font(AppFont);
|
||||
QFont_family(AppFont, @FDefaultAppFontName);
|
||||
@ -518,6 +518,11 @@ begin
|
||||
Result := False;
|
||||
case QEvent_type(Event) of
|
||||
QEventApplicationFontChange: SetDefaultAppFontName;
|
||||
QEventStyleChange:
|
||||
begin
|
||||
if (Sender = QCoreApplication_instance()) then
|
||||
FCachedMenuBarHeight := -1;
|
||||
end;
|
||||
QEventApplicationActivate:
|
||||
if Assigned(Application) and not FEatNextDeactivate then
|
||||
begin
|
||||
@ -1299,6 +1304,31 @@ begin
|
||||
FStockDefaultDC := 0; // app must be initialized
|
||||
end;
|
||||
|
||||
function TQtWidgetSet.GetMenuHeight: Integer;
|
||||
var
|
||||
AMenuBar: QMenuBarH;
|
||||
DummyWindow: QMainWindowH;
|
||||
DummyStr: WideString;
|
||||
Size: TSize;
|
||||
begin
|
||||
if FCachedMenuBarHeight = -1 then
|
||||
begin
|
||||
DummyWindow := QMainWindow_create(QApplication_desktop());
|
||||
QWidget_setVisible(DummyWindow, False);
|
||||
AMenuBar := QMenuBar_create();
|
||||
DummyStr := 'DUMMY BAR';
|
||||
QMenuBar_addMenu(AMenuBar, @DummyStr);
|
||||
QMainWindow_setMenuBar(DummyWindow, AMenuBar);
|
||||
QMenuBar_sizeHint(AMenuBar, @Size);
|
||||
QMainWindow_destroy(DummyWindow);
|
||||
FCachedMenuBarHeight := Size.cy;
|
||||
end;
|
||||
if (FCachedMenuBarHeight <= 0) then
|
||||
FCachedMenuBarHeight := 22; // default
|
||||
|
||||
Result := FCachedMenuBarHeight;
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.ClearCachedColors;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -3805,18 +3805,22 @@ begin
|
||||
end;
|
||||
SM_CXMENUCHECK:
|
||||
begin
|
||||
//DebugLn('Trace:TODO: [TQtWidgetSet.GetSystemMetrics] --> SM_CXMENUCHECK ');
|
||||
Result := GetPixelMetric(QStylePM_IndicatorWidth, nil, nil);
|
||||
end;
|
||||
SM_CYMENUCHECK:
|
||||
begin
|
||||
//DebugLn('Trace:TODO: [TQtWidgetSet.GetSystemMetrics] --> SM_CYMENUCHECK ');
|
||||
Result := GetPixelMetric(QStylePM_IndicatorHeight, nil, nil);
|
||||
end;
|
||||
SM_CXMENUSIZE:
|
||||
begin
|
||||
//TODO: should be calculated - this is mdi titlebar button width
|
||||
// QStylePM_MdiSubWindowMinimizedWidth - margins
|
||||
Result := GetPixelMetric(QStylePM_IndicatorWidth, nil, nil);
|
||||
end;
|
||||
SM_CYMENUSIZE:
|
||||
begin
|
||||
//TODO: should be calculated - this is mdi titlebar button height
|
||||
// QStylePM_MdiSubWindowMinimizedWidth - margins
|
||||
Result := GetPixelMetric(QStylePM_IndicatorHeight, nil, nil);
|
||||
end;
|
||||
SM_CXMIN:
|
||||
@ -3912,7 +3916,7 @@ begin
|
||||
end;
|
||||
SM_CYMENU:
|
||||
begin
|
||||
//DebugLn('Trace:TODO: [TQtWidgetSet.GetSystemMetrics] --> SM_CYMENU ');
|
||||
Result := GetMenuHeight;
|
||||
end;
|
||||
SM_CYSMCAPTION:
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user