mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:39:10 +02:00
Qt: Fix for #11796 - except for OI.Changed TabWidget behaviour, added some new routines, fixed focus problems with tabwidget.
git-svn-id: trunk@15958 -
This commit is contained in:
parent
64d1536bb4
commit
d85ac506ff
@ -607,8 +607,11 @@ type
|
|||||||
private
|
private
|
||||||
FCurrentChangedHook: QTabWidget_hookH;
|
FCurrentChangedHook: QTabWidget_hookH;
|
||||||
FTabBarEventHook: QWidget_hookH;
|
FTabBarEventHook: QWidget_hookH;
|
||||||
|
FTabBarChangedHook: QTabBar_hookH;
|
||||||
FTabBar: QTabBarH;
|
FTabBar: QTabBarH;
|
||||||
|
function getShowTabs: Boolean;
|
||||||
function getTabBar: QTabBarH;
|
function getTabBar: QTabBarH;
|
||||||
|
procedure setShowTabs(const AValue: Boolean);
|
||||||
protected
|
protected
|
||||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||||
public
|
public
|
||||||
@ -617,6 +620,7 @@ type
|
|||||||
|
|
||||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||||
procedure SignalCurrentChanged(Index: Integer); cdecl;
|
procedure SignalCurrentChanged(Index: Integer); cdecl;
|
||||||
|
procedure SignalTabBarCurrentChanged(Index: Integer); cdecl;
|
||||||
function SlotTabBarMouse(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotTabBarMouse(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
public
|
public
|
||||||
function indexOf(const AWidget: QWidgetH): integer;
|
function indexOf(const AWidget: QWidgetH): integer;
|
||||||
@ -627,10 +631,13 @@ type
|
|||||||
function getTabPosition: QTabWidgetTabPosition;
|
function getTabPosition: QTabWidgetTabPosition;
|
||||||
procedure removeTab(AIndex: Integer);
|
procedure removeTab(AIndex: Integer);
|
||||||
procedure setCurrentIndex(AIndex: Integer);
|
procedure setCurrentIndex(AIndex: Integer);
|
||||||
|
procedure setCurrentWidget(APage: TQtWidget);
|
||||||
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
||||||
procedure setTabPosition(ATabPosition: QTabWidgetTabPosition);
|
procedure setTabPosition(ATabPosition: QTabWidgetTabPosition);
|
||||||
procedure setTabText(index: Integer; p2: WideString);
|
procedure setTabText(index: Integer; p2: WideString);
|
||||||
|
function tabAt(APoint: TPoint): Integer;
|
||||||
|
|
||||||
|
property ShowTabs: Boolean read getShowTabs write setShowTabs;
|
||||||
property TabBar: QTabBarH read getTabBar;
|
property TabBar: QTabBarH read getTabBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2401,6 +2408,14 @@ var
|
|||||||
Modifiers: QtKeyboardModifiers;
|
Modifiers: QtKeyboardModifiers;
|
||||||
MousePos: TQtPoint;
|
MousePos: TQtPoint;
|
||||||
begin
|
begin
|
||||||
|
{$note fix for #11796, only OI is a black sheep}
|
||||||
|
if Assigned(LCLObject.PopupMenu) then
|
||||||
|
begin
|
||||||
|
if (Self is TQtComboBox) and (TQtComboBox(Self).FLineEdit <> nil) then
|
||||||
|
QWidget_setContextMenuPolicy(TQtComboBox(Self).FLineEdit.Widget, QtNoContextMenu);
|
||||||
|
QWidget_setContextMenuPolicy(Widget, QtNoContextMenu);
|
||||||
|
end;
|
||||||
|
|
||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
MousePos := QContextMenuEvent_pos(QContextMenuEventH(Event))^;
|
MousePos := QContextMenuEvent_pos(QContextMenuEventH(Event))^;
|
||||||
OffsetMousePos(@MousePos);
|
OffsetMousePos(@MousePos);
|
||||||
@ -5205,10 +5220,23 @@ end;
|
|||||||
function TQtTabWidget.getTabBar: QTabBarH;
|
function TQtTabWidget.getTabBar: QTabBarH;
|
||||||
begin
|
begin
|
||||||
if FTabBar = nil then
|
if FTabBar = nil then
|
||||||
|
begin
|
||||||
FTabBar := QLCLTabWidget_tabBarHandle(QTabWidgetH(Widget));
|
FTabBar := QLCLTabWidget_tabBarHandle(QTabWidgetH(Widget));
|
||||||
|
QWidget_setFocusPolicy(FTabBar, QtNoFocus);
|
||||||
|
end;
|
||||||
Result := FTabBar;
|
Result := FTabBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtTabWidget.getShowTabs: Boolean;
|
||||||
|
begin
|
||||||
|
Result := QWidget_isVisible(TabBar);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtTabWidget.setShowTabs(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
QWidget_setVisible(TabBar, AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
function TQtTabWidget.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
function TQtTabWidget.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||||
begin
|
begin
|
||||||
// Creates the widget
|
// Creates the widget
|
||||||
@ -5233,9 +5261,12 @@ begin
|
|||||||
|
|
||||||
FCurrentChangedHook := QTabWidget_hook_create(Widget);
|
FCurrentChangedHook := QTabWidget_hook_create(Widget);
|
||||||
FTabBarEventHook := QWidget_hook_create(TabBar);
|
FTabBarEventHook := QWidget_hook_create(TabBar);
|
||||||
|
FTabBarChangedHook := QTabBar_hook_create(TabBar);
|
||||||
|
|
||||||
QTabWidget_currentChanged_Event(Method) := @SignalCurrentChanged;
|
QTabWidget_currentChanged_Event(Method) := @SignalCurrentChanged;
|
||||||
QTabWidget_hook_hook_currentChanged(FCurrentChangedHook, Method);
|
QTabWidget_hook_hook_currentChanged(FCurrentChangedHook, Method);
|
||||||
|
QTabBar_currentChanged_Event(Method) := @SignalTabBarCurrentChanged;
|
||||||
|
QTabBar_hook_hook_currentChanged(FTabBarChangedHook, Method);
|
||||||
TEventFilterMethod(Method) := @EventFilter;
|
TEventFilterMethod(Method) := @EventFilter;
|
||||||
QObject_hook_hook_events(FTabBarEventHook, Method);
|
QObject_hook_hook_events(FTabBarEventHook, Method);
|
||||||
end;
|
end;
|
||||||
@ -5337,10 +5368,15 @@ begin
|
|||||||
QTabWidget_setCurrentIndex(QTabWidgetH(Widget), AIndex);
|
QTabWidget_setCurrentIndex(QTabWidgetH(Widget), AIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtTabWidget.setCurrentWidget(APage: TQtWidget);
|
||||||
|
begin
|
||||||
|
QTabWidget_setCurrentWidget(QTabWidgetH(Widget), APage.Widget);
|
||||||
|
APage.setFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQtTabWidget.setFocusPolicy(const APolicy: QtFocusPolicy);
|
procedure TQtTabWidget.setFocusPolicy(const APolicy: QtFocusPolicy);
|
||||||
begin
|
begin
|
||||||
inherited setFocusPolicy(APolicy);
|
QWidget_setFocusPolicy(TabBar, QtNoFocus);
|
||||||
QWidget_setFocusPolicy(TabBar, QtClickFocus);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -5371,6 +5407,26 @@ begin
|
|||||||
Msg.Msg := LM_NOTIFY;
|
Msg.Msg := LM_NOTIFY;
|
||||||
FillChar(Hdr, SizeOf(Hdr), 0);
|
FillChar(Hdr, SizeOf(Hdr), 0);
|
||||||
|
|
||||||
|
Hdr.hwndFrom := LCLObject.Handle;
|
||||||
|
Hdr.Code := TCN_SELCHANGING;
|
||||||
|
Hdr.idFrom := Index;
|
||||||
|
Msg.NMHdr := @Hdr;
|
||||||
|
Msg.Result := 0;
|
||||||
|
DeliverMessage(Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtTabWidget.SignalTabBarCurrentChanged(Index: Integer); cdecl;
|
||||||
|
var
|
||||||
|
Msg: TLMNotify;
|
||||||
|
Hdr: TNmHdr;
|
||||||
|
begin
|
||||||
|
if LCLObject = nil then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
FillChar(Msg, SizeOf(Msg), 0);
|
||||||
|
Msg.Msg := LM_NOTIFY;
|
||||||
|
FillChar(Hdr, SizeOf(Hdr), 0);
|
||||||
|
|
||||||
Hdr.hwndFrom := LCLObject.Handle;
|
Hdr.hwndFrom := LCLObject.Handle;
|
||||||
Hdr.Code := TCN_SELCHANGE;
|
Hdr.Code := TCN_SELCHANGE;
|
||||||
Hdr.idFrom := Index;
|
Hdr.idFrom := Index;
|
||||||
@ -5423,6 +5479,14 @@ begin
|
|||||||
QTabWidget_setTabText(QTabWidgetH(Widget), index, @p2);
|
QTabWidget_setTabText(QTabWidgetH(Widget), index, @p2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtTabWidget.tabAt(APoint: TPoint): Integer;
|
||||||
|
var
|
||||||
|
AQtPoint: TQtPoint;
|
||||||
|
begin
|
||||||
|
AQtPoint := QtPoint(APoint.x, APoint.y);
|
||||||
|
Result := QTabBar_tabAt(TabBar, @AQtPoint);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TQtComboBox }
|
{ TQtComboBox }
|
||||||
|
|
||||||
function TQtComboBox.GetLineEdit: TQtLineEdit;
|
function TQtComboBox.GetLineEdit: TQtLineEdit;
|
||||||
|
@ -37,7 +37,7 @@ uses
|
|||||||
SysUtils, Classes, Controls, Graphics, Forms, StdCtrls, ExtCtrls, LCLType,
|
SysUtils, Classes, Controls, Graphics, Forms, StdCtrls, ExtCtrls, LCLType,
|
||||||
ImgList,
|
ImgList,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
WSExtCtrls, WSLCLClasses;
|
WSExtCtrls, WSProc, WSLCLClasses;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -329,7 +329,6 @@ begin
|
|||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtWSCustomNotebook.CreateHandle');
|
WriteLn('TQtWSCustomNotebook.CreateHandle');
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
QtTabWidget := TQtTabWidget.Create(AWinControl, AParams);
|
QtTabWidget := TQtTabWidget.Create(AWinControl, AParams);
|
||||||
QtTabWidget.SetTabPosition(QTabWidgetTabPositionMap[TCustomNoteBook(AWinControl).TabPosition]);
|
QtTabWidget.SetTabPosition(QTabWidgetTabPositionMap[TCustomNoteBook(AWinControl).TabPosition]);
|
||||||
QtTabWidget.AttachEvents;
|
QtTabWidget.AttachEvents;
|
||||||
@ -375,45 +374,29 @@ begin
|
|||||||
WriteLn('TQtWSCustomNotebook.RemovePage');
|
WriteLn('TQtWSCustomNotebook.RemovePage');
|
||||||
{$endif}
|
{$endif}
|
||||||
TabWidget := TQtTabWidget(ANotebook.Handle);
|
TabWidget := TQtTabWidget(ANotebook.Handle);
|
||||||
|
TabWidget.setUpdatesEnabled(false);
|
||||||
TabWidget.removeTab(AIndex);
|
TabWidget.removeTab(AIndex);
|
||||||
|
TabWidget.setUpdatesEnabled(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TQtWSCustomNotebook.GetTabIndexAtPos(
|
class function TQtWSCustomNotebook.GetTabIndexAtPos(
|
||||||
const ANotebook: TCustomNotebook; const AClientPos: TPoint): integer;
|
const ANotebook: TCustomNotebook; const AClientPos: TPoint): integer;
|
||||||
var
|
var
|
||||||
TabWidget: TQtTabWidget;
|
TabWidget: TQtTabWidget;
|
||||||
APoint: TQtPoint;
|
|
||||||
begin
|
begin
|
||||||
TabWidget := TQtTabWidget(ANotebook.Handle);
|
TabWidget := TQtTabWidget(ANotebook.Handle);
|
||||||
if TabWidget.TabBar <> nil then
|
Result := TabWidget.tabAt(AClientPos);
|
||||||
begin
|
|
||||||
APoint := QtPoint(AClientPos.x, AClientPos.y);
|
|
||||||
|
|
||||||
Result := QTabBar_tabAt(TabWidget.TabBar, @APoint);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Result := -1;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TQtWSCustomNotebook.SetPageIndex(
|
class procedure TQtWSCustomNotebook.SetPageIndex(
|
||||||
const ANotebook: TCustomNotebook; const AIndex: integer);
|
const ANotebook: TCustomNotebook; const AIndex: integer);
|
||||||
var
|
var
|
||||||
TabWidget: TQtTabWidget;
|
TabWidget: TQtTabWidget;
|
||||||
OldIndex: Integer;
|
|
||||||
begin
|
begin
|
||||||
|
if not WSCheckHandleAllocated(ANotebook, 'SetPageIndex') then
|
||||||
|
Exit;
|
||||||
TabWidget := TQtTabWidget(ANotebook.Handle);
|
TabWidget := TQtTabWidget(ANotebook.Handle);
|
||||||
|
|
||||||
// copy pasted from win32wsextctrls with corrections
|
|
||||||
|
|
||||||
OldIndex := TabWidget.getCurrentIndex;
|
|
||||||
TabWidget.setCurrentIndex(AIndex);
|
TabWidget.setCurrentIndex(AIndex);
|
||||||
if not (csDestroying in ANotebook.ComponentState) then
|
|
||||||
begin
|
|
||||||
if (OldIndex >= 0) and (OldIndex <> AIndex) and
|
|
||||||
(OldIndex < ANotebook.PageCount) and
|
|
||||||
(ANotebook.CustomPage(OldIndex).HandleAllocated) then
|
|
||||||
TQtWidget(ANotebook.CustomPage(OldIndex).Handle).setVisible(False);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TQtWSCustomNotebook.SetTabCaption(
|
class procedure TQtWSCustomNotebook.SetTabCaption(
|
||||||
@ -436,7 +419,7 @@ var
|
|||||||
begin
|
begin
|
||||||
TabWidget := TQtTabWidget(ANotebook.Handle);
|
TabWidget := TQtTabWidget(ANotebook.Handle);
|
||||||
if TabWidget.TabBar <> nil then
|
if TabWidget.TabBar <> nil then
|
||||||
QWidget_setVisible(TabWidget.TabBar, AShowTabs);
|
TabWidget.ShowTabs := AShowTabs;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtWSCustomRadioGroup }
|
{ TQtWSCustomRadioGroup }
|
||||||
|
Loading…
Reference in New Issue
Block a user