mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 20:40:25 +02:00
added TScreen handlers, implemented TMainIDE.UnHideIDE
git-svn-id: trunk@4184 -
This commit is contained in:
parent
d43aa69aac
commit
f5fda4505a
@ -4822,29 +4822,18 @@ end;
|
||||
procedure TPropertyEditorHook.RemoveHandler(HookType: TPropHookType;
|
||||
const Handler: TMethod);
|
||||
begin
|
||||
if FHandlers[HookType]=nil then exit;
|
||||
FHandlers[HookType].Remove(Handler);
|
||||
end;
|
||||
|
||||
function TPropertyEditorHook.GetHandlerCount(HookType: TPropHookType): integer;
|
||||
begin
|
||||
if FHandlers[HookType]<>nil then
|
||||
Result:=FHandlers[HookType].Count
|
||||
else
|
||||
Result:=0;
|
||||
Result:=FHandlers[HookType].Count;
|
||||
end;
|
||||
|
||||
function TPropertyEditorHook.GetNextHandlerIndex(HookType: TPropHookType;
|
||||
var i: integer): boolean;
|
||||
begin
|
||||
if FHandlers[HookType]<>nil then begin
|
||||
dec(i);
|
||||
if (i>=FHandlers[HookType].Count) then
|
||||
i:=FHandlers[HookType].Count-1;
|
||||
end else begin
|
||||
i:=-1;
|
||||
end;
|
||||
Result:=(i>=0);
|
||||
Result:=FHandlers[HookType].NextDownIndex(i);
|
||||
end;
|
||||
|
||||
constructor TPropertyEditorHook.Create;
|
||||
|
@ -227,15 +227,15 @@ procedure TDebugManager.OnDebuggerChangeState(ADebugger: TDebugger;
|
||||
const
|
||||
// dsNone, dsIdle, dsStop, dsPause, dsRun, dsError
|
||||
TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = (
|
||||
// dsNone, dsIdle, dsStop, dsPause, dsRun, dsError
|
||||
// dsNone, dsIdle, dsStop, dsPause, dsRun, dsError
|
||||
itNone, itNone, itNone, itDebugger, itDebugger, itDebugger
|
||||
);
|
||||
STATENAME: array[TDBGState] of string = (
|
||||
'dsNone', 'dsIdle', 'dsStop', 'dsPause', 'dsRun', 'dsError'
|
||||
);
|
||||
begin
|
||||
// Is the next line needed ???
|
||||
if (ADebugger<>FDebugger) or (ADebugger=nil) then exit;
|
||||
if (ADebugger<>FDebugger) or (ADebugger=nil) then
|
||||
RaiseException('TDebugManager.OnDebuggerChangeState');
|
||||
|
||||
WriteLN('[TDebugManager.OnDebuggerChangeState] state: ', STATENAME[FDebugger.State]);
|
||||
|
||||
@ -265,11 +265,12 @@ begin
|
||||
end;
|
||||
|
||||
if (FDebugger.State in [dsRun]) then begin
|
||||
// hide IDE during run
|
||||
if EnvironmentOptions.HideIDEOnRun then
|
||||
MainIDE.HideIDE;
|
||||
end else if (OldState in [dsRun]) then begin
|
||||
MainIDE.Show;
|
||||
SourceNotebook.Show;
|
||||
// unhide IDE
|
||||
MainIDE.UnhideIDE;
|
||||
end;
|
||||
|
||||
case FDebugger.State of
|
||||
@ -935,6 +936,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.24 2003/05/25 12:12:36 mattias
|
||||
added TScreen handlers, implemented TMainIDE.UnHideIDE
|
||||
|
||||
Revision 1.23 2003/05/24 17:51:34 marc
|
||||
MWE: Added an usersource history
|
||||
|
||||
|
@ -339,6 +339,7 @@ type
|
||||
FToolStatus: TIDEToolStatus;
|
||||
procedure SetToolStatus(const AValue: TIDEToolStatus);
|
||||
protected
|
||||
CurrentParsedCompilerOption: TParsedCompilerOptions;
|
||||
TheCompiler: TCompiler;
|
||||
TheOutputFilter: TOutputFilter;
|
||||
|
||||
@ -357,12 +358,14 @@ type
|
||||
|
||||
procedure LoadMenuShortCuts; virtual;
|
||||
public
|
||||
CurrentParsedCompilerOption: TParsedCompilerOptions;
|
||||
MacroList: TTransferMacroList;
|
||||
HiddenWindowsOnRun: TList; // list of forms, that were automatically hidden
|
||||
// and will be shown when debugged program stops
|
||||
|
||||
property ToolStatus: TIDEToolStatus read FToolStatus write SetToolStatus;
|
||||
procedure UpdateCaption; virtual; abstract;
|
||||
procedure HideIDE; virtual; abstract;
|
||||
procedure UnhideIDE; virtual; abstract;
|
||||
|
||||
procedure CreateOftenUsedForms; virtual; abstract;
|
||||
|
||||
|
45
lcl/forms.pp
45
lcl/forms.pp
@ -487,6 +487,19 @@ type
|
||||
Index: Integer;
|
||||
Handle: HCURSOR;
|
||||
end;
|
||||
|
||||
TScreenFormEvent = procedure(Sender: TObject; Form: TCustomForm) of object;
|
||||
TScreenActiveFormChangedEvent = procedure(Sender: TObject;
|
||||
LastForm: TCustomForm) of object;
|
||||
TScreenControlEvent = procedure(Sender: TObject;
|
||||
LastControl: TControl) of object;
|
||||
|
||||
TScreenNotification = (
|
||||
snFormAdded,
|
||||
snRemoveForm,
|
||||
snActiveControlChanged,
|
||||
snActiveFormChanged
|
||||
);
|
||||
|
||||
TScreen = class(TComponent)
|
||||
private
|
||||
@ -502,6 +515,7 @@ type
|
||||
FFocusedForm: TCustomForm;
|
||||
FFonts : TStrings;
|
||||
FFormList: TList;
|
||||
FHandlers: array[TScreenNotification] of TMethodList;
|
||||
FHintFont : TFont;
|
||||
FLastActiveControl: TWinControl;
|
||||
FLastActiveCustomForm: TCustomForm;
|
||||
@ -526,6 +540,13 @@ type
|
||||
procedure SetCursor(const AValue: TCursor);
|
||||
procedure SetCursors(Index: Integer; const AValue: HCURSOR);
|
||||
procedure UpdateLastActive;
|
||||
procedure AddHandler(HandlerType: TScreenNotification;
|
||||
const Handler: TMethod);
|
||||
procedure RemoveHandler(HandlerType: TScreenNotification;
|
||||
const Handler: TMethod);
|
||||
function GetHandlerCount(HandlerType: TScreenNotification): integer;
|
||||
function GetNextHandlerIndex(HandlerType: TScreenNotification;
|
||||
var i: integer): boolean;
|
||||
public
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
destructor Destroy; Override;
|
||||
@ -534,6 +555,19 @@ type
|
||||
function CustomFormZIndex(AForm: TCustomForm): integer;
|
||||
procedure MoveFormToFocusFront(ACustomForm: TCustomForm);
|
||||
procedure MoveFormToZFront(ACustomForm: TCustomForm);
|
||||
// handler
|
||||
procedure AddHandlerFormAdded(OnFormAdded: TScreenFormEvent);
|
||||
procedure RemoveHandlerFormAdded(OnFormAdded: TScreenFormEvent);
|
||||
procedure AddHandlerRemoveForm(OnRemoveForm: TScreenFormEvent);
|
||||
procedure RemoveHandlerRemoveForm(OnRemoveForm: TScreenFormEvent);
|
||||
procedure AddHandlerActiveControlChanged(
|
||||
OnActiveControlChanged: TScreenControlEvent);
|
||||
procedure RemoveHandlerActiveControlChanged(
|
||||
OnActiveControlChanged: TScreenControlEvent);
|
||||
procedure AddHandlerActiveFormChanged(
|
||||
OnActiveFormChanged: TScreenActiveFormChangedEvent);
|
||||
procedure RemoveHandlerActiveFormChanged(
|
||||
OnActiveFormChanged: TScreenActiveFormChangedEvent);
|
||||
public
|
||||
property ActiveControl: TWinControl read FActiveControl;
|
||||
property ActiveCustomForm: TCustomForm read FActiveCustomForm;
|
||||
@ -542,7 +576,8 @@ type
|
||||
property Cursors[Index: Integer]: HCURSOR read GetCursors write SetCursors;
|
||||
property CustomFormCount: Integer read GetCustomFormCount;
|
||||
property CustomForms[Index: Integer]: TCustomForm read GetCustomForms;
|
||||
property CustomFormsZOrdered[Index: Integer]: TCustomForm read GetCustomFormsZOrdered;
|
||||
property CustomFormsZOrdered[Index: Integer]: TCustomForm
|
||||
read GetCustomFormsZOrdered;
|
||||
property FocusedForm: TCustomForm read FFocusedForm;
|
||||
property FormCount: Integer read GetFormCount;
|
||||
property Forms[Index: Integer]: TForm read GetForms;
|
||||
@ -550,10 +585,10 @@ type
|
||||
property Height : Integer read Getheight;
|
||||
property HintFont : TFont read FHintFont;
|
||||
property Width : Integer read GetWidth;
|
||||
property OnActiveControlChange: TNotifyEvent
|
||||
read FOnActiveControlChange write FOnActiveControlChange;
|
||||
property OnActiveFormChange: TNotifyEvent
|
||||
read FOnActiveFormChange write FOnActiveFormChange;
|
||||
property OnActiveControlChange: TNotifyEvent read FOnActiveControlChange
|
||||
write FOnActiveControlChange;
|
||||
property OnActiveFormChange: TNotifyEvent read FOnActiveFormChange
|
||||
write FOnActiveFormChange;
|
||||
property PixelsPerInch : integer read FPixelsPerInch;
|
||||
end;
|
||||
|
||||
|
@ -51,7 +51,11 @@ end;
|
||||
Destructor for the class.
|
||||
------------------------------------------------------------------------------}
|
||||
Destructor TScreen.Destroy;
|
||||
var
|
||||
HandlerType: TScreenNotification;
|
||||
begin
|
||||
for HandlerType:=Low(FHandlers) to High(FHandlers) do
|
||||
FreeThenNil(FHandlers[HandlerType]);
|
||||
FreeThenNil(FHintFont);
|
||||
FreeThenNil(FFormList);
|
||||
FreeThenNil(FCustomForms);
|
||||
@ -105,6 +109,50 @@ begin
|
||||
FCustomFormsZOrdered.Insert(0, ACustomForm);
|
||||
end;
|
||||
|
||||
procedure TScreen.AddHandlerFormAdded(OnFormAdded: TScreenFormEvent);
|
||||
begin
|
||||
AddHandler(snFormAdded,TMethod(OnFormAdded));
|
||||
end;
|
||||
|
||||
procedure TScreen.RemoveHandlerFormAdded(OnFormAdded: TScreenFormEvent);
|
||||
begin
|
||||
RemoveHandler(snFormAdded,TMethod(OnFormAdded));
|
||||
end;
|
||||
|
||||
procedure TScreen.AddHandlerRemoveForm(OnRemoveForm: TScreenFormEvent);
|
||||
begin
|
||||
AddHandler(snRemoveForm,TMethod(OnRemoveForm));
|
||||
end;
|
||||
|
||||
procedure TScreen.RemoveHandlerRemoveForm(OnRemoveForm: TScreenFormEvent);
|
||||
begin
|
||||
RemoveHandler(snRemoveForm,TMethod(OnRemoveForm));
|
||||
end;
|
||||
|
||||
procedure TScreen.AddHandlerActiveControlChanged(
|
||||
OnActiveControlChanged: TScreenControlEvent);
|
||||
begin
|
||||
AddHandler(snActiveControlChanged,TMethod(OnActiveControlChanged));
|
||||
end;
|
||||
|
||||
procedure TScreen.RemoveHandlerActiveControlChanged(
|
||||
OnActiveControlChanged: TScreenControlEvent);
|
||||
begin
|
||||
RemoveHandler(snActiveControlChanged,TMethod(OnActiveControlChanged));
|
||||
end;
|
||||
|
||||
procedure TScreen.AddHandlerActiveFormChanged(
|
||||
OnActiveFormChanged: TScreenActiveFormChangedEvent);
|
||||
begin
|
||||
AddHandler(snActiveFormChanged,TMethod(OnActiveFormChanged));
|
||||
end;
|
||||
|
||||
procedure TScreen.RemoveHandlerActiveFormChanged(
|
||||
OnActiveFormChanged: TScreenActiveFormChangedEvent);
|
||||
begin
|
||||
RemoveHandler(snActiveFormChanged,TMethod(OnActiveFormChanged));
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TScreen.GetFonts : TStrings;
|
||||
------------------------------------------------------------------------------}
|
||||
@ -217,6 +265,8 @@ end;
|
||||
Do not use this procedure. This procedure is used by TScreen internally.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TScreen.AddForm(AForm: TCustomForm);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FCustomForms.Add(AForm);
|
||||
FCustomFormsZOrdered.Add(AForm);
|
||||
@ -225,6 +275,9 @@ begin
|
||||
FFormList.Add(AForm);
|
||||
Application.UpdateVisible;
|
||||
end;
|
||||
i:=GetHandlerCount(snFormAdded);
|
||||
while GetNextHandlerIndex(snFormAdded,i) do
|
||||
TScreenFormEvent(FHandlers[snFormAdded][i])(Self,AForm);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -281,10 +334,14 @@ end;
|
||||
Params: FForm: The form to be removed
|
||||
Returns: Nothing
|
||||
|
||||
Do not use this procedure. This procedure is used by TScreen internally.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TScreen.RemoveForm(AForm: TCustomForm);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=GetHandlerCount(snRemoveForm);
|
||||
while GetNextHandlerIndex(snRemoveForm,i) do
|
||||
TScreenFormEvent(FHandlers[snRemoveForm][i])(Self,AForm);
|
||||
FCustomForms.Remove(AForm);
|
||||
FCustomFormsZOrdered.Remove(AForm);
|
||||
FFormList.Remove(AForm);
|
||||
@ -343,18 +400,75 @@ end;
|
||||
procedure TScreen.UpdateLastActive;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TScreen.UpdateLastActive;
|
||||
|
||||
procedure NotifyOnActiveFormChanged;
|
||||
var
|
||||
i: Integer;
|
||||
Handler: TScreenFormEvent;
|
||||
begin
|
||||
if Assigned(FOnActiveFormChange) then FOnActiveFormChange(Self);
|
||||
i:=GetHandlerCount(snActiveFormChanged);
|
||||
while GetNextHandlerIndex(snActiveFormChanged,i) do begin
|
||||
Handler:=TScreenFormEvent(FHandlers[snActiveFormChanged][i]);
|
||||
Handler(Self,FLastActiveCustomForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure NotifyOnActiveControlChanged;
|
||||
var
|
||||
i: Integer;
|
||||
Handler: TScreenControlEvent;
|
||||
begin
|
||||
if Assigned(FOnActiveControlChange) then FOnActiveControlChange(Self);
|
||||
i:=GetHandlerCount(snActiveControlChanged);
|
||||
while GetNextHandlerIndex(snActiveControlChanged,i) do begin
|
||||
Handler:=TScreenFormEvent(FHandlers[snActiveControlChanged][i]);
|
||||
Handler(Self,FLastActiveControl);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
if FLastActiveCustomForm <> FActiveCustomForm then
|
||||
begin
|
||||
FLastActiveCustomForm := FActiveCustomForm;
|
||||
if Assigned(FOnActiveFormChange) then FOnActiveFormChange(Self);
|
||||
NotifyOnActiveFormChanged;
|
||||
end;
|
||||
if FLastActiveControl <> FActiveControl then
|
||||
begin
|
||||
FLastActiveControl := FActiveControl;
|
||||
if Assigned(FOnActiveControlChange) then FOnActiveControlChange(Self);
|
||||
NotifyOnActiveControlChanged;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TScreen.AddHandler(HandlerType: TScreenNotification;
|
||||
const Handler: TMethod);
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TScreen.AddHandler(HandlerType: TScreenNotification;
|
||||
const Handler: TMethod);
|
||||
begin
|
||||
if Handler.Code=nil then RaiseGDBException('TScreen.AddHandler');
|
||||
if FHandlers[HandlerType]=nil then
|
||||
FHandlers[HandlerType]:=TMethodList.Create;
|
||||
FHandlers[HandlerType].Add(Handler);
|
||||
end;
|
||||
|
||||
procedure TScreen.RemoveHandler(HandlerType: TScreenNotification;
|
||||
const Handler: TMethod);
|
||||
begin
|
||||
FHandlers[HandlerType].Remove(Handler);
|
||||
end;
|
||||
|
||||
function TScreen.GetHandlerCount(HandlerType: TScreenNotification): integer;
|
||||
begin
|
||||
Result:=FHandlers[HandlerType].Count;
|
||||
end;
|
||||
|
||||
function TScreen.GetNextHandlerIndex(HandlerType: TScreenNotification;
|
||||
var i: integer): boolean;
|
||||
begin
|
||||
Result:=FHandlers[HandlerType].NextDownIndex(i);
|
||||
end;
|
||||
|
||||
// included by forms.pp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user