mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 09:16:13 +02:00
Qt: simplified getting style pixel metrics by using GetPixelMetric() instead QStyle_pixelMetric()
git-svn-id: trunk@34512 -
This commit is contained in:
parent
6603d6ade6
commit
cac40f27dc
@ -207,6 +207,8 @@ type
|
||||
|
||||
function HwndFromWidgetH(const WidgetH: QWidgetH): HWND;
|
||||
function DTFlagsToQtFlags(const Flags: Cardinal): Integer;
|
||||
function GetPixelMetric(AMetric: QStylePixelMetric; AOption: QStyleOptionH;
|
||||
AWidget: QWidgetH): Integer;
|
||||
function GetQtVersion: String;
|
||||
function QtVersionCheck(const AMajor, AMinor, AMicro: Integer): Boolean;
|
||||
{$IFDEF HASX11}
|
||||
@ -304,7 +306,14 @@ begin
|
||||
if Flags and DT_EXPANDTABS <> 0 then
|
||||
Result := Result or QtTextExpandTabs;
|
||||
end;
|
||||
|
||||
|
||||
function GetPixelMetric(AMetric: QStylePixelMetric; AOption: QStyleOptionH;
|
||||
AWidget: QWidgetH): Integer;
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_style(),
|
||||
AMetric, AOption, AWidget);
|
||||
end;
|
||||
|
||||
function QtObjectFromWidgetH(const WidgetH: QWidgetH): TQtWidget;
|
||||
var
|
||||
V: QVariantH;
|
||||
|
@ -621,7 +621,7 @@ begin
|
||||
opt := QStyleOption_create(Integer(QStyleOptionVersion), Integer(QStyleOptionSO_Default));
|
||||
APixmap := QPixmap_create();
|
||||
if StockID in [idButtonOk..idButtonShield] then
|
||||
IconSize := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonIconSize, opt)
|
||||
IconSize := GetPixelMetric(QStylePM_ButtonIconSize, opt, nil)
|
||||
else
|
||||
IconSize := 0;
|
||||
QStyle_standardPixmap(QApplication_style(), APixmap, AStdPixmap, opt);
|
||||
|
@ -3300,10 +3300,8 @@ begin
|
||||
QWidget_frameGeometry(W, @R);
|
||||
|
||||
// exclude borders from frame
|
||||
FrameBorder := QStyle_pixelMetric(QApplication_style(),
|
||||
QStylePM_DefaultFrameWidth, nil, W);
|
||||
TitleBarHeight := QStyle_pixelMetric(QApplication_style(),
|
||||
QStylePM_TitleBarHeight, nil, W);
|
||||
FrameBorder := GetPixelMetric(QStylePM_DefaultFrameWidth, nil, W);
|
||||
TitleBarHeight := GetPixelMetric(QStylePM_TitleBarHeight, nil, W);
|
||||
|
||||
inc(R.Left, FrameBorder);
|
||||
inc(R.Top, TitleBarHeight);
|
||||
@ -5173,11 +5171,12 @@ var
|
||||
BtnHeight := QFontMetrics_height(AMetrics);
|
||||
Result.cx := BtnWidth;
|
||||
Result.cy := BtnHeight;
|
||||
BtnMargin := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonMargin, nil, Widget);
|
||||
FocusV := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
FocusH := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
ShiftH := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
ShiftV := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
|
||||
BtnMargin := GetPixelMetric(QStylePM_ButtonMargin, nil, Widget);
|
||||
FocusV := GetPixelMetric(QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
FocusH := GetPixelMetric(QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
ShiftH := GetPixelMetric(QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
ShiftV := GetPixelMetric(QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
|
||||
if ShiftH = 0 then
|
||||
ShiftH := FocusH;
|
||||
@ -5336,11 +5335,11 @@ function TQtBitBtn.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||
QPainter_setBackgroundMode(APainter, QtTransparentMode);
|
||||
QWidget_rect(Widget, @R);
|
||||
|
||||
BMargin := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonMargin, nil, Widget);
|
||||
VMargin := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
HMargin := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
SHorz := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
SVert := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
BMargin := GetPixelMetric(QStylePM_ButtonMargin, nil, Widget);
|
||||
VMargin := GetPixelMetric(QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
HMargin := GetPixelMetric(QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
SHorz := GetPixelMetric(QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
SVert := GetPixelMetric(QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
|
||||
if SHorz = 0 then
|
||||
SHorz := HMargin;
|
||||
@ -5508,11 +5507,11 @@ var
|
||||
BtnHeight := TextSize.cy;
|
||||
Result.cx := BtnWidth;
|
||||
Result.cy := BtnHeight;
|
||||
BtnMargin := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonMargin, nil, Widget);
|
||||
FocusV := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
FocusH := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
ShiftH := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
ShiftV := QStyle_pixelMetric(QApplication_style(), QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
BtnMargin := GetPixelMetric(QStylePM_ButtonMargin, nil, Widget);
|
||||
FocusV := GetPixelMetric(QStylePM_FocusFrameVMargin, nil, Widget);
|
||||
FocusH := GetPixelMetric(QStylePM_FocusFrameHMargin, nil, Widget);
|
||||
ShiftH := GetPixelMetric(QStylePM_ButtonShiftHorizontal, nil, Widget);
|
||||
ShiftV := GetPixelMetric(QStylePM_ButtonShiftVertical, nil, Widget);
|
||||
|
||||
if ShiftH = 0 then
|
||||
ShiftH := FocusH;
|
||||
@ -5987,8 +5986,8 @@ begin
|
||||
begin
|
||||
if IsMdiChild then
|
||||
begin
|
||||
if QMouseEvent_y(QMouseEventH(Event)) <= QStyle_pixelMetric(
|
||||
QApplication_style(), QStylePM_TitleBarHeight, nil, Widget) then
|
||||
if QMouseEvent_y(QMouseEventH(Event)) <= GetPixelMetric(
|
||||
QStylePM_TitleBarHeight, nil, Widget) then
|
||||
QEvent_ignore(Event)
|
||||
else
|
||||
Result := SlotMouse(Sender, Event);
|
||||
@ -8308,8 +8307,7 @@ begin
|
||||
begin
|
||||
R := TQtTabWidget(FOwner).getGeometry;
|
||||
R1 := getGeometry;
|
||||
BaseHeight := QStyle_pixelMetric(QApplication_style(),
|
||||
QStylePM_TabBarBaseHeight);
|
||||
BaseHeight := GetPixelMetric(QStylePM_TabBarBaseHeight, nil, nil);
|
||||
|
||||
case TQtTabWidget(FOwner).getTabPosition of
|
||||
QTabWidgetNorth:
|
||||
@ -10433,8 +10431,7 @@ begin
|
||||
if (Item <> nil) and
|
||||
((QListWidgetItem_flags(Item) and QtItemIsUserCheckable) <> 0) then
|
||||
begin
|
||||
x := QStyle_pixelMetric(QApplication_style(), QStylePM_IndicatorWidth,
|
||||
nil, Widget);
|
||||
x := GetPixelMetric(QStylePM_IndicatorWidth, nil, Widget);
|
||||
if ((MousePos.X > 2) and (MousePos.X < (X + 2))) then
|
||||
begin
|
||||
FCheckBoxClicked := True;
|
||||
|
@ -3723,8 +3723,7 @@ begin
|
||||
SM_CXBORDER, SM_CYBORDER:
|
||||
begin
|
||||
// size of frame around controls
|
||||
Result := QStyle_pixelMetric(QApplication_style(),
|
||||
QStylePM_DefaultFrameWidth, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_DefaultFrameWidth, nil, nil);
|
||||
end;
|
||||
SM_CXCURSOR:
|
||||
begin
|
||||
@ -3817,11 +3816,11 @@ begin
|
||||
end;
|
||||
SM_CXMENUSIZE:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_style(), QStylePM_IndicatorWidth, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_IndicatorWidth, nil, nil);
|
||||
end;
|
||||
SM_CYMENUSIZE:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_style(), QStylePM_IndicatorHeight, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_IndicatorHeight, nil, nil);
|
||||
end;
|
||||
SM_CXMIN:
|
||||
begin
|
||||
@ -3876,12 +3875,12 @@ begin
|
||||
SM_CXSIZEFRAME,
|
||||
SM_CYSIZEFRAME:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_style(), QStylePM_MDIFrameWidth, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_MDIFrameWidth, nil, nil);
|
||||
end;
|
||||
SM_CXSMICON,
|
||||
SM_CYSMICON:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_style(), QStylePM_SmallIconSize, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_SmallIconSize, nil, nil);
|
||||
end;
|
||||
SM_CXSMSIZE:
|
||||
begin
|
||||
@ -3904,11 +3903,11 @@ begin
|
||||
SM_CXHSCROLL,
|
||||
SM_CYHSCROLL:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_Style, QStylePM_ScrollBarExtent, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_ScrollBarExtent, nil, nil);
|
||||
end;
|
||||
SM_CYCAPTION:
|
||||
begin
|
||||
Result := QStyle_pixelMetric(QApplication_Style, QStylePM_TitleBarHeight, nil, nil);
|
||||
Result := GetPixelMetric(QStylePM_TitleBarHeight, nil, nil);
|
||||
end;
|
||||
SM_CYKANJIWINDOW:
|
||||
begin
|
||||
|
@ -259,6 +259,7 @@ type
|
||||
|
||||
|
||||
implementation
|
||||
uses qtint;
|
||||
|
||||
{$include qtpagecontrol.inc}
|
||||
|
||||
@ -2064,8 +2065,7 @@ begin
|
||||
case AValue of
|
||||
vsIcon:
|
||||
begin
|
||||
x := QStyle_pixelMetric(QApplication_style(), QStylePM_IconViewIconSize,
|
||||
nil, ItemViewWidget);
|
||||
x := GetPixelMetric(QStylePM_IconViewIconSize, nil, ItemViewWidget);
|
||||
Size.cx := x;
|
||||
Size.cy := x;
|
||||
if Assigned(TListView(ALV).LargeImages) then
|
||||
@ -2076,8 +2076,7 @@ begin
|
||||
end;
|
||||
vsSmallIcon:
|
||||
begin
|
||||
x := QStyle_pixelMetric(QApplication_style(), QStylePM_ListViewIconSize,
|
||||
nil, ItemViewWidget);
|
||||
x := GetPixelMetric(QStylePM_ListViewIconSize, nil, ItemViewWidget);
|
||||
Size.cx := x;
|
||||
Size.cy := x;
|
||||
if Assigned(TListView(ALV).SmallImages) then
|
||||
@ -2088,8 +2087,7 @@ begin
|
||||
end;
|
||||
vsList, vsReport:
|
||||
begin
|
||||
x := QStyle_pixelMetric(QApplication_style(), QStylePM_ListViewIconSize,
|
||||
nil, ItemViewWidget);
|
||||
x := GetPixelMetric(QStylePM_ListViewIconSize, nil, ItemViewWidget);
|
||||
Size.cx := x;
|
||||
Size.cy := x;
|
||||
end;
|
||||
|
@ -1297,10 +1297,10 @@ begin
|
||||
begin
|
||||
end else
|
||||
begin
|
||||
dx := QStyle_pixelMetric(QApplication_style(), QStylePM_LayoutLeftMargin) +
|
||||
QStyle_pixelMetric(QApplication_style(), QStylePM_LayoutRightMargin);
|
||||
dy := QStyle_pixelMetric(QApplication_style(), QStylePM_LayoutTopMargin) +
|
||||
QStyle_pixelMetric(QApplication_style(), QStylePM_LayoutBottomMargin);
|
||||
dx := GetPixelMetric(QStylePM_LayoutLeftMargin, nil, nil) +
|
||||
GetPixelMetric(QStylePM_LayoutRightMargin, nil, nil);
|
||||
dy := GetPixelMetric(QStylePM_LayoutTopMargin, nil, nil) +
|
||||
GetPixelMetric(QStylePM_LayoutBottomMargin, nil, nil);
|
||||
|
||||
aClientRect:=Rect(0,0,
|
||||
Max(0, aWidth - dx),
|
||||
|
Loading…
Reference in New Issue
Block a user