fpmwnd.inc 12 KB

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