|
@@ -5,7 +5,8 @@ unit Fresnel.App;
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
- Classes, SysUtils, CustApp, Fresnel.Events, Fresnel.Forms, Fresnel.WidgetSet;
|
|
|
+ Classes, SysUtils, CustApp, Fresnel.Classes, Fresnel.Events, Fresnel.Forms,
|
|
|
+ Fresnel.WidgetSet;
|
|
|
|
|
|
type
|
|
|
TApplicationFlag = (
|
|
@@ -41,7 +42,7 @@ type
|
|
|
procedure NotifyActivateHandler; virtual;
|
|
|
procedure NotifyDeactivateHandler; virtual;
|
|
|
procedure NotifyIdleEndHandler; virtual;
|
|
|
- procedure NotifyIdleHandler(var Done: Boolean); virtual;
|
|
|
+ procedure NotifyIdleHandler; virtual;
|
|
|
procedure WSAppActivate(Async: Boolean = False); virtual;
|
|
|
procedure WSAppDeactivate(Async: Boolean = False); virtual;
|
|
|
procedure WSAppMinimize; virtual;
|
|
@@ -56,13 +57,13 @@ type
|
|
|
public
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
destructor Destroy; override;
|
|
|
- procedure CreateForm(InstanceClass: TComponentClass; out Reference); virtual; // use this for designed forms and components
|
|
|
+ procedure CreateForm(aClass: TComponentClass; out FormVariable); override;
|
|
|
procedure UpdateMainForm(AForm: TFresnelForm); virtual;
|
|
|
|
|
|
// events, queues
|
|
|
procedure HandleException(Sender: TObject); override;
|
|
|
procedure HandleMessage; virtual;
|
|
|
- procedure ProcessMessages; virtual;
|
|
|
+ procedure ProcessMessages; override;
|
|
|
procedure Idle(Wait: Boolean); virtual;
|
|
|
|
|
|
property CaptureExceptions: Boolean read FCaptureExceptions write SetCaptureExceptions;
|
|
@@ -78,8 +79,6 @@ var
|
|
|
|
|
|
implementation
|
|
|
|
|
|
-uses fresnel.classes;
|
|
|
-
|
|
|
var
|
|
|
HandlingException: Boolean = False;
|
|
|
HaltingProgram: Boolean = False;
|
|
@@ -250,18 +249,18 @@ begin
|
|
|
CustomApplication:=nil;
|
|
|
end;
|
|
|
|
|
|
-procedure TFresnelApplication.CreateForm(InstanceClass: TComponentClass; out
|
|
|
- Reference);
|
|
|
+procedure TFresnelApplication.CreateForm(aClass: TComponentClass; out
|
|
|
+ FormVariable);
|
|
|
var
|
|
|
Instance: TComponent;
|
|
|
ok: boolean;
|
|
|
AForm: TFresnelForm;
|
|
|
begin
|
|
|
// Allocate the instance, without calling the constructor
|
|
|
- Instance := TComponent(InstanceClass.NewInstance);
|
|
|
+ Instance := TComponent(aClass.NewInstance);
|
|
|
// set the Reference before the constructor is called, so that
|
|
|
// events and constructors can refer to it
|
|
|
- TComponent(Reference) := Instance;
|
|
|
+ TComponent(FormVariable) := Instance;
|
|
|
|
|
|
if Instance is TFresnelForm then
|
|
|
AForm := TFresnelForm(Instance)
|
|
@@ -291,7 +290,7 @@ begin
|
|
|
ok:=true;
|
|
|
finally
|
|
|
if not ok then begin
|
|
|
- TComponent(Reference) := nil;
|
|
|
+ TComponent(FormVariable) := nil;
|
|
|
end;
|
|
|
if FCreatingForm=Instance then
|
|
|
FCreatingForm:=nil;
|
|
@@ -359,10 +358,8 @@ begin
|
|
|
EventDispatcher.DispatchEvent(evtIdleEnd);
|
|
|
end;
|
|
|
|
|
|
-procedure TFresnelApplication.NotifyIdleHandler(var Done: Boolean);
|
|
|
-
|
|
|
+procedure TFresnelApplication.NotifyIdleHandler;
|
|
|
begin
|
|
|
- // done ?
|
|
|
EventDispatcher.DispatchEvent(evtIdle);
|
|
|
end;
|
|
|
|
|
@@ -385,31 +382,16 @@ begin
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelApplication.Idle(Wait: Boolean);
|
|
|
-var
|
|
|
- Done: Boolean;
|
|
|
begin
|
|
|
-
|
|
|
ProcessAsyncCallQueue;
|
|
|
-
|
|
|
- Done := True;
|
|
|
- //if (FIdleLockCount=0) then begin
|
|
|
- // if Assigned(FOnIdle) then FOnIdle(Self, Done);
|
|
|
- // if Done then
|
|
|
- // NotifyIdleHandler(Done);
|
|
|
- //end;
|
|
|
- if Done
|
|
|
- then begin
|
|
|
- // wait till something happens
|
|
|
- //if (FIdleLockCount=0) then
|
|
|
- // DoIdleActions;
|
|
|
- Include(FFlags,AppWaiting);
|
|
|
- Exclude(FFlags,AppIdleEndSent);
|
|
|
- if Wait then
|
|
|
- WidgetSet.AppWaitMessage;
|
|
|
- //if (FIdleLockCount=0) then
|
|
|
- // DoOnIdleEnd;
|
|
|
- Exclude(FFlags,AppWaiting);
|
|
|
- end;
|
|
|
+ NotifyIdleHandler;
|
|
|
+
|
|
|
+ // wait till something happens
|
|
|
+ Include(FFlags,AppWaiting);
|
|
|
+ Exclude(FFlags,AppIdleEndSent);
|
|
|
+ if Wait then
|
|
|
+ WidgetSet.AppWaitMessage;
|
|
|
+ Exclude(FFlags,AppWaiting);
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelApplication.WSAppActivate(Async: Boolean);
|