fpmwnd.inc 11 KB

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