Merged revisions 55554 #8e53c46753,55555 #2fa1c8a50c,55737 #2e764a39b1,55759 #2b31dde183,55760 #d1dc375792,55774 #53e535b678,55782 #c92ee9b044 from trunk.

------------------------------------------------------------------------
r55554 | zeljko | 2017-07-21 11:08:43 +0200 (Fri, 21 Jul 2017) | 2 lines

Qt, Qt5: fixed ItemShow - scroll to item. issue #32078

------------------------------------------------------------------------
r55555 | zeljko | 2017-07-21 13:25:10 +0200 (Fri, 21 Jul 2017) | 2 lines

Qt5: use QScreen_grabWindow() instead of QPixmap_grabWindow(). part of issue #32141

------------------------------------------------------------------------
r55737 | zeljko | 2017-08-23 11:29:58 +0200 (Wed, 23 Aug 2017) | 2 lines

Qt4: fixed build under mswindows

------------------------------------------------------------------------
r55759 | zeljko | 2017-08-30 11:29:17 +0200 (Wed, 30 Aug 2017) | 2 lines

Qt5: implemented InitStockFont. part of issue #32354

------------------------------------------------------------------------
r55760 | zeljko | 2017-08-30 12:20:07 +0200 (Wed, 30 Aug 2017) | 2 lines

Qt,Qt5: fixed painting of TQtHintWindow. issue #32354

------------------------------------------------------------------------
r55774 | zeljko | 2017-09-02 20:13:58 +0200 (Sat, 02 Sep 2017) | 2 lines

Qt, Qt5: check if handle is valid inside various routines, fixes some sparta ide crashes.

------------------------------------------------------------------------
r55782 | zeljko | 2017-09-03 19:50:53 +0200 (Sun, 03 Sep 2017) | 2 lines

Qt5: TQtGroupBox does not need offset as in Qt4, since Qt5 provides correct coordinates. issue #32186

------------------------------------------------------------------------

git-svn-id: branches/fixes_1_8@55964 -
This commit is contained in:
zeljko 2017-10-03 08:55:07 +00:00
parent 12f30f41c9
commit 55cf3f4a53
8 changed files with 135 additions and 79 deletions

View File

@ -713,6 +713,7 @@ type
public
procedure InitializeWidget; override;
procedure DeInitializeWidget; override;
function CanPaintBackground: Boolean; override;
procedure SetDefaultColorRoles; override;
procedure setVisible(AVisible: Boolean); override;
property NeedRestoreVisible: Boolean read FNeedRestoreVisible write FNeedRestoreVisible;
@ -1523,6 +1524,7 @@ type
procedure setHeaderVisible(AVisible: Boolean);
procedure setItemSelected(AItem: QTreeWidgetItemH; ASelect: Boolean);
procedure setStretchLastSection(AValue: Boolean);
procedure scrollToItem(Item: QTreeWidgetItemH; hint: QAbstractItemViewScrollHint);
{$IFDEF TEST_QT_SORTING}
// direct Qt sorting via QtUserData ptr = our TListItem, crashes sometimes - qt bug.
procedure sortItems(Acolumn: Integer; AOrder: QtSortOrder);
@ -15395,6 +15397,12 @@ begin
Header.setStretchLastSection(AValue);
end;
procedure TQtTreeWidget.scrollToItem(Item: QTreeWidgetItemH;
hint: QAbstractItemViewScrollHint);
begin
QTreeWidget_scrollToItem(QTreeWidgetH(Widget), Item, hint);
end;
{$IFDEF TEST_QT_SORTING}
procedure TQtTreeWidget.sortItems(Acolumn: Integer; AOrder: QtSortOrder);
var
@ -18238,6 +18246,12 @@ begin
inherited DeInitializeWidget;
end;
function TQtHintWindow.CanPaintBackground: Boolean;
begin
Result := CanSendLCLMessage and getEnabled and
(LCLObject.Color <> clDefault);
end;
procedure TQtHintWindow.SetDefaultColorRoles;
begin
WidgetColorRole := QPaletteToolTipBase;

View File

@ -4957,7 +4957,9 @@ end;
function TQtWidgetSet.IsIconic(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).isMinimized;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).isMinimized;
end;
function TQtWidgetSet.IsWindow(handle: HWND): boolean;
@ -4967,17 +4969,23 @@ end;
function TQtWidgetSet.IsWindowEnabled(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).getEnabled and TQtWidget(Handle).getVisible;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).getEnabled and TQtWidget(Handle).getVisible;
end;
function TQtWidgetSet.IsWindowVisible(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).getVisible;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).getVisible;
end;
function TQtWidgetSet.IsZoomed(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).isMaximized;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).isMaximized;
end;
{------------------------------------------------------------------------------

View File

@ -1548,11 +1548,15 @@ begin
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(AIndex);
QtListWidget.setItemVisible(LWI, True);
if not PartialOK then
QtListWidget.scrollToItem(AIndex, QAbstractItemViewEnsureVisible);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(AIndex);
QtTreeWidget.setItemVisible(TWI, True);
if not PartialOK then
QtTreeWidget.scrollToItem(TWI, QAbstractItemViewEnsureVisible);
end;
end;

View File

@ -411,10 +411,12 @@ var
ReturnList: QStringListH;
i: integer;
QtFileDialog: TQtFileDialog;
{$if defined(QT_NATIVE_DIALOGS) or defined(MSWINDOWS)}
s: string;
{$endif}
{$ifdef QT_NATIVE_DIALOGS}
selectedFilter, saveFileName, saveFilter, saveTitle, sDir: WideString;
Flags: Cardinal;
s: string;
{$endif}
ActiveWin: HWND;
begin

View File

@ -713,6 +713,7 @@ type
public
procedure InitializeWidget; override;
procedure DeInitializeWidget; override;
function CanPaintBackground: Boolean; override;
procedure SetDefaultColorRoles; override;
procedure setVisible(AVisible: Boolean); override;
property NeedRestoreVisible: Boolean read FNeedRestoreVisible write FNeedRestoreVisible;
@ -1523,6 +1524,7 @@ type
procedure setHeaderVisible(AVisible: Boolean);
procedure setItemSelected(AItem: QTreeWidgetItemH; ASelect: Boolean);
procedure setStretchLastSection(AValue: Boolean);
procedure scrollToItem(Item: QTreeWidgetItemH; hint: QAbstractItemViewScrollHint);
{$IFDEF TEST_QT_SORTING}
// direct Qt sorting via QtUserData ptr = our TListItem, crashes sometimes - qt bug.
procedure sortItems(Acolumn: Integer; AOrder: QtSortOrder);
@ -8469,10 +8471,6 @@ function TQtGroupBox.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
var
ResizeEvent: QResizeEventH;
NewSize, OldSize: TSize;
R: TRect;
APos, AGlobalPos: TQtPoint;
APosF, AGlobalPosF: TQtPointF;
ANewMouseEvent: QMouseEventH;
begin
Result := False;
QEvent_accept(Event);
@ -8486,72 +8484,8 @@ begin
end;
exit;
end;
{about issue #29572: we must use main widget for mouse
events, since using it in FCentralWidget above freezes
application for some reason. Offsetting pos fixes problem.}
{For possible problems with Mouse events check issue #29572 and #32186}
case QEvent_type(Event) of
QEventWheel: // issue #29572
begin
QMouseEvent_pos(QMouseEventH(Event), @APos);
QMouseEvent_globalPos(QMouseEventH(Event), @AGlobalPos);
QWidget_geometry(FCentralWidget, @R);
inc(APos.X, -R.Left);
inc(APos.Y, -R.Top);
APosF.X := APos.X;
APosF.Y := APos.Y;
AGlobalPosF.X := AGlobalPos.X;
AGlobalPosF.y := AGlobalPos.Y;
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APosF, @AGlobalPosF, QMouseEvent_button(QMouseEventH(Event)),
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
try
Result := SlotMouseWheel(Sender, ANewMouseEvent);
finally
QMouseEvent_destroy(ANewMouseEvent);
end;
end;
QEventMouseMove: // issue #29572
begin
// APos :=
QMouseEvent_pos(QMouseEventH(Event), @APos);
// AGlobalPos :=
QMouseEvent_globalPos(QMouseEventH(Event), @AGlobalPos);
QWidget_geometry(FCentralWidget, @R);
inc(APos.X, -R.Left);
inc(APos.Y, -R.Top);
APosF.X := APos.X;
APosF.Y := APos.Y;
AGlobalPosF.X := AGlobalPos.X;
AGLobalPosF.y := AGlobalPos.Y;
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APosF, @AGlobalPosF, QMouseEvent_button(QMouseEventH(Event)),
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
try
Result := SlotMouseMove(Sender, ANewMouseEvent);
finally
QMouseEvent_destroy(ANewMouseEvent);
end;
end;
QEventMouseButtonPress,
QEventMouseButtonRelease,
QEventMouseButtonDblClick: // issue #29572
begin
// APos :=
QMouseEvent_pos(QMouseEventH(Event), @APos);
QMouseEvent_globalPos(QMouseEventH(Event), @AGlobalPos);
QWidget_geometry(FCentralWidget, @R);
inc(APos.X, -R.Left);
inc(APos.Y, -R.Top);
APosF.X := APos.X;
APosF.Y := APos.Y;
AGlobalPosF.X := AGlobalPos.X;
AGLobalPosF.y := AGlobalPos.Y;
ANewMouseEvent := QMouseEvent_create(QEvent_type(Event), @APosF, @AGlobalPosF, QMouseEvent_button(QMouseEventH(Event)),
QMouseEvent_buttons(QMouseEventH(Event)), QInputEvent_modifiers(QInputEventH(Event)));
try
Result := SlotMouse(Sender, ANewMouseEvent);
finally
QMouseEvent_destroy(ANewMouseEvent);
end;
end;
QEventPaint:
begin
Result := False;
@ -15375,6 +15309,12 @@ begin
Header.setStretchLastSection(AValue);
end;
procedure TQtTreeWidget.scrollToItem(Item: QTreeWidgetItemH;
hint: QAbstractItemViewScrollHint);
begin
QTreeWidget_scrollToItem(QTreeWidgetH(Widget), Item, hint);
end;
{$IFDEF TEST_QT_SORTING}
procedure TQtTreeWidget.sortItems(Acolumn: Integer; AOrder: QtSortOrder);
var
@ -18190,6 +18130,12 @@ begin
inherited DeInitializeWidget;
end;
function TQtHintWindow.CanPaintBackground: Boolean;
begin
Result := CanSendLCLMessage and getEnabled and
(LCLObject.Color <> clDefault);
end;
procedure TQtHintWindow.SetDefaultColorRoles;
begin
WidgetColorRole := QPaletteToolTipBase;

View File

@ -4788,6 +4788,74 @@ begin
CritSection:=TCriticalSection(ACritSec);
end;
function TQtWidgetSet.InitStockFont(AFont: TObject; AStockFont: TStockFont
): Boolean;
var
Font: TFont absolute AFont;
AMenu: QMenuH;
QtFont: QFontH;
AName: WideString;
begin
Result := False;
if AStockFont = sfMenu then
begin
AName := 'MenuTitle';
AMenu := QMenu_create(@AName, nil);
try
QtFont := QWidget_font(AMenu);
QFont_family(QtFont, @AName);
Font.Name := UTF16ToUTF8(AName);
if QFont_pointSize(QtFont) > 0 then
Font.Size := QFont_pointSize(QtFont)
else
Font.Height := QFont_pixelSize(QtFont);
if QFont_bold(QtFont) then
Font.Style := Font.Style + [fsBold];
if QFont_italic(QtFont) then
Font.Style := Font.Style + [fsItalic];
if QFont_underline(QtFont) then
Font.Style := Font.Style + [fsUnderline];
if QFont_strikeOut(QtFont) then
Font.Style := Font.Style + [fsStrikeOut];
Font.Color := clMenuText;
Result := True;
finally
QWidget_destroy(AMenu);
end;
end else
begin
QtFont := QFont_create;
try
if AStockFont = sfHint then
QToolTip_font(QtFont)
else
QApplication_font(QtFont);
QFont_family(QtFont, @AName);
Font.Name := UTF16ToUTF8(AName);
if QFont_pointSize(QtFont) > 0 then
Font.Size := QFont_pointSize(QtFont)
else
Font.Height := QFont_pixelSize(QtFont);
if QFont_bold(QtFont) then
Font.Style := Font.Style + [fsBold];
if QFont_italic(QtFont) then
Font.Style := Font.Style + [fsItalic];
if QFont_underline(QtFont) then
Font.Style := Font.Style + [fsUnderline];
if QFont_strikeOut(QtFont) then
Font.Style := Font.Style + [fsStrikeOut];
{comment font.color for check if hintfont works correct}
if AStockFont = sfHint then
Font.Color := clInfoText;
Result := True;
finally
QFont_destroy(QtFont);
end;
end;
end;
function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
var
QtDC: TQtDeviceContext absolute dc;
@ -4832,7 +4900,9 @@ end;
function TQtWidgetSet.IsIconic(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).isMinimized;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).isMinimized;
end;
function TQtWidgetSet.IsWindow(handle: HWND): boolean;
@ -4842,17 +4912,23 @@ end;
function TQtWidgetSet.IsWindowEnabled(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).getEnabled and TQtWidget(Handle).getVisible;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).getEnabled and TQtWidget(Handle).getVisible;
end;
function TQtWidgetSet.IsWindowVisible(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).getVisible;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).getVisible;
end;
function TQtWidgetSet.IsZoomed(Handle: HWND): boolean;
begin
Result := TQtWidget(Handle).isMaximized;
Result := False;
if IsValidHandle(Handle) then
Result := TQtWidget(Handle).isMaximized;
end;
{------------------------------------------------------------------------------
@ -6684,7 +6760,8 @@ begin
begin
with SrcQDC.getDeviceSize do
TmpPixmap := QPixmap_create(x, y);
QPixmap_grabWindow(TmpPixmap, QWidget_winId(SrcQDC.Parent), 0, 0);
QScreen_grabWindow(QGuiApplication_primaryScreen, TmpPixmap, QWidget_winId(SrcQDC.Parent), 0, 0);
// QPixmap_grabWindow(TmpPixmap, QWidget_winId(SrcQDC.Parent), 0, 0);
Image := QImage_create();
QPixmap_toImage(TmpPixmap, Image);
QPixmap_destroy(TmpPixmap);

View File

@ -142,6 +142,7 @@ function HideCaret(hWnd: HWND): Boolean; override;
function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override;
function InvalidateRgn(aHandle: HWND; Rgn: HRGN; Erase: Boolean): Boolean; override;
procedure InitializeCriticalSection(var CritSection: TCriticalSection); override;
function InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean; override;
function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; override;
function IsIconic(Handle: HWND): boolean; override;
function IsWindow(handle: HWND): boolean; override;

View File

@ -1547,11 +1547,15 @@ begin
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(AIndex);
QtListWidget.setItemVisible(LWI, True);
if not PartialOK then
QtListWidget.scrollToItem(AIndex, QAbstractItemViewEnsureVisible);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(AIndex);
QtTreeWidget.setItemVisible(TWI, True);
if not PartialOK then
QtTreeWidget.scrollToItem(TWI, QAbstractItemViewEnsureVisible);
end;
end;