fpmwnd.inc 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. BtnShow,BtnHide: PNoUpdateButton;
  35. procedure UpdateList;
  36. procedure UpdateButtons;
  37. end;
  38. constructor TWindowListBox.Init(var Bounds: TRect; AScrollBar: PScrollBar);
  39. begin
  40. inherited Init(Bounds,1,AScrollBar);
  41. end;
  42. function TWindowListBox.GetText(Item,MaxLen: Sw_Integer): String;
  43. var P: PView;
  44. S: string;
  45. begin
  46. P:=List^.At(Item);
  47. case P^.HelpCtx of
  48. hcSourceWindow : S:=PSourceWindow(P)^.GetTitle(MaxLen);
  49. hcInfoWindow : S:=PProgramInfoWindow(P)^.GetTitle(MaxLen);
  50. hcHelpWindow : S:=PHelpWindow(P)^.GetTitle(MaxLen);
  51. hcCalcWindow : S:=PCalculator(P)^.GetTitle(MaxLen);
  52. hcBrowserWindow: S:=PBrowserWindow(P)^.GetTitle(MaxLen);
  53. hcMessagesWindow:S:=PMessagesWindow(P)^.GetTitle(MaxLen);
  54. hcGDBWindow,
  55. hcWatches,
  56. hcStack,
  57. hcRegisters,
  58. hcClipboardWindow,
  59. hcASCIITableWindow,
  60. hcUserScreenWindow,
  61. hcBreakpointListWindow :
  62. S:=PWindow(P)^.GetTitle(MaxLen);
  63. else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
  64. end;
  65. if PWindow(P)^.Number<>0 then
  66. S:=S+'('+IntToStr(PWindow(P)^.Number)+')';
  67. if P^.GetState(sfVisible) then S:=' '+S else
  68. begin
  69. S:='*'+S+' - '+msg_windowlist_hidden;
  70. end;
  71. GetText:=copy(S,1,MaxLen);
  72. end;
  73. constructor TWindowListDialog.Init;
  74. var R,R2: TRect;
  75. SB: PScrollBar;
  76. begin
  77. R.Assign(0,0,round(ScreenWidth*5/8),15);
  78. inherited Init(R, dialog_windowlist);
  79. New(C, Init(20,10));
  80. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=R.B.X-13;
  81. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  82. New(SB, Init(R2)); Insert(SB);
  83. New(LB, Init(R, SB));
  84. LB^.Default:=true;
  85. LB^.NewList(C);
  86. UpdateList;
  87. if C^.Count>=2 then LB^.FocusItem(1); { focus the 2nd one }
  88. Insert(LB);
  89. R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
  90. Insert(New(PLabel, Init(R2, label_wndlist_windows, LB)));
  91. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.A.X:=R.B.X-13+1; R.B.Y:=R.A.Y+2;
  92. Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
  93. R.Move(0,2);
  94. Insert(New(PButton, Init(R, button_Delete, cmDeleteItem, bfNormal)));
  95. R.Move(0,2);
  96. New(BtnShow, Init(R, button_Show, cmShowItem, bfNormal));
  97. Insert(BtnShow);
  98. R.Move(0,2);
  99. New(BtnHide, Init(R, button_Hide, cmHideItem, bfNormal));
  100. Insert(BtnHide);
  101. R.Move(0,2);
  102. Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
  103. LB^.Select;
  104. PutCommand(@Self,evBroadcast,cmListFocusChanged,LB);
  105. end;
  106. procedure TWindowListDialog.UpdateList;
  107. procedure AddIt(P: PView); {$ifndef FPC}far;{$endif}
  108. begin
  109. if (P<>pointer(Desktop^.Background)) and
  110. (P^.GetState(sfDisabled)=false) and
  111. ((P^.Options and ofSelectable)<>0) {and
  112. (P^.GetState(sfVisible)) }then
  113. C^.Insert(P);
  114. end;
  115. begin
  116. C^.DeleteAll;
  117. Desktop^.ForEach(@AddIt);
  118. LB^.SetRange(C^.Count);
  119. UpdateButtons;
  120. ReDraw;
  121. end;
  122. procedure TWindowListDialog.UpdateButtons;
  123. var W: PView;
  124. begin
  125. if LB^.Range>0 then
  126. begin
  127. W:=LB^.List^.At(LB^.Focused);
  128. if Assigned(BtnShow) then
  129. BtnShow^.SetState(sfDisabled,W^.GetState(sfVisible));
  130. if Assigned(BtnHide) then
  131. BtnHide^.SetState(sfDisabled,not W^.GetState(sfVisible));
  132. end
  133. else
  134. begin
  135. BtnShow^.SetState(sfDisabled,true);
  136. BtnHide^.SetState(sfDisabled,true);
  137. end;
  138. ReDraw;
  139. end;
  140. procedure TWindowListDialog.HandleEvent(var Event: TEvent);
  141. var W: PWindow;
  142. begin
  143. case Event.What of
  144. evKeyDown :
  145. case Event.KeyCode of
  146. kbDel :
  147. begin
  148. Message(@Self,evCommand,cmDeleteItem,nil);
  149. ClearEvent(Event);
  150. end;
  151. end;
  152. evBroadcast :
  153. case Event.Command of
  154. cmListFocusChanged :
  155. if Event.InfoPtr=LB then
  156. UpdateButtons;
  157. end;
  158. evCommand :
  159. case Event.Command of
  160. cmDeleteItem :
  161. if C^.Count>0 then
  162. begin
  163. Message(C^.At(LB^.Focused),evCommand,cmClose,nil);
  164. UpdateList;
  165. ClearEvent(Event);
  166. end;
  167. cmShowItem :
  168. if C^.Count>0 then
  169. begin
  170. PWindow(C^.At(LB^.Focused))^.Show;
  171. UpdateList;
  172. ClearEvent(Event);
  173. end;
  174. cmHideItem :
  175. if C^.Count>0 then
  176. begin
  177. PWindow(C^.At(LB^.Focused))^.Hide;
  178. UpdateList;
  179. ClearEvent(Event);
  180. end;
  181. cmOK :
  182. if C^.Count>0 then
  183. begin
  184. W:=PWindow(C^.At(LB^.Focused));
  185. if W^.GetState(sfVisible)=false then
  186. W^.Show;
  187. W^.MakeFirst;
  188. end;
  189. end;
  190. end;
  191. inherited HandleEvent(Event);
  192. end;
  193. destructor TWindowListDialog.Done;
  194. begin
  195. if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
  196. inherited Done;
  197. end;
  198. procedure TIDEApp.WindowList;
  199. var W: PWindowListDialog;
  200. begin
  201. New(W,Init);
  202. ExecView(W);
  203. Dispose(W,Done);
  204. end;
  205. {
  206. $Log$
  207. Revision 1.1 2000-07-13 09:48:35 michael
  208. + Initial import
  209. Revision 1.18 2000/06/16 08:50:41 pierre
  210. + new bunch of Gabor's changes
  211. Revision 1.17 2000/05/02 08:42:28 pierre
  212. * new set of Gabor changes: see fixes.txt
  213. Revision 1.16 2000/04/18 11:42:37 pierre
  214. lot of Gabor changes : see fixes.txt
  215. Revision 1.15 2000/03/07 21:51:52 pierre
  216. * Reconginze UserScreenWindow
  217. Revision 1.14 2000/01/28 22:36:46 pierre
  218. * avoid unknown type in alt+0 dialog for Ascii Chart and Clipboard
  219. Revision 1.13 2000/01/10 00:24:18 pierre
  220. * register window type added
  221. Revision 1.12 1999/09/09 14:09:58 pierre
  222. + StackWindow is a known window type
  223. Revision 1.11 1999/07/10 01:24:20 pierre
  224. + First implementation of watches window
  225. Revision 1.10 1999/06/30 23:58:18 pierre
  226. + BreakpointsList Window implemented
  227. with Edit/New/Delete functions
  228. + Individual breakpoint dialog with support for all types
  229. ignorecount and conditions
  230. (commands are not yet implemented, don't know if this wolud be useful)
  231. awatch and rwatch have problems because GDB does not annotate them
  232. I fixed v4.16 for this
  233. Revision 1.9 1999/06/29 22:50:15 peter
  234. * more fixes from gabor
  235. Revision 1.8 1999/06/28 19:32:23 peter
  236. * fixes from gabor
  237. Revision 1.7 1999/03/01 15:42:00 peter
  238. + Added dummy entries for functions not yet implemented
  239. * MenuBar didn't update itself automatically on command-set changes
  240. * Fixed Debugging/Profiling options dialog
  241. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  242. set
  243. * efBackSpaceUnindents works correctly
  244. + 'Messages' window implemented
  245. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  246. + Added TP message-filter support (for ex. you can call GREP thru
  247. GREP2MSG and view the result in the messages window - just like in TP)
  248. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  249. so topic search didn't work...
  250. * In FPHELP.PAS there were still context-variables defined as word instead
  251. of THelpCtx
  252. * StdStatusKeys() was missing from the statusdef for help windows
  253. + Topic-title for index-table can be specified when adding a HTML-files
  254. Revision 1.6 1999/01/21 11:54:22 peter
  255. + tools menu
  256. + speedsearch in symbolbrowser
  257. * working run command
  258. Revision 1.5 1999/01/12 14:29:37 peter
  259. + Implemented still missing 'switch' entries in Options menu
  260. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  261. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  262. ASCII chars and inserted directly in the text.
  263. + Added symbol browser
  264. * splitted fp.pas to fpide.pas
  265. Revision 1.4 1999/01/04 11:49:49 peter
  266. * 'Use tab characters' now works correctly
  267. + Syntax highlight now acts on File|Save As...
  268. + Added a new class to syntax highlight: 'hex numbers'.
  269. * There was something very wrong with the palette managment. Now fixed.
  270. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  271. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  272. process revised
  273. Revision 1.3 1998/12/28 15:47:50 peter
  274. + Added user screen support, display & window
  275. + Implemented Editor,Mouse Options dialog
  276. + Added location of .INI and .CFG file
  277. + Option (INI) file managment implemented (see bottom of Options Menu)
  278. + Switches updated
  279. + Run program
  280. Revision 1.2 1998/12/23 22:58:19 peter
  281. * fixed windowlist for fpc
  282. Revision 1.1 1998/12/22 14:27:54 peter
  283. * moved
  284. Revision 1.3 1998/12/22 10:39:50 peter
  285. + options are now written/read
  286. + find and replace routines
  287. }