- all event attaching code moved to TQtWidget.AttachEvents, TQtWidget.DetachEvents and descendants

- initial implementation of Qt Caret by *Andreas Hausladen* with changes. Compile with -dShowQtCaret to test
- fixed bug caused memory corruption
- other minor fixes

git-svn-id: trunk@11465 -
This commit is contained in:
paul 2007-07-12 05:47:15 +00:00
parent 0c7849de57
commit e720286a68
15 changed files with 1161 additions and 484 deletions

1
.gitattributes vendored
View File

@ -2697,6 +2697,7 @@ lcl/interfaces/qt/interfaces.pp svneol=native#text/pascal
lcl/interfaces/qt/qt4.pas svneol=native#text/plain
lcl/interfaces/qt/qt43.pas -text
lcl/interfaces/qt/qtcallback.inc svneol=native#text/pascal
lcl/interfaces/qt/qtcaret.pas svneol=native#text/pascal
lcl/interfaces/qt/qtint.pp svneol=native#text/pascal
lcl/interfaces/qt/qtlclintf.inc svneol=native#text/pascal
lcl/interfaces/qt/qtlclintfh.inc svneol=native#text/pascal

View File

@ -0,0 +1,401 @@
{
/***************************************************************************
QtCaret.pas - Qt Caret Emulation
-------------------------------------
copyright (c) Andreas Hausladen
adopted for Lazarus and Qt4 by Lazarus Team
***************************************************************************/
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit QtCaret;
{$mode delphi}{$H+}
interface
uses
// Bindings
{$ifdef USE_QT_4_3}
qt43,
{$else}
qt4,
{$endif}
// Free Pascal
Classes, SysUtils, Types,
// Widgetset
QtObjects, QtWidgets,
// LCL
LCLType, LCLIntf, Graphics, ExtCtrls;
// defines
{.$DEFINE ShowQtCaret}
type
TEmulatedCaret = class(TComponent)
private
FTimer: TTimer;
FWndId: Cardinal;
FWidget: TQtWidget;
FPixmap: QPixmapH;
FWidth, FHeight: Integer;
FPos: TQtPoint;
FVisible: Boolean;
FVisibleState: Boolean;
FCritSect: TCriticalSection;
procedure SetPos(const Value: TQtPoint);
protected
procedure DoTimer(Sender: TObject);
procedure DrawCaret; virtual;
function CreateColorPixmap(Color: Cardinal): QPixmapH;
procedure SetWidget(AWidget: TQtWidget);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Lock;
procedure Unlock;
function CreateCaret(AWidget: TQtWidget; Pixmap: QPixmapH; Width, Height: Integer): Boolean;
function DestroyCaret: Boolean;
function IsValid: Boolean;
function Show(AWidget: TQtWidget): Boolean;
function Hide: Boolean;
property Timer: TTimer read FTimer;
property Pos: TQtPoint read FPos write SetPos;
end;
function CreateCaret(Widget: TQtWidget; Pixmap: QPixmapH; Width, Height: Integer): Boolean; overload;
function CreateCaret(Widget: TQtWidget; ColorCaret: Cardinal; Width, Height: Integer): Boolean; overload;
function HideCaret(Widget: TQtWidget): Boolean;
function ShowCaret(Widget: TQtWidget): Boolean;
function SetCaretPos(X, Y: Integer): Boolean;
function GetCaretPos(var Pt: TPoint): Boolean;
function DestroyCaret: Boolean;
procedure DrawCaret;
implementation
var
GlobalCaret: TEmulatedCaret = nil;
procedure GlobalCaretNeeded;
begin
if GlobalCaret = nil then
GlobalCaret := TEmulatedCaret.Create(nil);
end;
function QtPoint(X, Y: Integer): TQtPoint;
begin
Result.X := X;
Result.Y := Y;
end;
procedure DrawCaret;
begin
GlobalCaretNeeded;
if Assigned(GlobalCaret) then
begin
GlobalCaret.Lock;
try
GlobalCaret.DrawCaret;
finally
GlobalCaret.Unlock;
end;
end;
end;
function CreateCaret(Widget: TQtWidget; Pixmap: QPixmapH; Width, Height: Integer): Boolean;
begin
GlobalCaretNeeded;
GlobalCaret.Lock;
try
Result := GlobalCaret.CreateCaret(Widget, Pixmap, Width, Height);
finally
GlobalCaret.Unlock;
end;
end;
function CreateCaret(Widget: TQtWidget; ColorCaret: Cardinal; Width, Height: Integer): Boolean;
begin
Result := CreateCaret(Widget, QPixmapH(ColorCaret), Width, Height);
end;
function GetCaretBlinkTime: Cardinal;
begin
Result := QApplication_cursorFlashTime;
end;
function SetCaretBlinkTime(uMSeconds: Cardinal): LongBool;
begin
Result := True;
try
QApplication_setCursorFlashTime(uMSeconds);
if assigned(GlobalCaret) then
begin
GlobalCaret.Lock;
try
GlobalCaret.Timer.Interval := GetCaretBlinkTime;
finally
GlobalCaret.Unlock;
end;
end;
except
Result := False;
end;
end;
function HideCaret(Widget: TQtWidget): Boolean;
begin
GlobalCaretNeeded;
if Assigned(GlobalCaret) then
begin
GlobalCaret.Lock;
try
Result := GlobalCaret.Hide;
finally
GlobalCaret.Unlock;
end;
end
else
Result := false;
end;
function ShowCaret(Widget: TQtWidget): Boolean;
begin
GlobalCaretNeeded;
GlobalCaret.Lock;
try
Result := GlobalCaret.Show(Widget);
finally
GlobalCaret.Unlock;
end;
end;
function SetCaretPos(X, Y: Integer): Boolean;
begin
Result := True;
GlobalCaretNeeded;
GlobalCaret.Lock;
try
GlobalCaret.Pos := QtPoint(X, Y);
finally
GlobalCaret.Unlock;
end;
end;
function GetCaretPos(var Pt: TPoint): Boolean;
begin
Result := True;
GlobalCaretNeeded;
GlobalCaret.Lock;
try
with GlobalCaret.Pos do
begin
Pt.x := X;
Pt.y := Y;
end;
finally
GlobalCaret.Unlock;
end;
end;
function DestroyCaret: Boolean;
begin
if Assigned(GlobalCaret) then
begin
GlobalCaret.Lock;
try
Result := GlobalCaret.DestroyCaret;
finally
GlobalCaret.Unlock;
end;
end
else
Result := False;
end;
{ TEmulatedCaret }
constructor TEmulatedCaret.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
InitializeCriticalSection(FCritSect);
FTimer := TTimer.Create(self);
FTimer.Enabled := False;
FTimer.Interval := GetCaretBlinkTime;
FTimer.OnTimer := DoTimer;
end;
destructor TEmulatedCaret.Destroy;
begin
DestroyCaret;
DeleteCriticalSection(FCritSect);
inherited Destroy;
end;
function TEmulatedCaret.CreateCaret(AWidget: TQtWidget; Pixmap: QPixmapH;
Width, Height: Integer): Boolean;
begin
DestroyCaret;
SetWidget(AWidget);
FWidth := Width;
FHeight := Height;
if Cardinal(Pixmap) > $FFFF then
FPixmap := QPixmap_create(Pixmap)
else
FPixmap := CreateColorPixmap(Integer(Pixmap));
Result := IsValid;
{$IFDEF ShowQtCaret}
FTimer.Enabled := True;
{$ENDIF}
end;
function TEmulatedCaret.DestroyCaret: Boolean;
begin
FTimer.Enabled := False;
Hide;
if Assigned(FPixmap) then
QPixmap_destroy(FPixmap);
FWidget := nil;
FPixmap := nil;
FWidth := 0;
FHeight := 0;
Result := not IsValid;
end;
procedure TEmulatedCaret.DrawCaret;
var
DestDev: QPaintDeviceH;
Painter: QPainterH;
R: TRect;
begin
if IsValid and FVisible and FVisibleState then
begin
{$IFDEF ShowQtCaret}
DestDev := QWidget_to_QPaintDevice(FWidget.Widget);
Painter := QPainter_create(DestDev);
R := Rect(0, 0, QPixmap_width(FPixmap), QPixmap_height(FPixmap));
QPainter_drawPixmap(Painter, PQtPoint(@FPos), FPixmap, PRect(@R));
QPainter_destroy(Painter);
{$ENDIF}
end;
end;
function TEmulatedCaret.Show(AWidget: TQtWidget): Boolean;
begin
if FWidget <> AWidget then
begin
Hide;
SetWidget(AWidget);
end;
Result := IsValid;
if Result then
FVisible := True;
end;
function TEmulatedCaret.Hide: Boolean;
begin
Result := IsValid;
if Result and FVisible then
FVisible := False;
end;
procedure TEmulatedCaret.SetPos(const Value: TQtPoint);
begin
if FVisible and ((FPos.x <> Value.x) or (FPos.y <> Value.y)) then
begin
Hide;
try
FPos := Value;
finally
Show(FWidget);
end;
end
else
FPos := Value;
end;
procedure TEmulatedCaret.DoTimer(Sender: TObject);
begin
FVisibleState := not FVisibleState;
if FVisible and (FWidget <> nil) and not FWidget.InPaint then
FWidget.Repaint;
end;
procedure TEmulatedCaret.Lock;
begin
EnterCriticalSection(FCritSect);
end;
procedure TEmulatedCaret.Unlock;
begin
LeaveCriticalSection(FCritSect);
end;
function TEmulatedCaret.CreateColorPixmap(Color: Cardinal): QPixmapH;
var
QC: TQColor;
begin
if (FWidth <= 0) or (FHeight <= 0) then
Result := nil
else
begin
case Color of
0: ColorRefToTQColor(clBlack, QC);
1: ColorRefToTQColor(clGray, QC);
else
Result := nil;
Exit;
end;
Result := QPixmap_create(FWidth, FHeight);
try
QPixmap_fill(Result, @QC);
except
QPixmap_destroy(Result);
Result := nil;
end;
end;
end;
function TEmulatedCaret.IsValid: Boolean;
begin
Result := (FWidget <> nil) and (FPixmap <> nil) and
(QWidget_find(FWndId) <> nil);
end;
procedure TEmulatedCaret.SetWidget(AWidget: TQtWidget);
begin
if FWidget <> nil then
FWidget.HasCaret := False;
FWidget := AWidget;
if FWidget <> nil then
begin
FWndId := QWidget_winId(FWidget.Widget);
FWidget.HasCaret := True;
end
else
FWndId := 0;
end;
end.

View File

@ -147,6 +147,7 @@ uses
QtWSSpin,
QtWSStdCtrls,
// QtWSToolwin,
QtCaret,
QtThemes,
////////////////////////////////////////////////////
Graphics, buttons, Menus,

File diff suppressed because it is too large Load Diff

View File

@ -335,6 +335,12 @@ begin
{$endif}
end;
function TQtWidgetSet.CreateCaret(Handle: HWND; Bitmap: hBitmap; Width, Height: Integer): Boolean;
begin
Result := (Handle <> 0) and
QtCaret.CreateCaret(TQtWidget(Handle), Bitmap, Width, Height);
end;
{------------------------------------------------------------------------------
Function: CreateCompatibleDC
Params: DC - handle to memory device context
@ -647,6 +653,11 @@ begin
{$endif}
end;
function TQtWidgetSet.DestroyCaret(Handle: HWND): Boolean;
begin
Result := (Handle <> 0) and QtCaret.DestroyCaret;
end;
{------------------------------------------------------------------------------
Method: DestroyCursor
Params: Handle
@ -951,6 +962,17 @@ begin
// Desc^.LineEnd := rileDWordBoundary;
end;
function TQtWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
begin
Result := QtCaret.GetCaretPos(lpPoint);
end;
function TQtWidgetSet.GetCaretRespondToFocus(handle: HWND; var ShowHideOnFocus: boolean): Boolean;
begin
{$note implement}
Result := False;
end;
{------------------------------------------------------------------------------
Function: GetClientBounds
Params: handle:
@ -2229,6 +2251,11 @@ begin
AdjustForBuddySize;}
end;
function TQtWidgetSet.HideCaret(hWnd: HWND): Boolean;
begin
Result := (hWnd <> 0) and QtCaret.HideCaret(TQtWidget(hWnd));
end;
{------------------------------------------------------------------------------
Procedure: InitializeCriticalSection
Params: var CritSection: TCriticalSection
@ -2670,6 +2697,23 @@ begin
result := TQtDeviceContext(DC).SetBkMode(bkMode);
end;
function TQtWidgetSet.SetCaretPos(X, Y: Integer): Boolean;
begin
Result := QtCaret.SetCaretPos(X, Y);
end;
function TQtWidgetSet.SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean;
begin
Result := QtCaret.SetCaretPos(X, Y);
end;
function TQtWidgetSet.SetCaretRespondToFocus(handle: HWND;
ShowHideOnFocus: boolean): Boolean;
begin
{$note implement}
Result := False;
end;
{------------------------------------------------------------------------------
Function: SetCursor
Params: ACursor - HCursor (QCursorH)
@ -2759,6 +2803,11 @@ begin
Result := True;
end;
function TQtWidgetSet.ShowCaret(hWnd: HWND): Boolean;
begin
Result := (hWnd <> 0) and (QtCaret.ShowCaret(TQtWidget(hWnd)));
end;
{------------------------------------------------------------------------------
Method: SetProp
Params: Handle -

View File

@ -34,6 +34,7 @@ function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint; o
function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean; override;
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
function CreateCaret(Handle : HWND; Bitmap : hBitmap; Width, Height : Integer) : Boolean; override;
function CreateCompatibleDC(DC: HDC): HDC; override;
function CreateCursor(ACursorInfo: PIconInfo): hCursor; override;
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
@ -43,6 +44,7 @@ function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN; override;
procedure DeleteCriticalSection(var CritSection: TCriticalSection); override;
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
function DestroyCaret(Handle : HWND): Boolean; override;
function DestroyCursor(Handle: hCursor): Boolean; override;
function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; override;
@ -57,6 +59,8 @@ function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const St
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
function GetBitmapRawImageDescription(Bitmap: HBITMAP; Desc: PRawImageDescription): Boolean; override;
function GetCaretPos(var lpPoint: TPoint): Boolean; override;
function GetCaretRespondToFocus(handle: HWND; var ShowHideOnFocus: boolean): Boolean; override;
function GetClientBounds(handle : HWND; var ARect : TRect) : Boolean; override;
function GetClientRect(handle : HWND; var ARect : TRect) : Boolean; override;
function GetClipBox(DC : hDC; lpRect : PRect) : Longint; override;
@ -81,6 +85,8 @@ function GetWindowRect(Handle: hwnd; var ARect: TRect): Integer; override;
function GetWindowRelativePosition(Handle: hwnd; var Left, Top: Integer): boolean; override;
function GetWindowSize(Handle: hwnd; var Width, Height: Integer): boolean; override;
function HideCaret(hWnd: HWND): Boolean; override;
function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override;
procedure InitializeCriticalSection(var CritSection: TCriticalSection); override;
@ -99,6 +105,9 @@ function SelectClipRGN(DC : hDC; RGN : HRGN) : Longint; override;
function SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ; override;
function SetBKColor(DC: HDC; Color: TColorRef): TColorRef; override;
function SetBkMode(DC: HDC; bkMode : Integer) : Integer; override;
function SetCaretPos(X, Y: Integer): Boolean; override;
function SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean; override;
function SetCaretRespondToFocus(handle: HWND; ShowHideOnFocus: boolean): Boolean; override;
function SetCursor(ACursor: HCURSOR): HCURSOR; override;
function SetCursorPos(X, Y: Integer): Boolean; override;
function SetFocus(hWnd: HWND): HWND; override;
@ -106,6 +115,7 @@ function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; override;
function SetWindowOrgEx(DC : HDC; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override;
function ShowCaret(hWnd: HWND): Boolean; override;
function ShowWindow(hWnd: HWND; nCmdShow: Integer): Boolean; override;
function StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer;
SrcDC: HDC; XSrc, YSrc, SrcWidth, SrcHeight: Integer; ROp: Cardinal): Boolean; override;

View File

@ -84,24 +84,9 @@ class function TQtWSBitBtn.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
QtPushButton: TQtPushButton;
Method: TMethod;
Hook : QObject_hookH;
begin
QtPushButton := TQtPushButton.Create(AWinControl, AParams);
// Various Events
Hook := QObject_hook_create(QtPushButton.Widget);
TEventFilterMethod(Method) := QtPushButton.EventFilter;
QObject_hook_hook_events(Hook, Method);
// OnClick Event
QAbstractButton_clicked2_Event(Method) := QtPushButton.SlotClicked;
QAbstractButton_hook_hook_clicked2(QAbstractButton_hook_create(QtPushButton.Widget), Method);
QtPushButton.AttachEvents;
// Focus

View File

@ -64,26 +64,11 @@ implementation
class function TQtWSCustomCalendar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
QtCalendar: TQtCalendar;
Hook: QCalendarWidget_hookH;
Method: TMethod;
begin
QtCalendar := TQtCalendar.Create(AWinControl, AParams);
Hook := QCalendarWidget_hook_create(QtCalendar.Widget);
TEventFilterMethod(Method) := QtCalendar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtCalendar.AttachEvents;
QCalendarWidget_clicked_Event(Method) := QtCalendar.SignalClicked;
QCalendarWidget_hook_hook_clicked(QCalendarWidget_hook_create(QtCalendar.Widget), Method);
QCalendarWidget_activated_Event(Method) := QtCalendar.SignalActivated;
QCalendarWidget_hook_hook_activated(QCalendarWidget_hook_create(QtCalendar.Widget), Method);
QCalendarWidget_selectionChanged_Event(Method) := QtCalendar.SignalSelectionChanged;
QCalendarWidget_hook_hook_selectionChanged(QCalendarWidget_hook_create(QtCalendar.Widget), Method);
QCalendarWidget_currentPageChanged_Event(Method) := QtCalendar.SignalCurrentPageChanged;
QCalendarWidget_hook_hook_currentPageChanged(QCalendarWidget_hook_create(QtCalendar.Widget), Method);
QWidget_setFocusPolicy(QtCalendar.Widget, QtTabFocus or QtClickFocus);

View File

@ -254,14 +254,9 @@ implementation
class function TQtWSToolButton.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtToolButton: TQtToolButton;
Hook: QToolButton_hookH;
Method: TMethod;
begin
QtToolButton := TQtToolButton.Create(AWinControl, AParams);
Hook := QToolButton_hook_create(QtToolButton.Widget);
TEventFilterMethod(Method) := QtToolButton.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtToolButton.AttachEvents;
Result := THandle(QtToolButton);
end;
@ -338,14 +333,9 @@ end;
class function TQtWSToolBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtToolBar: TQtToolBar;
Hook: QToolBar_hookH;
Method: TMethod;
begin
QtToolBar := TQtToolBar.Create(AWinControl, AParams);
Hook := QToolBar_hook_create(QtToolBar.Widget);
TEventFilterMethod(Method) := QtToolBar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtToolBar.AttachEvents;
Result := THandle(QtToolBar);
end;
@ -392,29 +382,9 @@ end;
class function TQtWSTrackBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtTrackBar: TQtTrackBar;
Method: TMethod;
Hook : QSlider_hookH;
begin
QtTrackBar := TQtTrackBar.Create(AWinControl, AParams);
Hook := QSlider_hook_create(QtTrackBar.Widget);
TEventFilterMethod(Method) := QtTrackBar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QAbstractSlider_rangeChanged_Event(Method) := QtTrackbar.SlotRangeChanged;
QAbstractSlider_hook_hook_rangeChanged(QAbstractSlider_hook_create(QtTrackBar.Widget), Method);
QAbstractSlider_sliderMoved_Event(Method) := QtTrackBar.SlotSliderMoved;
QAbstractSlider_hook_hook_sliderMoved(QAbstractSlider_hook_create(QtTrackBar.Widget), Method);
QAbstractSlider_sliderPressed_Event(Method) := QtTrackBar.SlotSliderPressed;
QAbstractSlider_hook_hook_sliderPressed(QAbstractSlider_hook_create(QtTrackBar.Widget), Method);
QAbstractSlider_sliderReleased_Event(Method) := QtTrackBar.SlotSliderReleased;
QAbstractSlider_hook_hook_sliderReleased(QAbstractSlider_hook_create(QtTrackBar.Widget), Method);
QAbstractSlider_valueChanged_Event(Method) := QtTrackBar.SlotValueChanged;
QAbstractSlider_hook_hook_valueChanged(QAbstractSlider_hook_create(QtTrackBar.Widget), Method);
QtTrackBar.AttachEvents;
Result := THandle(QtTrackBar);
end;
@ -488,23 +458,9 @@ end;
class function TQtWSProgressBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtProgressBar: TQtProgressBar;
Method: TMethod;
Hook : QProgressBar_hookH;
begin
QtProgressBar := TQtProgressBar.Create(AWinControl, AParams);
// Various Events
Hook := QProgressBar_hook_create(QtProgressBar.Widget);
TEventFilterMethod(Method) := QtProgressBar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QProgressBar_valueChanged_Event(Method) := QtProgressBar.SignalValueChanged;
QProgressBar_hook_hook_valueChanged(QProgressBar_hook_create(QtProgressBar.Widget), Method);
QtProgressBar.AttachEvents;
Result := THandle(QtProgressBar);
end;
@ -573,21 +529,12 @@ end;
class function TQtWSStatusBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtStatusBar: TQtStatusBar;
Method: TMethod;
Hook : QStatusBar_hookH;
Str: WideString;
i: Integer;
R: TRect;
begin
QtStatusBar := TQtStatusBar.Create(AWinControl, AParams);
// Various Events
Hook := QStatusBar_hook_create(QtStatusBar.Widget);
TEventFilterMethod(Method) := QtStatusBar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtStatusBar.AttachEvents;
if TStatusBar(AWinControl).SimplePanel then
begin
@ -802,45 +749,9 @@ end;
class function TQtWSCustomListView.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtTreeWidget: TQtTreeWidget;
Method: TMethod;
Hook : QTreeWidget_hookH;
begin
QtTreeWidget := TQtTreeWidget.Create(AWinControl, AParams);
// Various Events
Hook := QTreeWidget_hook_create(QtTreeWidget.Widget);
TEventFilterMethod(Method) := QtTreeWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
QTreeWidget_currentItemChanged_Event(Method) := QtTreeWidget.SignalCurrentItemChanged;
QTreeWidget_hook_hook_currentItemChanged(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemDoubleClicked_Event(Method) := QtTreeWidget.SignalItemDoubleClicked;
QTreeWidget_hook_hook_ItemDoubleClicked(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemClicked_Event(Method) := QtTreeWidget.SignalItemClicked;
QTreeWidget_hook_hook_ItemClicked(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemActivated_Event(Method) := QtTreeWidget.SignalItemActivated;
QTreeWidget_hook_hook_ItemActivated(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemChanged_Event(Method) := QtTreeWidget.SignalItemChanged;
QTreeWidget_hook_hook_ItemChanged(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemSelectionChanged_Event(Method) := QtTreeWidget.SignalItemSelectionChanged;
QTreeWidget_hook_hook_ItemSelectionChanged(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemPressed_Event(Method) := QtTreeWidget.SignalItemPressed;
QTreeWidget_hook_hook_ItemPressed(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QTreeWidget_itemEntered_Event(Method) := QtTreeWidget.SignalItemEntered;
QTreeWidget_hook_hook_ItemEntered(QTreeWidget_hook_create(QtTreeWidget.Widget), Method);
QtTreeWidget.AttachEvents;
Result := THandle(QtTreeWidget);
end;

View File

@ -131,21 +131,13 @@ class function TQtWSCustomControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtAbstractScrollArea: TQtAbstractScrollArea;
Method: TMethod;
Hook: QObject_hookH;
begin
{$ifdef VerboseQt}
WriteLn('> TQtWSCustomControl.CreateHandle for ',dbgsname(AWinControl));
{$endif}
QtAbstractScrollArea := TQtAbstractScrollArea.Create(AWinControl, AParams);
Hook := QAbstractScrollArea_hook_create(QtAbstractScrollArea.Widget);
TEventFilterMethod(Method) := QtAbstractScrollArea.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtAbstractScrollArea.AttachEvents;
Result := THandle(QtAbstractScrollArea);
{$ifdef VerboseQt}
@ -184,36 +176,41 @@ end;
Shows or hides a widget.
------------------------------------------------------------------------------}
class procedure TQtWSCustomControl.ShowHide(const AWinControl: TWinControl);
var
Widget: TQtWidget;
begin
{$ifdef VerboseQt}
WriteLn('Trace:> [TQtWSCustomControl.ShowHide]');
{$endif}
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if (AWinControl = nil) or not AWinControl.HandleAllocated then
exit;
Widget := TQtWidget(AWinControl.Handle);
{ if the widget is a form, this is a place to set the Tab order }
if (AWinControl is TForm) and AWinControl.HandleObjectShouldBeVisible then
TQtMainWindow(AWinControl.Handle).SetTabOrders;
if AWinControl.HandleObjectShouldBeVisible and (Widget is TQtMainWindow) then
TQtMainWindow(Widget).SetTabOrders;
if AWinControl.HandleObjectShouldBeVisible then
QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, True)
else QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, False);
QWidget_setVisible(Widget.Widget, True)
else
QWidget_setVisible(Widget.Widget, False);
{$ifdef VerboseQt}
Write('Trace:< [TQtWSCustomControl.ShowHide] ');
if AWinControl is TForm then Write('Is TForm, ');
if AWinControl is TForm then
Write('Is TForm, ');
if AWinControl.HandleObjectShouldBeVisible then WriteLn('Visible: True')
else WriteLn('Visible: False');
if AWinControl.HandleObjectShouldBeVisible then
WriteLn('Visible: True')
else
WriteLn('Visible: False');
{$endif}
// showhide fires before invalidate, so we must create viewport right here
if not AWinControl.InheritsFrom(TCustomForm)
then
TQtAbstractScrollArea(AWinControl.Handle).viewportNeeded;
if Widget is TQtAbstractScrollArea then
TQtAbstractScrollArea(Widget).viewportNeeded;
end;
{------------------------------------------------------------------------------
@ -234,10 +231,10 @@ begin
else
FocusWidget := QWidget_focusWidget(Widget.Widget);
Result := (FocusWidget <> nil)
and QWidget_isEnabled(FocusWidget)
and QWidget_isVisible(FocusWidget)
and (QWidget_focusPolicy(FocusWidget) <> QtNoFocus);
Result := (FocusWidget <> nil) and
QWidget_isEnabled(FocusWidget) and
QWidget_isVisible(FocusWidget) and
(QWidget_focusPolicy(FocusWidget) <> QtNoFocus);
end else
Result := False;
end;
@ -251,21 +248,13 @@ class function TQtWSWinControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtWidget: TQtWidget;
Method: TMethod;
Hook : QObject_hookH;
begin
{$ifdef VerboseQt}
WriteLn('> TQtWSWinControl.CreateHandle for ',dbgsname(AWinControl));
{$endif}
QtWidget := TQtWidget.Create(AWinControl, AParams);
// Various Events
Hook := QObject_hook_create(QtWidget.Widget);
TEventFilterMethod(Method) := QtWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtWidget.AttachEvents;
// Finalization
@ -351,30 +340,36 @@ end;
Shows or hides a widget.
------------------------------------------------------------------------------}
class procedure TQtWSWinControl.ShowHide(const AWinControl: TWinControl);
var
Widget: TQtWidget;
begin
{$ifdef VerboseQt}
WriteLn('Trace:> [TQtWSWinControl.ShowHide]');
{$endif}
if AWinControl = nil then exit;
if not AWinControl.HandleAllocated then exit;
if (AWinControl = nil) or not AWinControl.HandleAllocated then
exit;
Widget := TQtWidget(AWinControl.Handle);
{ if the widget is a form, this is a place to set the Tab order }
if (AWinControl is TForm) and AWinControl.HandleObjectShouldBeVisible then
TQtMainWindow(AWinControl.Handle).SetTabOrders;
if AWinControl.HandleObjectShouldBeVisible and (Widget is TQtMainWindow) then
TQtMainWindow(Widget).SetTabOrders;
if AWinControl.HandleObjectShouldBeVisible then
QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, True)
else QWidget_setVisible(TQtWidget(AWinControl.Handle).Widget, False);
QWidget_setVisible(Widget.Widget, True)
else
QWidget_setVisible(Widget.Widget, False);
{$ifdef VerboseQt}
Write('Trace:< [TQtWSWinControl.ShowHide] ');
if AWinControl is TForm then Write('Is TForm, ');
if AWinControl is TForm then
Write('Is TForm, ');
if AWinControl.HandleObjectShouldBeVisible then WriteLn('Visible: True')
else WriteLn('Visible: False');
if AWinControl.HandleObjectShouldBeVisible then
WriteLn('Visible: True')
else
WriteLn('Visible: False');
{$endif}
end;

View File

@ -253,18 +253,9 @@ class function TQtWSCustomPanel.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtFrame: TQtFrame;
Method: TMethod;
Hook : QObject_hookH;
begin
QtFrame := TQtFrame.Create(AWinControl, AParams);
// Various Events
Hook := QObject_hook_create(QtFrame.Widget);
TEventFilterMethod(Method) := QtFrame.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtFrame.AttachEvents;
// Set´s initial properties
@ -304,25 +295,15 @@ class function TQtWSCustomPage.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtWidget: TQtWidget;
Method: TMethod;
Hook : QTabBar_hookH;
begin
{$ifdef VerboseQt}
WriteLn('Trace:> [TQtWSCustomPage.CreateHandle]');
{$endif}
QtWidget := TQtWidget.CreatePage(AWinControl, AParams);
// Various Events
Hook := QTabBar_hook_create(QtWidget.Widget);
TEventFilterMethod(Method) := QtWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtWidget.AttachEvents;
// Returns the Handle
Result := THandle(QtWidget);
{$ifdef VerboseQt}
@ -373,8 +354,6 @@ end;
class function TQtWSCustomNotebook.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtTabWidget: TQtTabWidget;
Method: TMethod;
Hook : QTabWidget_hookH;
begin
{$ifdef VerboseQt}
WriteLn('TQtWSCustomNotebook.CreateHandle');
@ -382,18 +361,7 @@ begin
QtTabWidget := TQtTabWidget.Create(AWinControl, AParams);
QtTabWidget.SetTabPosition(QTabWidgetTabPositionMap[TCustomNoteBook(AWinControl).TabPosition]);
// Various Events
Hook := QTabWidget_hook_create(QtTabWidget.Widget);
TEventFilterMethod(Method) := QtTabWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
QTabWidget_currentChanged_Event(Method) := QtTabWidget.SignalCurrentChanged;
QTabWidget_hook_hook_currentChanged(QTabWidget_hook_create(QtTabWidget.Widget), Method);
QtTabWidget.AttachEvents;
// Returns the Handle
@ -454,8 +422,6 @@ class function TQtWSCustomRadioGroup.CreateHandle(const AWinControl: TWinControl
var
QtGroupBox: TQtGroupBox;
Str: WideString;
Method: TMethod;
Hook : QGroupBox_hookH;
i: Integer;
begin
@ -483,9 +449,7 @@ begin
QGridLayout_setRowStretch(QtGroupBox.BoxLayout, i, 0);
end;
Hook := QGroupBox_hook_create(QtGroupBox.Widget);
TEventFilterMethod(Method) := QtGroupBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtGroupBox.AttachEvents;
Result := THandle(QtGroupBox);
end;
@ -560,8 +524,6 @@ class function TQtWSCustomCheckGroup.CreateHandle(const AWinControl: TWinControl
var
QtGroupBox: TQtGroupBox;
Str: WideString;
Method: TMethod;
Hook : QGroupBox_hookH;
i: Integer;
begin
@ -588,9 +550,7 @@ begin
QGridLayout_setRowStretch(QtGroupBox.BoxLayout, i, 0);
end;
Hook := QGroupBox_hook_create(QtGroupBox.Widget);
TEventFilterMethod(Method) := QtGroupBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtGroupBox.AttachEvents;
Result := THandle(QtGroupBox);
end;

View File

@ -144,8 +144,6 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
var
QtMainWindow: TQtMainWindow;
Str: WideString;
Method: TMethod;
Hook : QObject_hookH;
begin
{$ifdef VerboseQt}
WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height),
@ -174,15 +172,9 @@ begin
SetQtBorderIcons(QtMainWindow, TCustomForm(AWinControl).BorderIcons);
// Sets Various Events
Hook := QObject_hook_create(QtMainWindow.Widget);
TEventFilterMethod(Method) := QtMainWindow.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtMainWindow.AttachEvents;
// Return the handle
Result := THandle(QtMainWindow);
end;

View File

@ -113,8 +113,6 @@ var
ParentMenu, Menu: TQtMenu;
MenuBar: TQtMenuBar;
Text: WideString;
Method: TMethod;
Hook: QObject_hookH;
begin
{$ifdef VerboseQt}
WriteLn('trace:> [TQtWSMenuItem.CreateHandle] Caption: ', AMenuItem.Caption,
@ -223,19 +221,7 @@ begin
end;
if Menu <> nil then
begin
// Trigger event
QAction_triggered_Event(Method) := Menu.SlotTriggered;
QAction_hook_hook_triggered(QAction_hook_create(Menu.ActionHandle), Method);
Hook := QObject_hook_create(Menu.Widget);
TEventFilterMethod(Method) := Menu.EventFilter;
QObject_hook_hook_events(Hook, Method);
end;
Menu.AttachEvents;
{$ifdef VerboseQt}
WriteLn(' Result: ', dbghex(Result));
@ -387,6 +373,8 @@ begin
Parent := TQtMainWindow(TCustomForm(AMenu.Owner).Handle).Widget;
Menu := TQtMenu.Create(Parent);
Menu.MenuItem := AMenu.Items;
Menu.AttachEvents;
Result := HMENU(Menu);
end;

View File

@ -95,8 +95,6 @@ class function TQtWSCustomFloatSpinEdit.CreateHandle(const AWinControl: TWinCont
var
QtSpinBox: TQtSpinBox;
QtFloatSpinBox: TQtFloatSpinBox;
Hook: QAbstractSpinBox_hookH;
Method: TMethod;
FIsFloat: Boolean;
begin
@ -105,41 +103,17 @@ begin
FIsFloat := TCustomFloatSpinEdit(AWinControl).DecimalPlaces > 0;
if FIsFloat then
QtFloatSpinBox := TQtFloatSpinBox.Create(AWinControl, AParams)
begin
QtFloatSpinBox := TQtFloatSpinBox.Create(AWinControl, AParams);
QtFloatSpinBox.AttachEvents;
Result := THandle(QtFloatSpinBox);
end
else
begin
QtSpinBox := TQtSpinBox.Create(AWinControl, AParams);
if FIsFloat then
begin
Hook := QAbstractSpinBox_hook_create(QtFloatSpinBox.Widget);
TEventFilterMethod(Method) := QtFloatSpinBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
{TODO: find out which TLMessage should be sended }
QAbstractSpinBox_editingFinished_Event(Method) := QtFloatSpinBox.SignalEditingFinished;
QAbstractSpinBox_hook_hook_editingFinished(QAbstractSpinBox_hook_create(QtFloatSpinBox.Widget), Method);
QDoubleSpinBox_valueChanged_Event(Method) := QtFloatSpinBox.SignalValueChanged;
QDoubleSpinBox_hook_hook_valueChanged(QDoubleSpinBox_hook_create(QtFloatSpinBox.Widget), Method);
end else
begin
Hook := QAbstractSpinBox_hook_create(QtSpinBox.Widget);
TEventFilterMethod(Method) := QtSpinBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
{TODO: find out which TLMessage should be sended }
QAbstractSpinBox_editingFinished_Event(Method) := QtSpinBox.SignalEditingFinished;
QAbstractSpinBox_hook_hook_editingFinished(QAbstractSpinBox_hook_create(QtSpinBox.Widget), Method);
QSpinBox_valueChanged_Event(Method) := QtSpinBox.SignalValueChanged;
QSpinBox_hook_hook_valueChanged(QSpinBox_hook_create(QtSpinBox.Widget), Method);
QtSpinBox.AttachEvents;
Result := THandle(QtSpinBox);
end;
if FIsFloat then Result := THandle(QtFloatSpinBox)
else Result := THandle(QtSpinBox);
end;
{------------------------------------------------------------------------------

View File

@ -337,10 +337,7 @@ uses LMessages;
class function TQtWSScrollBar.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtScrollBar: TQtScrollBar;
Method: TMethod;
Hook : QScrollBar_hookH;
begin
QtScrollBar := TQtScrollBar.Create(AWinControl, AParams);
case TScrollBar(AWinControl).Kind of
@ -364,26 +361,7 @@ begin
QtScrollBar.setRange(TScrollBar(AWinControl).Min, TScrollBar(AWinControl).Max);
QtScrollbar.setValue(TScrollBar(AWinControl).Position);
QtScrollBar.setPageStep(TScrollBar(AWinControl).PageSize);
// Various Events
Hook := QScrollBar_hook_create(QtScrollBar.Widget);
TEventFilterMethod(Method) := QtScrollBar.EventFilter;
QObject_hook_hook_events(Hook, Method);
QAbstractSlider_rangeChanged_Event(Method) := QtScrollBar.SlotRangeChanged;
QAbstractSlider_hook_hook_rangeChanged(QAbstractSlider_hook_create(QtScrollBar.Widget), Method);
QAbstractSlider_sliderMoved_Event(Method) := QtScrollBar.SlotSliderMoved;
QAbstractSlider_hook_hook_sliderMoved(QAbstractSlider_hook_create(QtScrollBar.Widget), Method);
QAbstractSlider_sliderPressed_Event(Method) := QtScrollBar.SlotSliderPressed;
QAbstractSlider_hook_hook_sliderPressed(QAbstractSlider_hook_create(QtScrollBar.Widget), Method);
QAbstractSlider_sliderReleased_Event(Method) := QtScrollBar.SlotSliderReleased;
QAbstractSlider_hook_hook_sliderReleased(QAbstractSlider_hook_create(QtScrollBar.Widget), Method);
QAbstractSlider_valueChanged_Event(Method) := QtScrollBar.SlotValueChanged;
QAbstractSlider_hook_hook_valueChanged(QAbstractSlider_hook_create(QtScrollBar.Widget), Method);
QtScrollBar.AttachEvents;
Result := THandle(QtScrollbar);
end;
@ -453,28 +431,10 @@ end;
class function TQtWSCustomListBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND;
var
QtListWidget: TQtListWidget;
Method: TMethod;
Hook : QListWidget_hookH;
begin
QtListWidget := TQtListWidGet.Create(AWinControl, AParams);
// Various Events
Hook := QListWidget_hook_create(QtListWidget.Widget);
TEventFilterMethod(Method) := QtListWidget.EventFilter;
QObject_hook_hook_events(Hook, Method);
// OnSelectionChange event
QListWidget_currentItemChanged_Event(Method) := QtListWidget.SlotSelectionChange;
QListWidget_hook_hook_currentItemChanged(QListWidget_hook_create(QtListWidget.Widget), Method);
QListWidget_itemDoubleClicked_Event(Method) := QtListWidget.SignalItemDoubleClicked;
QListWidget_hook_hook_ItemDoubleClicked(QListWidget_hook_create(QtListWidget.Widget), Method);
QListWidget_itemClicked_Event(Method) := QtListWidget.SignalItemClicked;
QListWidget_hook_hook_ItemClicked(QListWidget_hook_create(QtListWidget.Widget), Method);
QtListWidget.AttachEvents;
// QListWidget_itemClicked_Event(Method;
@ -628,21 +588,9 @@ class function TQtWSCustomMemo.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtTextEdit: TQtTextEdit;
Method: TMethod;
Hook : QTextEdit_hookH;
begin
QtTextEdit := TQtTextEdit.Create(AWinControl, AParams);
Hook := QTextEdit_hook_create(QtTextEdit.Widget);
TEventFilterMethod(Method) := QtTextEdit.EventFilter;
QObject_hook_hook_events(Hook, Method);
{TODO: BUG CopyUnicodeToPWideString() segfaults while calling SetLength()
workaround: add try..except around SetLength() }
QTextEdit_textChanged_Event(Method) := QtTextEdit.SignalTextChanged;
QTextEdit_hook_hook_textChanged(QTextEdit_hook_create(QtTextEdit.Widget), Method);
QtTextEdit.AttachEvents;
Result := THandle(QtTextEdit);
end;
@ -767,21 +715,9 @@ class function TQtWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
QtLineEdit: TQtLineEdit;
Method: TMethod;
Hook : QLineEdit_hookH;
begin
QtLineEdit := TQtLineEdit.Create(AWinControl, AParams);
Hook := QLineEdit_hook_create(QtLineEdit.Widget);
TEventFilterMethod(Method) := QtLineEdit.EventFilter;
QObject_hook_hook_events(Hook, Method);
{TODO: BUG CopyUnicodeToPWideString() segfaults while calling SetLength()
workaround: add try..except around SetLength() }
QLineEdit_textChanged_Event(Method) := QtLineEdit.SignalTextChanged;
QLineEdit_hook_hook_textChanged(QLineEdit_hook_create(QtLineEdit.Widget), Method);
QtLineEdit.AttachEvents;
Result := THandle(QtLineEdit);
end;
@ -972,31 +908,14 @@ class function TQtWSButton.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
QtPushButton: TQtPushButton;
Method: TMethod;
Hook : QObject_hookH;
begin
QtPushButton := TQtPushButton.Create(AWinControl, AParams);
// Various Events
Hook := QObject_hook_create(QtPushButton.Widget);
TEventFilterMethod(Method) := QtPushButton.EventFilter;
QObject_hook_hook_events(Hook, Method);
// OnClick Event
QAbstractButton_clicked2_Event(Method) := QtPushButton.SlotClicked;
QAbstractButton_hook_hook_clicked2(QAbstractButton_hook_create(QtPushButton.Widget), Method);
QtPushButton.AttachEvents;
// Focus
QWidget_setFocusPolicy(QtPushButton.Widget, QtStrongFocus);
// Returns the Handle
Result := THandle(QtPushButton);
end;
@ -1160,29 +1079,18 @@ end;
class function TQtWSCustomCheckBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
QtCheckBox: TQtCheckBox;
Method: TMethod;
Hook : QAbstractButton_hookH;
ATextWidth: Integer;
FM: QFontMetricsH;
Str: WideString;
begin
QtCheckBox := TQtCheckBox.Create(AWinControl, AParams);
QtCheckBox.AttachEvents;
// Focus
// QWidget_setFocusPolicy(QtCheckBox.Widget, QtStrongFocus);
{we have a bug in LCL when parent is TCustomCheckGroup, it doesn't set sizes for items ?!? Width = 0 , Height = 0}
// writeln('WW=',QWidget_width(QtCheckBox.Widget),' WH=',QWidget_height(QtCheckBox.Widget),' WCW=',AWinControl.Width,' WCH=',AWinControl.Height,' CAPTION=',TCustomCheckBox(AWinControl).Caption);
Hook := QCheckBox_hook_create(QtCheckBox.Widget);
TEventFilterMethod(Method) := QtCheckBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
QCheckBox_stateChanged_Event(Method) := QtCheckBox.SignalStateChanged;
QCheckBox_hook_hook_stateChanged(QCheckBox_hook_create(QtCheckBox.Widget), Method);
{we must cheat TCustomCheckGroup here with some reasonable CheckBox size...}
if AWinControl.Height = 0 then
begin
@ -1301,22 +1209,12 @@ class function TQtWSRadioButton.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
QtRadioButton: TQtRadioButton;
Method: TMethod;
Hook : QAbstractButton_hookH;
ATextWidth: Integer;
FM: QFontMetricsH;
Str: WideString;
begin
QtRadioButton := TQtRadioButton.Create(AWinControl, AParams);
// Various Events
Hook := QAbstractButton_hook_create(QtRadioButton.Widget);
TEventFilterMethod(Method) := QtRadioButton.EventFilter;
QObject_hook_hook_events(Hook, Method);
QtRadioButton.AttachEvents;
{we must cheat TCustomRadioGroup here with some reasonable RadioButton size...}
if AWinControl.Height = 0 then
@ -1336,9 +1234,6 @@ begin
AWinControl.SetInitialBounds(0, 0, ATextWidth + 22, 22);
end;
QAbstractButton_clicked_Event(Method) := QtRadioButton.SignalClicked;
QAbstractButton_hook_hook_clicked(QAbstractButton_hook_create(QtRadioButton.Widget), Method);
// Focus
//QWidget_setFocusPolicy(QtRadioButton.Widget, QtStrongFocus);
@ -1376,19 +1271,14 @@ class function TQtWSCustomGroupBox.CreateHandle(const AWinControl: TWinControl;
var
QtGroupBox: TQtGroupBox;
Str: WideString;
Method: TMethod;
Hook : QGroupBox_hookH;
begin
QtGroupBox := TQtGroupBox.Create(AWinControl, AParams);
QtGroupBox.AttachEvents;
// If SetSlots is uncommented, then TRadioGroup stops working
// This needs further investigation --> Problem is with child controls sizes (zeljko@holobit.net)
// SetSlots(QtButtonGroup);
Hook := QGroupBox_hook_create(QtGroupBox.Widget);
TEventFilterMethod(Method) := QtGroupBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
Str := UTF8Decode(AWinControl.Caption);
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
@ -1427,32 +1317,9 @@ class function TQtWSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
QtComboBox: TQtComboBox;
Method: TMethod;
Hook : QObject_hookH;
begin
QtComboBox := TQtComboBox.Create(AWinControl, AParams);
// Various Events
Hook := QObject_hook_create(QtComboBox.Widget);
TEventFilterMethod(Method) := QtComboBox.EventFilter;
QObject_hook_hook_events(Hook, Method);
// OnChange event
QComboBox_editTextChanged_Event(Method) := QtComboBox.SlotChange;
QComboBox_hook_hook_editTextChanged(
QComboBox_hook_create(QtComboBox.Widget), Method);
// OnSelect event
QComboBox_currentIndexChanged_Event(Method) := QtComboBox.SlotSelect;
QComboBox_hook_hook_currentIndexChanged(
QComboBox_hook_create(QtComboBox.Widget), Method);
QtComboBox.AttachEvents;
Result := THandle(QtComboBox);
end;