mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 08:19:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			196 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			196 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
{
 | 
						|
    $Id$
 | 
						|
    This file is part of the Free Pascal Integrated Development Environment
 | 
						|
    Copyright (c) 1998 by Berczi Gabor
 | 
						|
 | 
						|
    Window menu entries
 | 
						|
 | 
						|
    See the file COPYING.FPC, included in this distribution,
 | 
						|
    for details about the copyright.
 | 
						|
 | 
						|
    This program is distributed in the hope that it will be useful,
 | 
						|
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | 
						|
 | 
						|
 **********************************************************************}
 | 
						|
 | 
						|
procedure TIDEApp.CloseAll;
 | 
						|
 | 
						|
  procedure SendClose(P: PView); {$ifndef FPC}far;{$endif}
 | 
						|
  begin
 | 
						|
    Message(P,evCommand,cmClose,nil);
 | 
						|
  end;
 | 
						|
 | 
						|
begin
 | 
						|
  Desktop^.ForEach(@SendClose);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
type
 | 
						|
    PWindowListBox = ^TWindowListBox;
 | 
						|
    TWindowListBox = object(TAdvancedListBox)
 | 
						|
      constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
 | 
						|
      function    GetText(Item,MaxLen: Sw_Integer): String; virtual;
 | 
						|
    end;
 | 
						|
 | 
						|
    PWindowListDialog = ^TWindowListDialog;
 | 
						|
    TWindowListDialog = object(TCenterDialog)
 | 
						|
      constructor Init;
 | 
						|
      procedure   HandleEvent(var Event: TEvent); virtual;
 | 
						|
      destructor  Done; virtual;
 | 
						|
    private
 | 
						|
      LB: PWindowListBox;
 | 
						|
      C : PCollection;
 | 
						|
      procedure  UpdateList;
 | 
						|
    end;
 | 
						|
 | 
						|
constructor TWindowListBox.Init(var Bounds: TRect; AScrollBar: PScrollBar);
 | 
						|
begin
 | 
						|
  inherited Init(Bounds,1,AScrollBar);
 | 
						|
end;
 | 
						|
 | 
						|
function TWindowListBox.GetText(Item,MaxLen: Sw_Integer): String;
 | 
						|
var P: PView;
 | 
						|
    S: string;
 | 
						|
begin
 | 
						|
  P:=List^.At(Item);
 | 
						|
  case P^.HelpCtx of
 | 
						|
    hcSourceWindow : S:=PSourceWindow(P)^.GetTitle(MaxLen);
 | 
						|
    hcInfoWindow   : S:=PProgramInfoWindow(P)^.GetTitle(MaxLen);
 | 
						|
    hcHelpWindow   : S:=PHelpWindow(P)^.GetTitle(MaxLen);
 | 
						|
    hcCalcWindow   : S:=PCalculator(P)^.GetTitle(MaxLen);
 | 
						|
    hcBrowserWindow: S:=PBrowserWindow(P)^.GetTitle(MaxLen);
 | 
						|
  else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
 | 
						|
  end;
 | 
						|
  GetText:=copy(S,1,MaxLen);
 | 
						|
end;
 | 
						|
 | 
						|
constructor TWindowListDialog.Init;
 | 
						|
var R,R2: TRect;
 | 
						|
    SB: PScrollBar;
 | 
						|
begin
 | 
						|
  R.Assign(0,0,50,15);
 | 
						|
  inherited Init(R, 'Window List');
 | 
						|
 | 
						|
  New(C, Init(20,10));
 | 
						|
 | 
						|
  GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=37;
 | 
						|
  R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
 | 
						|
  New(SB, Init(R2)); Insert(SB);
 | 
						|
  New(LB, Init(R, SB));
 | 
						|
  LB^.Default:=true;
 | 
						|
  LB^.NewList(C);
 | 
						|
  UpdateList;
 | 
						|
  if C^.Count>=2 then LB^.FocusItem(1); { focus the 2nd one }
 | 
						|
  Insert(LB);
 | 
						|
  R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
 | 
						|
  Insert(New(PLabel, Init(R2, '~W~indows', LB)));
 | 
						|
 | 
						|
  GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=38; R.B.Y:=R.A.Y+2;
 | 
						|
  Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault)));
 | 
						|
  R.Move(0,3);
 | 
						|
  Insert(New(PButton, Init(R, '~D~elete', cmDeleteItem, bfNormal)));
 | 
						|
  R.Move(0,3);
 | 
						|
  Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
 | 
						|
 | 
						|
  LB^.Select;
 | 
						|
end;
 | 
						|
 | 
						|
procedure TWindowListDialog.UpdateList;
 | 
						|
procedure AddIt(P: PView); {$ifndef FPC}far;{$endif}
 | 
						|
begin
 | 
						|
  if (P<>pointer(Desktop^.Background)) and (P^.GetState(sfVisible)) then
 | 
						|
     C^.Insert(P);
 | 
						|
end;
 | 
						|
begin
 | 
						|
  C^.DeleteAll;
 | 
						|
  Desktop^.ForEach(@AddIt);
 | 
						|
  LB^.SetRange(C^.Count);
 | 
						|
  ReDraw;
 | 
						|
end;
 | 
						|
 | 
						|
procedure TWindowListDialog.HandleEvent(var Event: TEvent);
 | 
						|
begin
 | 
						|
  case Event.What of
 | 
						|
    evKeyDown :
 | 
						|
      case Event.KeyCode of
 | 
						|
        kbDel :
 | 
						|
          begin
 | 
						|
            Message(@Self,evCommand,cmDeleteItem,nil);
 | 
						|
            ClearEvent(Event);
 | 
						|
          end;
 | 
						|
      end;
 | 
						|
    evCommand :
 | 
						|
      case Event.Command of
 | 
						|
        cmDeleteItem :
 | 
						|
          if C^.Count>0 then
 | 
						|
          begin
 | 
						|
            Message(C^.At(LB^.Focused),evCommand,cmClose,nil);
 | 
						|
            UpdateList;
 | 
						|
            ClearEvent(Event);
 | 
						|
          end;
 | 
						|
        cmOK :
 | 
						|
          PView(C^.At(LB^.Focused))^.MakeFirst;
 | 
						|
      end;
 | 
						|
  end;
 | 
						|
  inherited HandleEvent(Event);
 | 
						|
end;
 | 
						|
 | 
						|
destructor TWindowListDialog.Done;
 | 
						|
begin
 | 
						|
  if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
 | 
						|
  inherited Done;
 | 
						|
end;
 | 
						|
 | 
						|
procedure TIDEApp.WindowList;
 | 
						|
var W: PWindowListDialog;
 | 
						|
begin
 | 
						|
  New(W,Init);
 | 
						|
  ExecView(W);
 | 
						|
  Dispose(W,Done);
 | 
						|
end;
 | 
						|
 | 
						|
{
 | 
						|
  $Log$
 | 
						|
  Revision 1.6  1999-01-21 11:54:22  peter
 | 
						|
    + tools menu
 | 
						|
    + speedsearch in symbolbrowser
 | 
						|
    * working run command
 | 
						|
 | 
						|
  Revision 1.5  1999/01/12 14:29:37  peter
 | 
						|
    + Implemented still missing 'switch' entries in Options menu
 | 
						|
    + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
 | 
						|
      ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
 | 
						|
      ASCII chars and inserted directly in the text.
 | 
						|
    + Added symbol browser
 | 
						|
    * splitted fp.pas to fpide.pas
 | 
						|
 | 
						|
  Revision 1.4  1999/01/04 11:49:49  peter
 | 
						|
   * 'Use tab characters' now works correctly
 | 
						|
   + Syntax highlight now acts on File|Save As...
 | 
						|
   + Added a new class to syntax highlight: 'hex numbers'.
 | 
						|
   * There was something very wrong with the palette managment. Now fixed.
 | 
						|
   + Added output directory (-FE<xxx>) support to 'Directories' dialog...
 | 
						|
   * Fixed some possible bugs in Running/Compiling, and the compilation/run
 | 
						|
     process revised
 | 
						|
 | 
						|
  Revision 1.3  1998/12/28 15:47:50  peter
 | 
						|
    + Added user screen support, display & window
 | 
						|
    + Implemented Editor,Mouse Options dialog
 | 
						|
    + Added location of .INI and .CFG file
 | 
						|
    + Option (INI) file managment implemented (see bottom of Options Menu)
 | 
						|
    + Switches updated
 | 
						|
    + Run program
 | 
						|
 | 
						|
  Revision 1.2  1998/12/23 22:58:19  peter
 | 
						|
    * fixed windowlist for fpc
 | 
						|
 | 
						|
  Revision 1.1  1998/12/22 14:27:54  peter
 | 
						|
    * moved
 | 
						|
 | 
						|
  Revision 1.3  1998/12/22 10:39:50  peter
 | 
						|
    + options are now written/read
 | 
						|
    + find and replace routines
 | 
						|
 | 
						|
}
 |