IDE: designer: fixed handling deactivate messages

git-svn-id: trunk@39774 -
This commit is contained in:
mattias 2013-01-06 11:53:30 +00:00
parent 69cc8c5905
commit 88c2af49d0
5 changed files with 101 additions and 47 deletions

View File

@ -244,8 +244,8 @@ type
// hook
function GetPropertyEditorHook: TPropertyEditorHook; override;
function OnFormActivated: boolean;
function OnFormCloseQuery: boolean;
function DoFormActivated(Active: boolean): boolean;
function DoFormCloseQuery: boolean;
property PopupMenuComponentEditor: TBaseComponentEditor read FPopupMenuComponentEditor write SetPopupMenuComponentEditor;
public
@ -2573,26 +2573,29 @@ begin
if csDesigning in Sender.ComponentState then begin
Result:=true;
Inc(FProcessingDesignerEvent);
case TheMessage.Msg of
LM_PAINT: Result := PaintControl(Sender, TLMPaint(TheMessage));
CN_KEYDOWN,CN_SYSKEYDOWN: KeyDown(Sender,TLMKey(TheMessage));
CN_KEYUP,CN_SYSKEYUP: KeyUP(Sender,TLMKey(TheMessage));
LM_LBUTTONDOWN,
LM_RBUTTONDOWN,
LM_LBUTTONDBLCLK: MouseDownOnControl(Sender,TLMMouse(TheMessage));
LM_LBUTTONUP,
LM_RBUTTONUP: MouseUpOnControl(Sender, TLMMouse(TheMessage));
LM_MOUSEMOVE: MouseMoveOnControl(Sender, TLMMouse(TheMessage));
LM_SIZE: Result:=SizeControl(Sender, TLMSize(TheMessage));
LM_MOVE: Result:=MoveControl(Sender, TLMMove(TheMessage));
LM_ACTIVATE: Result:=OnFormActivated;
LM_CLOSEQUERY: Result:=OnFormCloseQuery;
LM_SETCURSOR: Result:=HandleSetCursor(TheMessage);
LM_CONTEXTMENU: HandlePopupMenu(Sender, TLMContextMenu(TheMessage));
else
Result:=false;
try
case TheMessage.Msg of
LM_PAINT: Result := PaintControl(Sender, TLMPaint(TheMessage));
CN_KEYDOWN,CN_SYSKEYDOWN: KeyDown(Sender,TLMKey(TheMessage));
CN_KEYUP,CN_SYSKEYUP: KeyUP(Sender,TLMKey(TheMessage));
LM_LBUTTONDOWN,
LM_RBUTTONDOWN,
LM_LBUTTONDBLCLK: MouseDownOnControl(Sender,TLMMouse(TheMessage));
LM_LBUTTONUP,
LM_RBUTTONUP: MouseUpOnControl(Sender, TLMMouse(TheMessage));
LM_MOUSEMOVE: MouseMoveOnControl(Sender, TLMMouse(TheMessage));
LM_SIZE: Result:=SizeControl(Sender, TLMSize(TheMessage));
LM_MOVE: Result:=MoveControl(Sender, TLMMove(TheMessage));
LM_ACTIVATE: Result:=DoFormActivated(TLMActivate(TheMessage).Active=WA_ACTIVE);
LM_CLOSEQUERY: Result:=DoFormCloseQuery;
LM_SETCURSOR: Result:=HandleSetCursor(TheMessage);
LM_CONTEXTMENU: HandlePopupMenu(Sender, TLMContextMenu(TheMessage));
else
Result:=false;
end;
finally
Dec(FProcessingDesignerEvent);
end;
Dec(FProcessingDesignerEvent);
end else begin
if (TheMessage.Msg=LM_PAINT)
or (TheMessage.Msg=CN_KEYDOWN)
@ -3806,17 +3809,21 @@ begin
EnvironmentOptions.SnapToGrid:=AValue;
end;
function TDesigner.OnFormActivated: boolean;
function TDesigner.DoFormActivated(Active: boolean): boolean;
begin
//the form was activated.
if Assigned(FOnActivated) then FOnActivated(Self);
Result:=true;
if Active then begin
// designer form was activated.
if Assigned(FOnActivated) then FOnActivated(Self);
end else begin
// designer form deactivated
end;
Result:=false; // pass message to form, needed for focussing
end;
function TDesigner.OnFormCloseQuery: boolean;
function TDesigner.DoFormCloseQuery: boolean;
begin
if Assigned(FOnCloseQuery) then FOnCloseQuery(Self);
Result:=true;
Result:=true; // do not pass to form
end;
function TDesigner.GetPropertyEditorHook: TPropertyEditorHook;

View File

@ -6063,8 +6063,13 @@ begin
if ObjectInspector1.IsVisible then
begin
ObjectInspector1.FocusGrid;
if DisplayState <> high(TDisplayState) then
DisplayState:= Succ(DisplayState);
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.DoShowInspector old=',dbgs(DisplayState)]);
{$ENDIF}
case DisplayState of
dsSource: DisplayState:=dsInspector;
dsForm: DisplayState:=dsInspector2;
end;
end;
end;
end;
@ -8793,10 +8798,13 @@ end;
procedure TMainIDE.DoBringToFrontFormOrUnit;
begin
if DisplayState = dsSource then begin
DoShowDesignerFormOfCurrentSrc;
end else begin
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.DoBringToFrontFormOrUnit ',dbgs(DisplayState)]);
{$ENDIF}
if DisplayState <> dsSource then begin
DoShowSourceOfActiveDesignerForm;
end else begin
DoShowDesignerFormOfCurrentSrc;
end;
end;
@ -8806,16 +8814,14 @@ begin
DoShowInspector(true);
exit;
end;
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.DoBringToFrontFormOrInspector old=',dbgs(DisplayState)]);
{$ENDIF}
case DisplayState of
dsInspector:
DoShowDesignerFormOfCurrentSrc;
dsInspector2:
DoShowSourceOfActiveDesignerForm;
else
DoShowInspector(true);
dsInspector: DoShowDesignerFormOfCurrentSrc;
dsInspector2: DoShowSourceOfActiveDesignerForm;
else
DoShowInspector(true);
end;
end;
@ -8826,6 +8832,9 @@ var
AForm: TCustomForm;
UnitCodeBuf: TCodeBuffer;
begin
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.DoShowDesignerFormOfCurrentSrc ']);
{$ENDIF}
GetCurrentUnit(ActiveSourceEditor,ActiveUnitInfo);
if (ActiveUnitInfo = nil) then exit;
@ -8849,7 +8858,7 @@ begin
// load the form, if not already done
AForm:=GetDesignerFormOfSource(ActiveUnitInfo,true);
if AForm=nil then exit;
DisplayState:= dsForm;
DisplayState:=dsForm;
LastFormActivated:=AForm;
ShowDesignerForm(AForm);
if TheControlSelection.SelectionForm<>AForm then begin
@ -8872,7 +8881,10 @@ begin
end;
end;
SourceEditorManager.ShowActiveWindowOnTop(False);
DisplayState:= dsSource;
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.DoShowSourceOfActiveDesignerForm ']);
{$ENDIF}
DisplayState:=dsSource;
end;
procedure TMainIDE.GetIDEFileState(Sender: TObject; const AFilename: string;
@ -11655,11 +11667,20 @@ end;
procedure TMainIDE.OnSrcNoteBookActivated(Sender: TObject);
begin
DisplayState:= dsSource;
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDE.OnSrcNoteBookActivated']);
{$ENDIF}
DisplayState:=dsSource;
end;
procedure TMainIDE.OnDesignerActivated(Sender: TObject);
begin
{$IFDEF VerboseIDEDisplayState}
if DisplayState<>dsForm then begin
debugln(['TMainIDE.OnDesignerActivated ']);
DumpStack;
end;
{$ENDIF}
DisplayState:= dsForm;
LastFormActivated := (Sender as TDesigner).Form;
UpdateIDEComponentPalette;

View File

@ -89,6 +89,7 @@ type
FDisplayState: TDisplayState;
// used to find the last form so you can display the correct tab
FLastFormActivated: TCustomForm;
procedure SetDisplayState(AValue: TDisplayState);
protected
FNeedUpdateHighlighters: boolean;
@ -194,7 +195,7 @@ type
public
property ToolStatus: TIDEToolStatus read FToolStatus write SetToolStatus;
property WindowMenuActiveForm: TCustomForm read FWindowMenuActiveForm write FWindowMenuActiveForm;
property DisplayState: TDisplayState read FDisplayState write FDisplayState;
property DisplayState: TDisplayState read FDisplayState write SetDisplayState;
property LastFormActivated: TCustomForm read FLastFormActivated write FLastFormActivated;
end;
@ -453,6 +454,15 @@ begin
UpdateWindowMenu;
end;
procedure TMainIDEBase.SetDisplayState(AValue: TDisplayState);
begin
if FDisplayState=AValue then Exit;
FDisplayState:=AValue;
{$IFDEF VerboseIDEDisplayState}
debugln(['TMainIDEBase.SetDisplayState ',dbgs(DisplayState)]);
{$ENDIF}
end;
function TMainIDEBase.CreateMenuSeparator : TMenuItem;
begin
Result := TMenuItem.Create(MainIDEBar);

View File

@ -60,8 +60,8 @@ uses
MemCheck,
{$ENDIF}
Classes, LCLType, LCLIntf, StdCtrls, Buttons, Menus, ComCtrls, SysUtils,
Controls, Graphics, ExtCtrls, Dialogs, FileUtil, Forms, CodeToolManager,
CodeCache, AVL_Tree, SynEditKeyCmds,
typinfo, Controls, Graphics, ExtCtrls, Dialogs, FileUtil, Forms,
CodeToolManager, CodeCache, AVL_Tree, SynEditKeyCmds,
// IDE
PropEdits, ObjectInspector, MenuIntf, SrcEditorIntf, ProjectIntf, MacroIntf,
CompOptsIntf, LazIDEIntf,
@ -299,6 +299,8 @@ type
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
end;
function dbgs(d: TDisplayState): string; overload;
implementation
@ -336,6 +338,11 @@ begin
Result:='['+Result+']';
end;
function dbgs(d: TDisplayState): string;
begin
Result:=GetEnumName(typeinfo(d),ord(d));
end;
{ TMainIDEInterface }
function TMainIDEInterface.GetActiveProject: TLazProject;

View File

@ -339,6 +339,9 @@ begin
if LockOnChange(PgtkObject(Widget),0) > 0 then Exit;
FillChar(Mess{%H-}, SizeOf(Mess), #0);
{$IFDEF VerboseIDEDisplayState}
debugln(['gtkactivateCB ',DbgSName(TObject(Data))]);
{$ENDIF}
Mess.Msg := LM_ACTIVATE;
Mess.Active := WA_ACTIVE;
Mess.Minimized := False;
@ -788,6 +791,9 @@ begin
try
if (Info <> nil) then
Include(Info^.Flags, wwiActivating);
{$IFDEF VerboseIDEDisplayState}
debugln(['gtkfrmactivateAfter ',DbgSName(TObject(Data))]);
{$ENDIF}
Mess.Msg := LM_ACTIVATE;
Mess.Active := WA_ACTIVE;
Mess.Minimized := False;
@ -834,6 +840,9 @@ begin
if (Info<>nil) then
Include(Info^.Flags, wwiDeactivating);
FillChar(Mess{%H-}, SizeOf(Mess), #0);
{$IFDEF VerboseIDEDisplayState}
debugln(['gtkfrmdeactivateAfter ',DbgSName(TObject(Data))]);
{$ENDIF}
Mess.Msg := LM_ACTIVATE;
Mess.Active := WA_INACTIVE;
Mess.Minimized := False;