Changes to make toggling between form and unit work.

Added BringWindowToTop
Shane

git-svn-id: trunk@419 -
This commit is contained in:
lazarus 2001-11-14 17:46:59 +00:00
parent 5b266eec73
commit a7787f8119
13 changed files with 188 additions and 52 deletions

View File

@ -58,6 +58,7 @@ type
FOnRemoveComponent: TOnRemoveComponent;
FOnSetDesigning: TOnSetDesigning;
FOnUnselectComponentClass: TNotifyEvent;
FOnActivated: TNotifyEvent;
FPopupMenu: TPopupMenu;
FAlignMenuItem: TMenuItem;
FMirrorHorizontalMenuItem: TMenuItem;
@ -100,6 +101,7 @@ type
procedure OnSizePopupMenuClick(Sender: TObject);
procedure OnBringToFrontMenuClick(Sender: TObject);
procedure OnSendToBackMenuClick(Sender: TObject);
Procedure OnFormActivated;
public
ControlSelection : TControlSelection;
constructor Create(Customform : TCustomform; AControlSelection: TControlSelection);
@ -130,6 +132,8 @@ type
property OnSetDesigning: TOnSetDesigning read FOnSetDesigning write FOnSetDesigning;
property OnUnselectComponentClass: TNotifyEvent
read FOnUnselectComponentClass write FOnUnselectComponentClass;
property OnActivated: TNotifyEvent
read FOnActivated write FOnActivated;
function NonVisualComponentAtPos(x,y: integer): TComponent;
procedure DrawNonVisualComponents(DC: HDC);
property OnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas
@ -695,7 +699,10 @@ Begin
Result := true
else
if ((Message.Msg >= LM_KeyFIRST) and (Message.Msg <= LM_KeyLAST)) then
Result:=true;
Result:=true
else
if (Message.Msg = LM_ACTIVATE) then
Result := True;
// else
// if ((Message.Msg >= CM_MOUSEENTER) and (Message.Msg <= CM_MOUSELEAVE)) then
// Result:=true;
@ -710,6 +717,7 @@ Begin
LM_MOUSEMOVE: MouseMoveOnControl(Sender, TLMMouse(Message));
LM_SIZE: Result:=SizeControl(Sender,TLMSize(Message));
LM_MOVE: Result:=MoveControl(Sender,TLMMove(Message));
LM_ACTIVATE : OnFormActivated;
// CM_MOUSELEAVE: Writeln('MOUSELEAVE!!!!!!!!!!!!');//Result:=MoveControl(Sender,TLMMove(Message));
end;
end;
@ -1052,6 +1060,13 @@ begin
FHintWindow.ActivateHint(Rect,AHint);
end;
Procedure TDesigner.OnFormActivated;
begin
//the form was activated.
if Assigned(FOnActivated) then
FOnActivated(Form);
end;
initialization
GridSizex := 10;

View File

@ -210,7 +210,7 @@ type
Procedure OnSrcNotebookProcessCommand(Sender: TObject; Command: integer;
var Handled: boolean);
procedure OnSrcNoteBookShowUnitInfo(Sender: TObject);
Procedure OnSrcNoteBookActivated(Sender : TObject);
// ObjectInspector events
procedure OIOnAddAvailableComponent(AComponent:TComponent;
var Allowed:boolean);
@ -235,6 +235,7 @@ type
procedure MessagesViewSelectionChanged(sender : TObject);
private
FCodeLastActivated : Boolean; //used for toggling between code and forms
FLastFormActivated : TCustomForm; //used to find the last form so you can display the corret tab
FSelectedComponent : TRegisteredComponent;
fProject: TProject;
MacroList: TTransferMacroList;
@ -342,6 +343,7 @@ type
ComponentClass: TRegisteredComponent);
procedure OnDesignerRemoveComponent(Sender: TObject; Component: TComponent);
procedure OnDesignerModified(Sender: TObject);
Procedure OnDesignerActivated(Sender : TObject);
procedure OnControlSelectionChanged(Sender: TObject);
procedure SaveEnvironment;
@ -572,7 +574,7 @@ begin
SourceNotebook.OnProcessUserCommand := @OnSrcNotebookProcessCommand;
SourceNotebook.OnShowUnitInfo := @OnSrcNoteBookShowUnitInfo;
SourceNotebook.OnEditorVisibleChanged := @OnSrcNotebookEditorVisibleChanged;
SourceNotebook.OnActivate := @OnSrcNoteBookActivated;
// find / replace dialog
itmSearchFind.OnClick := @SourceNotebook.FindClicked;
@ -731,7 +733,7 @@ writeln('[TMainIDE.FormCloseQuery]');
CanClose:=true;
if SomethingOfProjectIsModified then begin
if (Application.MessageBox('Save changes to project2?','Project changed', MB_IconQuestion+mb_YesNo))=mrYes then
if (Application.MessageBox('Save changes to project?','Project changed', MB_IconQuestion+mb_YesNo))=mrYes then
begin
CanClose:=DoSaveProject(false,false)<>mrAbort;
if CanClose=false then exit;
@ -1685,6 +1687,7 @@ writeln('[TMainIDE.SetDefaultsforForm] B');
OnRemoveComponent:=@OnDesignerRemoveComponent;
OnGetNonVisualCompIconCanvas:=@IDECompList.OnGetNonVisualCompIconCanvas;
OnModified:=@OnDesignerModified;
OnActivated := @OnDesignerActivated;
end;
end;
@ -3091,7 +3094,7 @@ CheckHeap(IntToStr(GetMem_Cnt));
// close the old project
if SomethingOfProjectIsModified then begin
if MessageDlg('Project changed', 'Save changes to project?',
mtconfirmation,[mbok, mbcancel],0)=mrOK then
mtconfirmation,[mbYes, mbNo],0)=mrYes then
begin
if DoSaveProject(false,false)=mrAbort then begin
Result:=mrAbort;
@ -3179,7 +3182,7 @@ begin
if SomethingOfProjectIsModified then begin
if MessageDlg('Project changed','Save changes to project?',
mtconfirmation,[mbok, mbcancel],0)=mrOK then
mtconfirmation,[mbYes, mbNo],0)=mrYes then
begin
if DoSaveProject(false,false)=mrAbort then begin
Result:=mrAbort;
@ -3340,8 +3343,8 @@ begin
'The project must be saved before building'#13
+'If you set the Test Directory in the environment options,'#13
+'you can create new projects and build them at once.'#13
+'Save project?',mtInformation,[mbOk,mbCancel],0);
if Result<>mrOk then exit;
+'Save project?',mtInformation,[mbYes,mbNo],0);
if Result<>mrYes then exit;
Result:=DoSaveAll;
exit;
end;
@ -3921,6 +3924,16 @@ begin
AForm:=SourceNotebook
else
AForm:=nil;
//if AForm is set, make sure the right tab is being displayed.
if AForm <> nil then
begin
ActiveUnitInfo := Project.UnitWithForm(FLastFormActivated);
if ActiveUnitInfo <> nil then
begin
SourceNotebook.Notebook.PageIndex := ActiveUnitInfo.EditorIndex;
end;
end;
end
else
begin
@ -3930,16 +3943,14 @@ begin
SourceNoteBook.NoteBook.PageIndex);
if (ActiveUnitInfo<>nil) then
AForm:=TCustomForm(ActiveUnitInfo.Form);
FLastFormActivated := AForm;
end;
end;
if AForm<>nil then
begin
// AForm.BringToFront;
AForm.Hide;
AForm.Show;
BringWindowToTop(AForm.Handle);
end;
end;
@ -4140,12 +4151,9 @@ begin
FMessagesViewBoundsRectValid:=true;
WasVisible:=MessagesView.Visible;
MessagesView.Show;
if not WasVisible then begin
// quick hack, till BringToFront works correctly
SourceNotebook.Hide;
SourceNotebook.Show;
end;
if not WasVisible then
bringWindowToTop(SourceNotebook.Handle); //sxm changed 2001-11-14
//set the event here for the selectionchanged event
if not assigned(MessagesView.OnSelectionChanged) then
MessagesView.OnSelectionChanged := @MessagesViewSelectionChanged;
@ -4550,11 +4558,27 @@ end;
Procedure TMainIDE.OnSrcNotebookEditorVisibleChanged(Sender : TObject);
var
NewSrcEdit : TSourceEditor;
ActiveUnitInfo : TUnitInfo;
begin
if SourceNotebook.Notebook = nil then Exit;
NewSrcEdit:=SourceNotebook.GetActiveSE;
ToggleFormSpeedBtn.Enabled := Assigned(NewSrcEdit.Control);
ActiveUnitInfo := Project.UnitWithEditorIndex(SourceNotebook.Notebook.Pageindex);
if ActiveUnitInfo = nil then Exit;
ToggleFormSpeedBtn.Enabled := Assigned(ActiveUnitInfo.Form);
end;
Procedure TMainIDE.OnSrcNoteBookActivated(Sender : TObject);
begin
FCodeLastActivated:=True;
end;
Procedure TMainIDE.OnDesignerActivated(Sender : TObject);
begin
FCodeLastActivated:=False;
FLastFormActivated := TCustomForm(Sender);
end;
initialization
@ -4569,8 +4593,9 @@ end.
{ =============================================================================
$Log$
Revision 1.142 2001/11/13 18:50:08 lazarus
Changes to facilitate the toggle between form and unit
Revision 1.143 2001/11/14 17:46:54 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.141 2001/11/12 16:56:04 lazarus

View File

@ -311,6 +311,7 @@ type
OnlyProjectUnits:boolean):integer;
function UnitWithEditorIndex(Index:integer):TUnitInfo;
Function UnitWithForm(AForm : TComponent) : TUnitInfo;
procedure CloseEditorIndex(EditorIndex:integer);
procedure InsertEditorIndex(EditorIndex:integer);
procedure Clear;
@ -1673,12 +1674,29 @@ begin
for i:=0 to UnitCount-1 do Result:=Result or Units[i].Modified;
end;
Function TProject.UnitWithForm(AForm : TComponent) : TUnitInfo;
var i:integer;
begin
i:=UnitCount-1;
while (i>=0) and (Units[i].Form<>AForm) do dec(i);
if i>=0 then
Result:=Units[i]
else
Result:=nil;
end;
end.
{
$Log$
Revision 1.40 2001/11/14 17:46:57 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.39 2001/11/06 22:20:30 lazarus
MG: started breakpoint and watch frontend

View File

@ -69,7 +69,7 @@ type
FEditor : TSynEdit;
FCodeTemplates: TSynEditAutoComplete;
//if this is a Form or Datamodule, this is used
FControl: TComponent;
// FControl: TComponent; //commented out on 11-14-2001
FCodeBuffer: TCodeBuffer;
FIgnoreCodeBufferLock: integer;
@ -120,7 +120,6 @@ type
protected
FindText : String;
ErrorMsgs : TStrings;
Procedure DisplayControl;
Procedure ReParent(AParent : TWinControl);
Procedure OpenAtCursorClicked(Sender : TObject);
@ -168,7 +167,7 @@ type
procedure GetDialogPosition(Width, Height:integer; var Left,Top:integer);
property CodeBuffer: TCodeBuffer read FCodeBuffer write SetCodeBuffer;
property Control : TComponent read FControl write FControl;
// property Control : TComponent read FControl write FControl; //commented out on 11-14-2001
property CurrentCursorXLine : Integer
read GetCurrentCursorXLine write SetCurrentCursorXLine;
property CurrentCursorYLine : Integer
@ -240,7 +239,6 @@ type
Procedure OpenAtCursorClicked(Sender : TObject);
Procedure BookmarkGoTo(Value: Integer);
Procedure BookMarkToggle(Value : Integer);
protected
ccSelection : String;
@ -267,6 +265,8 @@ type
function GetEditors(Index:integer):TSourceEditor;
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
public
SearchPaths: string;
@ -288,7 +288,6 @@ type
procedure UpdateStatusBar;
Procedure ClearUnUsedEditorComponents(Force: boolean);
Procedure DisplayFormforActivePage;
Procedure DisplayCodeforControl(Control : TObject);
Procedure DisplayCodefromUnitName(const UnitName : String);
@ -406,7 +405,7 @@ Begin
FErrorColumn:=-1;
FExecutionLine:=-1;
FControl := nil;
// FControl := nil; //commented out on 11-14-2001
//writeln('TSourceEditor.Create B ');
CreateEditor(AOwner,AParent);
//writeln('TSourceEditor.Create END ');
@ -1155,21 +1154,6 @@ writeln('TSourceEditor.CreateEditor A ');
FEditor.SetFocus;
end;
Procedure TSourceEditor.DisplayControl;
Begin
if FControl = nil then Exit;
if (FControl is TCustomForm) then TCustomForm(FControl).Show
else
if (FCOntrol is TControl) then TControl(FCOntrol).Visible := True;
//Bringtofront does not work yet.
//TControl(FControl).BringToFront;
//so I hide it and unhide it.
TControl(FCOntrol).Visible := False;
TControl(FCOntrol).Visible := True;
end;
procedure TSourceEditor.SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
begin
@ -1588,6 +1572,7 @@ begin
IdentCompletionTimer.Interval := 500;
Visible:=false;
end;
destructor TSourceNotebook.Destroy;
@ -2164,7 +2149,11 @@ Procedure TSourceNotebook.DisplayCodeforControl(Control : TObject);
Var
I,X : Integer;
Begin
X := FSourceEditorList.Count;
Writeln('DISPLAY CODE FOR CONTROL');
Writeln('This was commented out on 11-14-2001');
Writeln('This should be deleted a month from that day if it''s not used.');
{ X := FSourceEditorList.Count;
if X = 0 then Exit;
I := 0;
while (I < X)
@ -2174,8 +2163,9 @@ Begin
Writeln(' I = '+inttostr(i));
end;
if I < X then
if I < X then s
DisplayPage(TSourceEditor(FSOurceEditorList.Items[I]));
}
End;
Procedure TSourceNotebook.DisplayCodefromUnitName(const UnitName : String);
@ -2195,12 +2185,6 @@ Begin
DisplayPage(TSourceEditor(FSOurceEditorList.Items[I]));
end;
Procedure TSourceNotebook.DisplayFormforActivePage;
Begin
Writeln('DisplayFormForActivePage');
GetActiveSE.DisplayControl;
Writeln('Exiting DisplayFormForActivePage');
End;
Function TSourceNotebook.DisplayPage(SE : TSourceEditor) : Boolean;
Var
@ -2860,6 +2844,7 @@ Begin
end;
{ GOTO DIALOG}
Constructor TfrmGoto.Create(AOWner : TComponent);

View File

@ -345,6 +345,11 @@ end;
{ =============================================================================
$Log$
Revision 1.14 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.13 2001/11/05 18:18:19 lazarus
added popupmenu+arrows to notebooks, added target filename

View File

@ -14,6 +14,12 @@ begin
Result := False;
end;
Function TInterfaceBase.BringWindowToTop(hWnd : HWND): Boolean;
begin
// Your default here
// Result :=
end;
function TInterfaceBase.CallNextHookEx(hhk : HHOOK; ncode : Integer; wParam, lParam : Longint) : Integer;
begin
Result := 0;
@ -492,6 +498,11 @@ end;
{ =============================================================================
$Log$
Revision 1.19 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.18 2001/11/12 16:56:07 lazarus
MG: CLIPBOARD

View File

@ -21,6 +21,11 @@ begin
Result := InterfaceObject.BitBlt(DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, Rop);
end;
Function BringWindowToTop(hWnd : HWND): Boolean;
begin
Result := InterfaceObject.BringWindowToTop(hWnd);
end;
function CallNextHookEx(hhk : HHOOK; ncode : Integer; wParam, lParam : Longint) : Integer;
begin
Result := InterfaceObject.CallNExtHookEx(hhk,ncode,wparam,lParam);
@ -1022,6 +1027,11 @@ end;
{ =============================================================================
$Log$
Revision 1.19 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.18 2001/11/12 16:56:07 lazarus
MG: CLIPBOARD

View File

@ -19,6 +19,7 @@
//##apiwiz##sps## // Do not remove
function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
Function BringWindowToTop(hWnd : HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function CallNextHookEx(hhk : HHOOK; ncode : Integer; wParam, lParam : Longint) : Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
Function CallWindowProc(lpPrevWndFunc : TFarProc; Handle : HWND; Msg : UINT; wParam ,lParam : LongInt) : Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
@ -240,6 +241,11 @@ function UnionRect(var lprcDst: TRect; const lprcSrc1, lprcSrc2: TRect): Boolean
{ =============================================================================
$Log$
Revision 1.15 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.14 2001/11/12 16:56:07 lazarus
MG: CLIPBOARD

View File

@ -67,6 +67,7 @@ begin
Result := DeliverMessage(Data, Mess) = 0;
end;
function gtkactivateCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var
Mess : TLMessage;
@ -1389,6 +1390,11 @@ end;
{ =============================================================================
$Log$
Revision 1.44 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.43 2001/11/12 19:32:23 lazarus
MG: fixed empty clipboard stream crashing bug

View File

@ -442,14 +442,28 @@ begin
LM_BRINGTOFRONT:
begin
Assert(False, 'Trace:TODO:bringtofront');
Writeln('----------------------------');
Writeln('----------------------------');
Writeln('----------------------------');
Writeln('----------------------------');
Writeln('----------------------------');
Writeln('----------------------------');
{ Assert(False, 'Trace:TODO:bringtofront');
//For now just hide and show again.
if (Sender is TControl) then begin
TControl(Sender).Parent.RemoveControl(TControl(Sender));
writeln('Removed control ', TControl(Sender).Name);
TControl(Sender).Parent.InsertControl(TControl(Sender));
writeln('Inserted control ', TControl(Sender).Name);
end;
end;
}
if (Sender is TCustomForm) then
Begin
Widget := PgtkWidget(TCustomForm(Sender).Handle);
gdk_window_raise(Widget^.Window);
end;
end;
LM_BTNDEFAULT_CHANGED :
@ -3300,6 +3314,11 @@ end;
{ =============================================================================
$Log$
Revision 1.71 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.70 2001/11/12 16:56:08 lazarus
MG: CLIPBOARD

View File

@ -176,6 +176,24 @@ begin
end;
end;
{------------------------------------------------------------------------------
Function: BringWindowToTop
Params: hWnd:
Returns:
------------------------------------------------------------------------------}
Function TGTKObject.BringWindowToTop(hWnd : HWND): Boolean;
begin
//hwnd should be a PgtkWidget.
result := True;
try
gdk_window_raise(PgtkWidget(hwnd)^.window);
except
Result := False;
end;
end;
{------------------------------------------------------------------------------
Function: CallNextHookEx
Params: none
@ -4050,6 +4068,11 @@ end;
{ =============================================================================
$Log$
Revision 1.49 2001/11/14 17:46:59 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.48 2001/11/12 16:56:08 lazarus
MG: CLIPBOARD

View File

@ -6,6 +6,7 @@
//##apiwiz##sps## // Do not remove
function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; override;
Function BringWindowToTop(hWnd : HWND): Boolean; override;
function CallNextHookEx(hhk : HHOOK; ncode : Integer; wParam, lParam : Longint) : Integer; override;
Function CallWindowProc(lpPrevWndFunc : TFarProc; Handle : HWND; Msg : UINT; wParam ,lParam : LongInt) : Integer; override;
@ -125,6 +126,11 @@ Function WindowFromPoint(Point : TPoint) : HWND; override;
{ =============================================================================
$Log$
Revision 1.19 2001/11/14 17:46:59 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.18 2001/11/12 16:56:09 lazarus
MG: CLIPBOARD

View File

@ -87,6 +87,8 @@ LM_POPUPSHOW = LM_COMUSER+56;
LM_RECREATEWND = LM_COMUSER+57;
LM_SETFORMICON = LM_COMUSER+58;
LM_MINIMIZE = LM_COMUSER+59;
//end of messages that are sent to the interface
@ -769,6 +771,11 @@ end.
{
$Log$
Revision 1.12 2001/11/14 17:46:58 lazarus
Changes to make toggling between form and unit work.
Added BringWindowToTop
Shane
Revision 1.11 2001/06/26 00:08:35 lazarus
MG: added code for form icons from Rene E. Beszon