fpmwnd.inc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. procedure TIDEApp.ResizeApplication(x, y : longint);
  21. var
  22. OldR : TRect;
  23. Mode : TVideoMode;
  24. begin
  25. GetBounds(OldR);
  26. { adapt to new size }
  27. if (OldR.B.Y-OldR.A.Y<>y) or
  28. (OldR.B.X-OldR.A.X<>x) then
  29. begin
  30. Mode.color:=ScreenMode.Color;
  31. Mode.col:=x;
  32. Mode.row:=y;
  33. SetScreenVideoMode(Mode);
  34. Redraw;
  35. end;
  36. end;
  37. type
  38. PWindowListBox = ^TWindowListBox;
  39. TWindowListBox = object(TAdvancedListBox)
  40. constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
  41. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  42. end;
  43. PWindowListDialog = ^TWindowListDialog;
  44. TWindowListDialog = object(TCenterDialog)
  45. constructor Init;
  46. procedure HandleEvent(var Event: TEvent); virtual;
  47. destructor Done; virtual;
  48. private
  49. LB: PWindowListBox;
  50. C : PCollection;
  51. BtnShow,BtnHide: PNoUpdateButton;
  52. procedure UpdateList;
  53. procedure UpdateButtons;
  54. end;
  55. constructor TWindowListBox.Init(var Bounds: TRect; AScrollBar: PScrollBar);
  56. begin
  57. inherited Init(Bounds,1,AScrollBar);
  58. end;
  59. function TWindowListBox.GetText(Item,MaxLen: Sw_Integer): String;
  60. var P: PView;
  61. S: string;
  62. begin
  63. P:=List^.At(Item);
  64. case P^.HelpCtx of
  65. hcSourceWindow : S:=PSourceWindow(P)^.GetTitle(MaxLen);
  66. hcHelpWindow : S:=PHelpWindow(P)^.GetTitle(MaxLen);
  67. hcCalcWindow : S:=PCalculator(P)^.GetTitle(MaxLen);
  68. hcBrowserWindow: S:=PBrowserWindow(P)^.GetTitle(MaxLen);
  69. hcCompilerMessagesWindow,
  70. hcMessagesWindow:S:=PMessagesWindow(P)^.GetTitle(MaxLen);
  71. hcGDBWindow,
  72. hcDisassemblyWindow,
  73. hcWatchesWindow,
  74. hcStackWindow,
  75. hcRegistersWindow,
  76. hcFPURegisters,
  77. hcClipboardWindow,
  78. hcASCIITableWindow,
  79. hcUserScreenWindow,
  80. hcBreakpointListWindow :
  81. S:=PWindow(P)^.GetTitle(MaxLen);
  82. else S:='???? - '+PWindow(P)^.GetTitle(MaxLen);
  83. end;
  84. if PWindow(P)^.Number<>0 then
  85. S:=S+'('+IntToStr(PWindow(P)^.Number)+')';
  86. if P^.GetState(sfVisible) then S:=' '+S else
  87. begin
  88. S:='*'+S+' - '+msg_windowlist_hidden;
  89. end;
  90. GetText:=copy(S,1,MaxLen);
  91. end;
  92. constructor TWindowListDialog.Init;
  93. var R,R2: TRect;
  94. SB: PScrollBar;
  95. begin
  96. R.Assign(0,0,round(ScreenWidth*5/8),15);
  97. inherited Init(R, dialog_windowlist);
  98. HelpCtx:=hcWindowList;
  99. New(C, Init(20,10));
  100. GetExtent(R); R.Grow(-2,-2); Inc(R.A.Y); R.B.X:=R.B.X-13;
  101. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  102. New(SB, Init(R2)); Insert(SB);
  103. New(LB, Init(R, SB));
  104. LB^.Default:=true;
  105. LB^.NewList(C);
  106. UpdateList;
  107. if C^.Count>=2 then
  108. if PWindow(C^.At(1))^.GetState(sfVisible) then
  109. LB^.FocusItem(1); { focus the 2nd one }
  110. Insert(LB);
  111. R2.Copy(R); Dec(R2.A.Y); R2.B.Y:=R2.A.Y+1;
  112. Insert(New(PLabel, Init(R2, label_wndlist_windows, LB)));
  113. 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;
  114. Insert(New(PButton, Init(R, button_OK, cmOK, bfDefault)));
  115. R.Move(0,2);
  116. Insert(New(PButton, Init(R, button_Delete, cmDeleteItem, bfNormal)));
  117. R.Move(0,2);
  118. New(BtnShow, Init(R, button_Show, cmShowItem, bfNormal));
  119. Insert(BtnShow);
  120. R.Move(0,2);
  121. New(BtnHide, Init(R, button_Hide, cmHideItem, bfNormal));
  122. Insert(BtnHide);
  123. R.Move(0,2);
  124. Insert(New(PButton, Init(R, button_Cancel, cmCancel, bfNormal)));
  125. LB^.Select;
  126. PutCommand(@Self,evBroadcast,cmListFocusChanged,LB);
  127. end;
  128. procedure TWindowListDialog.UpdateList;
  129. var VisState: boolean;
  130. procedure AddIt(P: PView); {$ifndef FPC}far;{$endif}
  131. begin
  132. if (P<>pointer(Desktop^.Background)) and
  133. (P^.GetState(sfDisabled)=false) and
  134. ((P^.Options and ofSelectable)<>0) and
  135. (P^.GetState(sfVisible)=VisState) then
  136. C^.Insert(P);
  137. end;
  138. begin
  139. C^.DeleteAll;
  140. VisState:=true; Desktop^.ForEach(@AddIt); { add visible windows to list }
  141. VisState:=false; Desktop^.ForEach(@AddIt); { add hidden windows }
  142. LB^.SetRange(C^.Count);
  143. UpdateButtons;
  144. ReDraw;
  145. end;
  146. procedure TWindowListDialog.UpdateButtons;
  147. var W: PView;
  148. begin
  149. if LB^.Range>0 then
  150. begin
  151. W:=LB^.List^.At(LB^.Focused);
  152. if Assigned(BtnShow) then
  153. BtnShow^.SetState(sfDisabled,W^.GetState(sfVisible));
  154. if Assigned(BtnHide) then
  155. BtnHide^.SetState(sfDisabled,not W^.GetState(sfVisible));
  156. end
  157. else
  158. begin
  159. BtnShow^.SetState(sfDisabled,true);
  160. BtnHide^.SetState(sfDisabled,true);
  161. end;
  162. ReDraw;
  163. end;
  164. procedure TWindowListDialog.HandleEvent(var Event: TEvent);
  165. var W: PWindow;
  166. begin
  167. case Event.What of
  168. evKeyDown :
  169. case Event.KeyCode of
  170. kbDel :
  171. begin
  172. Message(@Self,evCommand,cmDeleteItem,nil);
  173. ClearEvent(Event);
  174. end;
  175. end;
  176. evBroadcast :
  177. case Event.Command of
  178. cmListFocusChanged :
  179. if Event.InfoPtr=LB then
  180. UpdateButtons;
  181. end;
  182. evCommand :
  183. case Event.Command of
  184. cmDeleteItem :
  185. if C^.Count>0 then
  186. begin
  187. Message(C^.At(LB^.Focused),evCommand,cmClose,nil);
  188. UpdateList;
  189. ClearEvent(Event);
  190. end;
  191. cmShowItem :
  192. if C^.Count>0 then
  193. begin
  194. PWindow(C^.At(LB^.Focused))^.Show;
  195. UpdateList;
  196. ClearEvent(Event);
  197. end;
  198. cmHideItem :
  199. if C^.Count>0 then
  200. begin
  201. PWindow(C^.At(LB^.Focused))^.Hide;
  202. UpdateList;
  203. ClearEvent(Event);
  204. end;
  205. cmOK :
  206. if C^.Count>0 then
  207. begin
  208. W:=PWindow(C^.At(LB^.Focused));
  209. if W^.GetState(sfVisible)=false then
  210. W^.Show;
  211. W^.MakeFirst;
  212. end;
  213. end;
  214. end;
  215. inherited HandleEvent(Event);
  216. end;
  217. destructor TWindowListDialog.Done;
  218. begin
  219. if C<>nil then begin C^.DeleteAll; Dispose(C, Done); end;
  220. inherited Done;
  221. end;
  222. procedure TIDEApp.WindowList;
  223. var W: PWindowListDialog;
  224. begin
  225. New(W,Init);
  226. ExecView(W);
  227. Dispose(W,Done);
  228. if assigned(Desktop^.Current) then
  229. begin
  230. Desktop^.Lock;
  231. { force correct commands to be enabled }
  232. Desktop^.Current^.SetState(sfActive,false);
  233. Desktop^.Current^.SetState(sfActive,true);
  234. Desktop^.UnLock;
  235. end;
  236. end;
  237. {
  238. $Log$
  239. Revision 1.6 2004-11-08 20:28:26 peter
  240. * Breakpoints are now deleted when removed from source, disabling is
  241. still possible from the breakpoint list
  242. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  243. FV and 1.9.x compilers
  244. * Run directory added to Run menu
  245. * Useless programinfo window removed
  246. Revision 1.5 2004/11/06 22:02:49 peter
  247. * fixed resize helptext
  248. Revision 1.4 2002/09/07 15:40:44 peter
  249. * old logs removed and tabs fixed
  250. Revision 1.3 2002/06/07 14:09:56 pierre
  251. * try to get resizing to work
  252. Revision 1.2 2002/05/30 15:03:24 pierre
  253. + ResizeApplication pethod for fvision
  254. }