fpmwnd.inc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Window menu entries
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. procedure TIDEApp.CloseAll;
  13. procedure SendClose(P: PView); {$ifndef FPC}far;{$endif}
  14. begin
  15. Message(P,evCommand,cmClose,nil);
  16. end;
  17. begin
  18. Desktop^.ForEach(@SendClose);
  19. end;
  20. type
  21. PWindowListBox = ^TWindowListBox;
  22. TWindowListBox = object(TAdvancedListBox)
  23. constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
  24. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  25. end;
  26. PWindowListDialog = ^TWindowListDialog;
  27. TWindowListDialog = object(TCenterDialog)
  28. constructor Init;
  29. procedure HandleEvent(var Event: TEvent); virtual;
  30. destructor Done; virtual;
  31. private
  32. LB: PWindowListBox;
  33. C : PCollection;
  34. procedure UpdateList;
  35. end;
  36. constructor TWindowListBox.Init(var Bounds: TRect; AScrollBar: PScrollBar);
  37. begin
  38. inherited Init(Bounds,1,AScrollBar);
  39. end;
  40. function TWindowListBox.GetText(Item,MaxLen: Sw_Integer): String;
  41. var P: PView;
  42. S: string;
  43. begin
  44. P:=List^.At(Item);
  45. case P^.HelpCtx of
  46. hcSourceWindow : S:=PSourceWindow(P)^.GetTitle(MaxLen);
  47. hcInfoWindow : S:=PProgramInfoWindow(P)^.GetTitle(MaxLen);
  48. hcHelpWindow : S:=PHelpWindow(P)^.GetTitle(MaxLen);
  49. hcCalcWindow : S:=PCalculator(P)^.GetTitle(MaxLen);
  50. hcBrowserWindow: S:=PBrowserWindow(P)^.GetTitle(MaxLen);
  51. else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
  52. end;
  53. GetText:=copy(S,1,MaxLen);
  54. end;
  55. constructor TWindowListDialog.Init;
  56. var R,R2: TRect;
  57. SB: PScrollBar;
  58. begin
  59. R.Assign(0,0,50,15);
  60. inherited Init(R, 'Window List');
  61. New(C, Init(20,10));
  62. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=37;
  63. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  64. New(SB, Init(R2)); Insert(SB);
  65. New(LB, Init(R, SB));
  66. LB^.Default:=true;
  67. LB^.NewList(C);
  68. UpdateList;
  69. if C^.Count>=2 then LB^.FocusItem(1); { focus the 2nd one }
  70. Insert(LB);
  71. R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
  72. Insert(New(PLabel, Init(R2, '~W~indows', LB)));
  73. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=38; R.B.Y:=R.A.Y+2;
  74. Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault)));
  75. R.Move(0,3);
  76. Insert(New(PButton, Init(R, '~D~elete', cmDeleteItem, bfNormal)));
  77. R.Move(0,3);
  78. Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  79. LB^.Select;
  80. end;
  81. procedure TWindowListDialog.UpdateList;
  82. procedure AddIt(P: PView); {$ifndef FPC}far;{$endif}
  83. begin
  84. if (P<>pointer(Desktop^.Background)) and (P^.GetState(sfVisible)) then
  85. C^.Insert(P);
  86. end;
  87. begin
  88. C^.DeleteAll;
  89. Desktop^.ForEach(@AddIt);
  90. LB^.SetRange(C^.Count);
  91. ReDraw;
  92. end;
  93. procedure TWindowListDialog.HandleEvent(var Event: TEvent);
  94. begin
  95. case Event.What of
  96. evKeyDown :
  97. case Event.KeyCode of
  98. kbDel :
  99. begin
  100. Message(@Self,evCommand,cmDeleteItem,nil);
  101. ClearEvent(Event);
  102. end;
  103. end;
  104. evCommand :
  105. case Event.Command of
  106. cmDeleteItem :
  107. if C^.Count>0 then
  108. begin
  109. Message(C^.At(LB^.Focused),evCommand,cmClose,nil);
  110. UpdateList;
  111. ClearEvent(Event);
  112. end;
  113. cmOK :
  114. PView(C^.At(LB^.Focused))^.MakeFirst;
  115. end;
  116. end;
  117. inherited HandleEvent(Event);
  118. end;
  119. destructor TWindowListDialog.Done;
  120. begin
  121. if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
  122. inherited Done;
  123. end;
  124. procedure TIDEApp.WindowList;
  125. var W: PWindowListDialog;
  126. begin
  127. New(W,Init);
  128. ExecView(W);
  129. Dispose(W,Done);
  130. end;
  131. {
  132. $Log$
  133. Revision 1.6 1999-01-21 11:54:22 peter
  134. + tools menu
  135. + speedsearch in symbolbrowser
  136. * working run command
  137. Revision 1.5 1999/01/12 14:29:37 peter
  138. + Implemented still missing 'switch' entries in Options menu
  139. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  140. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  141. ASCII chars and inserted directly in the text.
  142. + Added symbol browser
  143. * splitted fp.pas to fpide.pas
  144. Revision 1.4 1999/01/04 11:49:49 peter
  145. * 'Use tab characters' now works correctly
  146. + Syntax highlight now acts on File|Save As...
  147. + Added a new class to syntax highlight: 'hex numbers'.
  148. * There was something very wrong with the palette managment. Now fixed.
  149. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  150. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  151. process revised
  152. Revision 1.3 1998/12/28 15:47:50 peter
  153. + Added user screen support, display & window
  154. + Implemented Editor,Mouse Options dialog
  155. + Added location of .INI and .CFG file
  156. + Option (INI) file managment implemented (see bottom of Options Menu)
  157. + Switches updated
  158. + Run program
  159. Revision 1.2 1998/12/23 22:58:19 peter
  160. * fixed windowlist for fpc
  161. Revision 1.1 1998/12/22 14:27:54 peter
  162. * moved
  163. Revision 1.3 1998/12/22 10:39:50 peter
  164. + options are now written/read
  165. + find and replace routines
  166. }