mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:14:06 +02:00
MG: implemented TIdleTimer and fixed small bugs
git-svn-id: trunk@3184 -
This commit is contained in:
parent
dadb8e496c
commit
9409ca9778
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -332,6 +332,7 @@ images/components/tibdatabase.ico -text svneol=native#image/x-icon
|
||||
images/components/tibdatabase.xpm -text svneol=native#image/x-xpixmap
|
||||
images/components/tibquery.ico -text svneol=native#image/x-icon
|
||||
images/components/tibquery.xpm -text svneol=native#image/x-xpixmap
|
||||
images/components/tidletimer.xpm -text svneol=native#image/x-xpixmap
|
||||
images/components/timage.ico -text svneol=unset#image/x-icon
|
||||
images/components/timage.xpm -text svneol=native#image/x-xpixmap
|
||||
images/components/timagelist.xpm -text svneol=native#image/x-xpixmap
|
||||
@ -602,6 +603,7 @@ lcl/include/graphiccontrol.inc svneol=native#text/pascal
|
||||
lcl/include/graphicsobject.inc svneol=native#text/pascal
|
||||
lcl/include/hintwindow.inc svneol=native#text/pascal
|
||||
lcl/include/hkeys.inc svneol=native#text/pascal
|
||||
lcl/include/idletimer.inc svneol=native#text/pascal
|
||||
lcl/include/image.inc svneol=native#text/pascal
|
||||
lcl/include/imglist.inc svneol=native#text/pascal
|
||||
lcl/include/inputdialog.inc svneol=native#text/pascal
|
||||
|
26
images/components/tidletimer.xpm
Normal file
26
images/components/tidletimer.xpm
Normal file
@ -0,0 +1,26 @@
|
||||
/* XPM */
|
||||
static char * tidletimer_xpm[] = {
|
||||
"19 19 4 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #AD9226",
|
||||
"@ c #1100D6",
|
||||
" ..... ",
|
||||
" ..+++++.. ",
|
||||
" .++@@@@@++. ",
|
||||
" .+@@@@+@@@@+. ",
|
||||
" .+@@+@@+.@+@@+. ",
|
||||
" .+@@@@@@+.@@@@@+. ",
|
||||
" .+@+@@@@+.@@@+@+. ",
|
||||
".+@@@@@@@+.@@@@@@+.",
|
||||
".+@@@@@@@+.@@@@@@+.",
|
||||
".+@+@@@@@++++@@+@+.",
|
||||
".+@@@@@@@@....@@@+.",
|
||||
".+@@@@@@@@@@@@@@@+.",
|
||||
" .+@+@@@@@@@@@+@+. ",
|
||||
" .+@@@@@@@@@@@@@+. ",
|
||||
" .+@@+@@@@@+@@+. ",
|
||||
" .+@@@@+@@@@+. ",
|
||||
" .++@@@@@++. ",
|
||||
" ..+++++.. ",
|
||||
" ..... "};
|
@ -45,7 +45,7 @@ interface
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
SysUtils, Classes, LCLProc, Controls, StdCtrls, vclGlobals, lMessages,
|
||||
SysUtils, Classes, LCLProc, Controls, Forms, StdCtrls, vclGlobals, lMessages,
|
||||
GraphType, Graphics, LCLLinux, CustomTimer;
|
||||
|
||||
type
|
||||
@ -55,11 +55,8 @@ type
|
||||
{ TTabPosition - Move to TTabbedNotebook when it is created }
|
||||
TTabPosition = (tpTop, tpBottom, tpLeft, tpRight);
|
||||
|
||||
|
||||
{ TPage }
|
||||
{
|
||||
@abstract(Pages for Notebooks and TabbedNotebooks.)
|
||||
Introduced and (currently) maintained by Curtis White
|
||||
}
|
||||
|
||||
TPageFlag = (pfAdded);
|
||||
TPageFlags = set of TPageFlag;
|
||||
@ -94,11 +91,9 @@ type
|
||||
|
||||
TCustomNotebook = class;
|
||||
|
||||
|
||||
{ TNBPages }
|
||||
{
|
||||
@abstract(Notebook page access class to provide access to notebook pages.)
|
||||
Introduced and (currently) maintained by Curtis White
|
||||
}
|
||||
|
||||
TNBPages = class(TStrings)
|
||||
private
|
||||
fPageList: TList;
|
||||
@ -119,11 +114,9 @@ type
|
||||
procedure Move(CurIndex, NewIndex: Integer); override;
|
||||
end;
|
||||
|
||||
|
||||
{ TCustomNotebook }
|
||||
{
|
||||
@abstract(Base class for TNotebook and TTabbedNotebook.)
|
||||
Introduced by Curtis White
|
||||
}
|
||||
|
||||
TNoteBookOption = (nboShowCloseButtons, nboMultiLine);
|
||||
TNoteBookOptions = set of TNoteBookOption;
|
||||
|
||||
@ -189,11 +182,9 @@ type
|
||||
property Options: TNoteBookOptions read FOptions write SetOptions;
|
||||
end;
|
||||
|
||||
|
||||
{ TNotebook }
|
||||
{
|
||||
@abstract(A Delphi style TNotebook.)
|
||||
Introduced and (currently) maintained by Curtis White
|
||||
}
|
||||
|
||||
TNotebook = class(TCustomNotebook)
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -211,14 +202,48 @@ type
|
||||
|
||||
|
||||
{ Timer }
|
||||
{
|
||||
@abstract(A free running timer.)
|
||||
Introduced and (currently) maintained by Stefan Hille (stoppok@osibisa.ms.sub.org)
|
||||
}
|
||||
|
||||
TTimer = class (TCustomTimer)
|
||||
end;
|
||||
|
||||
|
||||
{ TIdleTimer }
|
||||
|
||||
TIdleTimerAutoEvent = (
|
||||
itaOnIdle,
|
||||
itaOnIdleEnd,
|
||||
itaOnUserInput
|
||||
);
|
||||
TIdleTimerAutoEvents = set of TIdleTimerAutoEvent;
|
||||
|
||||
TIdleTimer = class(TTimer)
|
||||
private
|
||||
FAutoEnabled: boolean;
|
||||
FAutoEndEvent: TIdleTimerAutoEvent;
|
||||
FAutoStartEvent: TIdleTimerAutoEvent;
|
||||
FHandlersConnected: boolean;
|
||||
procedure UpdateHandlers;
|
||||
procedure SetAutoEndEvent(const AValue: TIdleTimerAutoEvent);
|
||||
procedure SetAutoStartEvent(const AValue: TIdleTimerAutoEvent);
|
||||
protected
|
||||
procedure SetAutoEnabled(const AValue: boolean); virtual;
|
||||
procedure DoOnIdle(Sender: TObject); virtual;
|
||||
procedure DoOnIdleEnd(Sender: TObject); virtual;
|
||||
procedure DoOnUserInput(Sender: TObject); virtual;
|
||||
procedure Loaded; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
property AutoEnabled: boolean read FAutoEnabled write SetAutoEnabled;
|
||||
property AutoEndEvent: TIdleTimerAutoEvent
|
||||
read FAutoEndEvent write SetAutoEndEvent default itaOnIdle;
|
||||
property AutoStartEvent: TIdleTimerAutoEvent
|
||||
read FAutoStartEvent write SetAutoStartEvent default itaOnUserInput;
|
||||
end;
|
||||
|
||||
|
||||
{ TShape }
|
||||
|
||||
TShapeType = (stRectangle, stSquare, stRoundRect, stRoundSquare,
|
||||
stEllipse, stCircle);
|
||||
|
||||
@ -261,6 +286,7 @@ type
|
||||
// property OnStartDrag;
|
||||
end;
|
||||
|
||||
|
||||
{ TPaintBox }
|
||||
|
||||
TPaintBox = class(TGraphicControl)
|
||||
@ -336,6 +362,7 @@ type
|
||||
property Transparent: Boolean read FTransparent write SetTransparent;
|
||||
end;
|
||||
|
||||
|
||||
{ TBevel }
|
||||
|
||||
TBevelStyle = (bsLowered, bsRaised);
|
||||
@ -371,10 +398,7 @@ type
|
||||
|
||||
|
||||
{ TCustomRadioGroup }
|
||||
{
|
||||
@abstract(Base class for TRadioGroup.)
|
||||
(currently) maintained by Stefan Hille (stoppok@osibisa.ms.sub.org)
|
||||
}
|
||||
|
||||
TCustomRadioGroup = class(TCustomGroupBox)
|
||||
private
|
||||
FButtonList : TList; // list of TRadioButton
|
||||
@ -407,10 +431,7 @@ type
|
||||
|
||||
|
||||
{ TRadioGroup }
|
||||
{
|
||||
@abstract(Group of radiobuttons.)
|
||||
(currently) maintained by Stefan Hille (stoppok@osibisa.ms.sub.org)
|
||||
}
|
||||
|
||||
TRadioGroup = class(TCustomRadioGroup)
|
||||
public
|
||||
constructor Create (AOwner : TComponent); override;
|
||||
@ -520,6 +541,7 @@ uses Math;
|
||||
{$I customnotebook.inc}
|
||||
{$I notebook.inc}
|
||||
{$I timer.inc}
|
||||
{$I idletimer.inc}
|
||||
{$I shape.inc}
|
||||
{$I paintbox.inc}
|
||||
{$I customradiogroup.inc}
|
||||
@ -533,6 +555,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.43 2002/11/04 11:48:48 lazarus
|
||||
MG: implemented TIdleTimer and fixed small bugs
|
||||
|
||||
Revision 1.42 2002/10/31 04:27:58 lazarus
|
||||
AJ: added TShape
|
||||
|
||||
|
114
lcl/include/idletimer.inc
Normal file
114
lcl/include/idletimer.inc
Normal file
@ -0,0 +1,114 @@
|
||||
// included by extctrls.pp
|
||||
|
||||
{******************************************************************************
|
||||
TIdleTimer
|
||||
******************************************************************************
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.LCL, 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. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
}
|
||||
|
||||
{ TIdleTimer }
|
||||
|
||||
procedure TIdleTimer.SetAutoEnabled(const AValue: boolean);
|
||||
begin
|
||||
if FAutoEnabled=AValue then exit;
|
||||
FAutoEnabled:=AValue;
|
||||
UpdateHandlers;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.DoOnIdle(Sender: TObject);
|
||||
begin
|
||||
if not AutoEnabled then exit;
|
||||
// automatic start, stop or restart
|
||||
if AutoEndEvent=itaOnIdle then
|
||||
Enabled:=false;
|
||||
if AutoStartEvent=itaOnIdle then
|
||||
Enabled:=true;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.DoOnIdleEnd(Sender: TObject);
|
||||
begin
|
||||
if not AutoEnabled then exit;
|
||||
// automatic start, stop or restart
|
||||
if AutoEndEvent=itaOnIdleEnd then
|
||||
Enabled:=false;
|
||||
if AutoStartEvent=itaOnIdleEnd then
|
||||
Enabled:=true;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.DoOnUserInput(Sender: TObject);
|
||||
begin
|
||||
if not AutoEnabled then exit;
|
||||
// automatic start, stop or restart
|
||||
if AutoEndEvent=itaOnUserInput then
|
||||
Enabled:=false;
|
||||
if AutoStartEvent=itaOnUserInput then
|
||||
Enabled:=true;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
UpdateHandlers;
|
||||
end;
|
||||
|
||||
constructor TIdleTimer.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
FAutoEndEvent:=itaOnIdle;
|
||||
FAutoStartEvent:=itaOnUserInput;
|
||||
end;
|
||||
|
||||
destructor TIdleTimer.Destroy;
|
||||
begin
|
||||
AutoEnabled:=false;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.UpdateHandlers;
|
||||
begin
|
||||
if FAutoEnabled
|
||||
and ([csDesigning,csLoading]*ComponentState=[]) then begin
|
||||
// connect handlers
|
||||
if FHandlersConnected or (Application=nil) then exit;
|
||||
Application.AddOnIdleHandler(@DoOnIdle);
|
||||
Application.AddOnIdleEndHandler(@DoOnIdleEnd);
|
||||
Application.AddOnUserInputHandler(@DoOnUserInput);
|
||||
FHandlersConnected:=true;
|
||||
end else begin
|
||||
// disconnect handlers
|
||||
if (not FHandlersConnected) or (Application=nil) then exit;
|
||||
Application.RemoveOnIdleHandler(@DoOnIdle);
|
||||
Application.RemoveOnIdleEndHandler(@DoOnIdleEnd);
|
||||
Application.RemoveOnUserInputHandler(@DoOnUserInput);
|
||||
FHandlersConnected:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.SetAutoEndEvent(const AValue: TIdleTimerAutoEvent);
|
||||
begin
|
||||
if FAutoEndEvent=AValue then exit;
|
||||
FAutoEndEvent:=AValue;
|
||||
end;
|
||||
|
||||
procedure TIdleTimer.SetAutoStartEvent(const AValue: TIdleTimerAutoEvent);
|
||||
begin
|
||||
if FAutoStartEvent=AValue then exit;
|
||||
FAutoStartEvent:=AValue;
|
||||
end;
|
||||
|
||||
|
||||
// included by extctrls.pp
|
||||
|
Loading…
Reference in New Issue
Block a user