fpmwnd.inc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. hcMessagesWindow:S:=PMessagesWindow(P)^.GetTitle(MaxLen);
  52. hcGDBWindow,
  53. hcWatches,
  54. hcStack,
  55. hcRegisters,
  56. hcClipboardWindow,
  57. hcASCIITableWindow,
  58. hcBreakpointListWindow :
  59. S:=PWindow(P)^.GetTitle(MaxLen);
  60. else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
  61. end;
  62. if PWindow(P)^.Number<>0 then
  63. S:=S+'('+IntToStr(PWindow(P)^.Number)+')';
  64. GetText:=copy(S,1,MaxLen);
  65. end;
  66. constructor TWindowListDialog.Init;
  67. var R,R2: TRect;
  68. SB: PScrollBar;
  69. begin
  70. R.Assign(0,0,50,15);
  71. inherited Init(R, 'Window List');
  72. New(C, Init(20,10));
  73. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=37;
  74. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  75. New(SB, Init(R2)); Insert(SB);
  76. New(LB, Init(R, SB));
  77. LB^.Default:=true;
  78. LB^.NewList(C);
  79. UpdateList;
  80. if C^.Count>=2 then LB^.FocusItem(1); { focus the 2nd one }
  81. Insert(LB);
  82. R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
  83. Insert(New(PLabel, Init(R2, '~W~indows', LB)));
  84. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=38; R.B.Y:=R.A.Y+2;
  85. Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault)));
  86. R.Move(0,3);
  87. Insert(New(PButton, Init(R, '~D~elete', cmDeleteItem, bfNormal)));
  88. R.Move(0,3);
  89. Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  90. LB^.Select;
  91. end;
  92. procedure TWindowListDialog.UpdateList;
  93. procedure AddIt(P: PView); {$ifndef FPC}far;{$endif}
  94. begin
  95. if (P<>pointer(Desktop^.Background)) and (P^.GetState(sfVisible)) then
  96. C^.Insert(P);
  97. end;
  98. begin
  99. C^.DeleteAll;
  100. Desktop^.ForEach(@AddIt);
  101. LB^.SetRange(C^.Count);
  102. ReDraw;
  103. end;
  104. procedure TWindowListDialog.HandleEvent(var Event: TEvent);
  105. begin
  106. case Event.What of
  107. evKeyDown :
  108. case Event.KeyCode of
  109. kbDel :
  110. begin
  111. Message(@Self,evCommand,cmDeleteItem,nil);
  112. ClearEvent(Event);
  113. end;
  114. end;
  115. evCommand :
  116. case Event.Command of
  117. cmDeleteItem :
  118. if C^.Count>0 then
  119. begin
  120. Message(C^.At(LB^.Focused),evCommand,cmClose,nil);
  121. UpdateList;
  122. ClearEvent(Event);
  123. end;
  124. cmOK :
  125. if C^.Count>0 then
  126. PView(C^.At(LB^.Focused))^.MakeFirst;
  127. end;
  128. end;
  129. inherited HandleEvent(Event);
  130. end;
  131. destructor TWindowListDialog.Done;
  132. begin
  133. if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
  134. inherited Done;
  135. end;
  136. procedure TIDEApp.WindowList;
  137. var W: PWindowListDialog;
  138. begin
  139. New(W,Init);
  140. ExecView(W);
  141. Dispose(W,Done);
  142. end;
  143. {
  144. $Log$
  145. Revision 1.14 2000-01-28 22:36:46 pierre
  146. * avoid unknown type in alt+0 dialog for Ascii Chart and Clipboard
  147. Revision 1.13 2000/01/10 00:24:18 pierre
  148. * register window type added
  149. Revision 1.12 1999/09/09 14:09:58 pierre
  150. + StackWindow is a known window type
  151. Revision 1.11 1999/07/10 01:24:20 pierre
  152. + First implementation of watches window
  153. Revision 1.10 1999/06/30 23:58:18 pierre
  154. + BreakpointsList Window implemented
  155. with Edit/New/Delete functions
  156. + Individual breakpoint dialog with support for all types
  157. ignorecount and conditions
  158. (commands are not yet implemented, don't know if this wolud be useful)
  159. awatch and rwatch have problems because GDB does not annotate them
  160. I fixed v4.16 for this
  161. Revision 1.9 1999/06/29 22:50:15 peter
  162. * more fixes from gabor
  163. Revision 1.8 1999/06/28 19:32:23 peter
  164. * fixes from gabor
  165. Revision 1.7 1999/03/01 15:42:00 peter
  166. + Added dummy entries for functions not yet implemented
  167. * MenuBar didn't update itself automatically on command-set changes
  168. * Fixed Debugging/Profiling options dialog
  169. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  170. set
  171. * efBackSpaceUnindents works correctly
  172. + 'Messages' window implemented
  173. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  174. + Added TP message-filter support (for ex. you can call GREP thru
  175. GREP2MSG and view the result in the messages window - just like in TP)
  176. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  177. so topic search didn't work...
  178. * In FPHELP.PAS there were still context-variables defined as word instead
  179. of THelpCtx
  180. * StdStatusKeys() was missing from the statusdef for help windows
  181. + Topic-title for index-table can be specified when adding a HTML-files
  182. Revision 1.6 1999/01/21 11:54:22 peter
  183. + tools menu
  184. + speedsearch in symbolbrowser
  185. * working run command
  186. Revision 1.5 1999/01/12 14:29:37 peter
  187. + Implemented still missing 'switch' entries in Options menu
  188. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  189. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  190. ASCII chars and inserted directly in the text.
  191. + Added symbol browser
  192. * splitted fp.pas to fpide.pas
  193. Revision 1.4 1999/01/04 11:49:49 peter
  194. * 'Use tab characters' now works correctly
  195. + Syntax highlight now acts on File|Save As...
  196. + Added a new class to syntax highlight: 'hex numbers'.
  197. * There was something very wrong with the palette managment. Now fixed.
  198. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  199. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  200. process revised
  201. Revision 1.3 1998/12/28 15:47:50 peter
  202. + Added user screen support, display & window
  203. + Implemented Editor,Mouse Options dialog
  204. + Added location of .INI and .CFG file
  205. + Option (INI) file managment implemented (see bottom of Options Menu)
  206. + Switches updated
  207. + Run program
  208. Revision 1.2 1998/12/23 22:58:19 peter
  209. * fixed windowlist for fpc
  210. Revision 1.1 1998/12/22 14:27:54 peter
  211. * moved
  212. Revision 1.3 1998/12/22 10:39:50 peter
  213. + options are now written/read
  214. + find and replace routines
  215. }