mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 18:49:19 +02:00
(Qt): TQtTimer moved to qtobjects since it is not TQtWidget descendant
git-svn-id: trunk@11663 -
This commit is contained in:
parent
657ad02c41
commit
669a0e96f9
@ -353,6 +353,20 @@ type
|
|||||||
FormatCount: integer; Formats: PClipboardFormat): boolean;
|
FormatCount: integer; Formats: PClipboardFormat): boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TQtTimer }
|
||||||
|
|
||||||
|
TQtTimer = class(TQtObject)
|
||||||
|
private
|
||||||
|
FCallbackFunc: TFNTimerProc;
|
||||||
|
FId: Integer;
|
||||||
|
FAppObject: QObjectH;
|
||||||
|
public
|
||||||
|
constructor CreateTimer(Interval: integer; const TimerFunc: TFNTimerProc; App: QObjectH); virtual;
|
||||||
|
destructor Destroy; override;
|
||||||
|
public
|
||||||
|
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef);
|
procedure TQColorToColorRef(const AColor: TQColor; out AColorRef: TColorRef);
|
||||||
procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor);
|
procedure ColorRefToTQColor(const AColorRef: TColorRef; var AColor:TQColor);
|
||||||
procedure DebugRegion(const msg: string; Rgn: QRegionH);
|
procedure DebugRegion(const msg: string; Rgn: QRegionH);
|
||||||
@ -2021,5 +2035,69 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TQtTimer }
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtTimer.CreateTimer
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
constructor TQtTimer.CreateTimer(Interval: integer;
|
||||||
|
const TimerFunc: TFNTimerProc; App: QObjectH);
|
||||||
|
begin
|
||||||
|
FAppObject := App;
|
||||||
|
|
||||||
|
FCallbackFunc := TimerFunc;
|
||||||
|
|
||||||
|
TheObject := QTimer_create(App);
|
||||||
|
|
||||||
|
QTimer_setInterval(QTimerH(TheObject), Interval);
|
||||||
|
|
||||||
|
AttachEvents;
|
||||||
|
|
||||||
|
// start timer and get ID
|
||||||
|
QTimer_start(QTimerH(TheObject), Interval);
|
||||||
|
FId := QTimer_timerId(QTimerH(TheObject));
|
||||||
|
|
||||||
|
{$ifdef VerboseQt}
|
||||||
|
WriteLn('TQtTimer.CreateTimer: Interval = ', Interval, ' ID = ', FId);
|
||||||
|
{$endif}
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtTimer.Destroy
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
destructor TQtTimer.Destroy;
|
||||||
|
begin
|
||||||
|
{$ifdef VerboseQt}
|
||||||
|
WriteLn('TQtTimer.CreateTimer: Destroy. ID = ', FId);
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
FCallbackFunc := nil;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtTimer.EventFilter
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function TQtTimer.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
if QEvent_type(Event) = QEventTimer then
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
QEvent_accept(Event);
|
||||||
|
|
||||||
|
if Assigned(FCallbackFunc) then
|
||||||
|
FCallbackFunc;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -238,20 +238,6 @@ type
|
|||||||
procedure Text(retval: PWideString);
|
procedure Text(retval: PWideString);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtTimer }
|
|
||||||
|
|
||||||
TQtTimer = class(TQtObject)
|
|
||||||
private
|
|
||||||
FCallbackFunc: TFNTimerProc;
|
|
||||||
FId: Integer;
|
|
||||||
FAppObject: QObjectH;
|
|
||||||
public
|
|
||||||
constructor CreateTimer(Interval: integer; const TimerFunc: TFNTimerProc; App: QObjectH); virtual;
|
|
||||||
destructor Destroy; override;
|
|
||||||
public
|
|
||||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TQtCheckBox }
|
{ TQtCheckBox }
|
||||||
|
|
||||||
TQtCheckBox = class(TQtAbstractButton)
|
TQtCheckBox = class(TQtAbstractButton)
|
||||||
@ -2782,70 +2768,6 @@ begin
|
|||||||
QLabel_text(QLabelH(Widget), retval);
|
QLabel_text(QLabelH(Widget), retval);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtTimer }
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: TQtTimer.CreateTimer
|
|
||||||
Params: None
|
|
||||||
Returns: Nothing
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
constructor TQtTimer.CreateTimer(Interval: integer;
|
|
||||||
const TimerFunc: TFNTimerProc; App: QObjectH);
|
|
||||||
begin
|
|
||||||
FAppObject := App;
|
|
||||||
|
|
||||||
FCallbackFunc := TimerFunc;
|
|
||||||
|
|
||||||
TheObject := QTimer_create(App);
|
|
||||||
|
|
||||||
QTimer_setInterval(QTimerH(TheObject), Interval);
|
|
||||||
|
|
||||||
AttachEvents;
|
|
||||||
|
|
||||||
// start timer and get ID
|
|
||||||
QTimer_start(QTimerH(TheObject), Interval);
|
|
||||||
FId := QTimer_timerId(QTimerH(TheObject));
|
|
||||||
|
|
||||||
{$ifdef VerboseQt}
|
|
||||||
WriteLn('TQtTimer.CreateTimer: Interval = ', Interval, ' ID = ', FId);
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: TQtTimer.Destroy
|
|
||||||
Params: None
|
|
||||||
Returns: Nothing
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
destructor TQtTimer.Destroy;
|
|
||||||
begin
|
|
||||||
{$ifdef VerboseQt}
|
|
||||||
WriteLn('TQtTimer.CreateTimer: Destroy. ID = ', FId);
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
FCallbackFunc := nil;
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: TQtTimer.EventFilter
|
|
||||||
Params: None
|
|
||||||
Returns: Nothing
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function TQtTimer.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
|
||||||
begin
|
|
||||||
Result := False;
|
|
||||||
|
|
||||||
if QEvent_type(Event) = QEventTimer then
|
|
||||||
begin
|
|
||||||
Result := True;
|
|
||||||
|
|
||||||
QEvent_accept(Event);
|
|
||||||
|
|
||||||
if Assigned(FCallbackFunc) then
|
|
||||||
FCallbackFunc;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TQtCheckBox }
|
{ TQtCheckBox }
|
||||||
|
|
||||||
function TQtCheckBox.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
function TQtCheckBox.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||||
|
Loading…
Reference in New Issue
Block a user