mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-09 11:32:41 +02:00

Allowed DockHeader to disappear for single client. (todo: also for notebook) Disallowed undocking of a NOT docked notebook. (hack, the notebook should become a frame) git-svn-id: trunk@22495 -
86 lines
1.8 KiB
ObjectPascal
86 lines
1.8 KiB
ObjectPascal
unit fEditBook;
|
|
(* Maintain a chain of active (editor) windows.
|
|
Move form to front whenever activated.
|
|
Dequeue form when destroyed.
|
|
|
|
The queue head is stored in the global variable MRUEdit.
|
|
|
|
The EditBook should become a frame, embeddable without docking.
|
|
*)
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
{ TODO : figure out what's wrong with the mru list - with multiple windows }
|
|
{.$DEFINE mru} //problems with MRU list???
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
|
fDockBook;
|
|
|
|
type
|
|
TEditBook = class(TEasyDockBook)
|
|
procedure FormActivate(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|
private
|
|
{ private declarations }
|
|
protected
|
|
NRUEdit: TEditBook; //Next Recently Used EditBook
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
MRUEdit: TEditBook; //Most Recently Used EditBook
|
|
|
|
implementation
|
|
|
|
{ TEditBook }
|
|
|
|
procedure TEditBook.FormActivate(Sender: TObject);
|
|
var
|
|
prev: TEditBook;
|
|
begin
|
|
//enQ self as first
|
|
if MRUEdit = Self then
|
|
exit; //is alread head
|
|
prev := MRUEdit;
|
|
{$IFDEF mru}
|
|
while (prev <> nil) and (prev.NRUEdit <> self) do
|
|
prev := prev.NRUEdit;
|
|
if prev <> nil then
|
|
prev.NRUEdit := self.NRUEdit; //was already in Q
|
|
NRUEdit := MRUEdit; //old head
|
|
MRUEdit := self; //become head
|
|
{$ELSE}
|
|
{$ENDIF}
|
|
end;
|
|
|
|
procedure TEditBook.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|
var
|
|
prev: TEditBook;
|
|
begin
|
|
//deQ self
|
|
prev := MRUEdit;
|
|
{$IFDEF mru}
|
|
if prev = self then
|
|
MRUEdit := NRUEdit
|
|
else begin
|
|
while (prev <> nil) and (prev.NRUEdit <> self) do
|
|
prev := prev.NRUEdit;
|
|
if prev.NRUEdit = self then
|
|
prev.NRUEdit := NRUEdit;
|
|
//else not in chain?
|
|
end;
|
|
NRUEdit := nil;
|
|
{$ELSE}
|
|
{$ENDIF}
|
|
end;
|
|
|
|
initialization
|
|
{$I feditbook.lrs}
|
|
|
|
end.
|
|
|