app.pas 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. { $Id$}
  2. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  3. { }
  4. { System independent GRAPHICAL clone of APP.PAS }
  5. { }
  6. { Interface Copyright (c) 1992 Borland International }
  7. { }
  8. { Copyright (c) 1996, 1997, 1998, 1999 by Leon de Boer }
  9. { [email protected] - primary e-mail addr }
  10. { [email protected] - backup e-mail addr }
  11. { }
  12. {****************[ THIS CODE IS FREEWARE ]*****************}
  13. { }
  14. { This sourcecode is released for the purpose to }
  15. { promote the pascal language on all platforms. You may }
  16. { redistribute it and/or modify with the following }
  17. { DISCLAIMER. }
  18. { }
  19. { This SOURCE CODE is distributed "AS IS" WITHOUT }
  20. { WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR }
  21. { ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
  22. { }
  23. {*****************[ SUPPORTED PLATFORMS ]******************}
  24. { }
  25. { Only Free Pascal Compiler supported }
  26. { }
  27. {**********************************************************}
  28. UNIT App;
  29. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  30. INTERFACE
  31. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  32. {====Include file to sort compiler platform out =====================}
  33. {$I Platform.inc}
  34. {====================================================================}
  35. {==== Compiler directives ===========================================}
  36. {$X+} { Extended syntax is ok }
  37. {$R-} { Disable range checking }
  38. {$S-} { Disable Stack Checking }
  39. {$I-} { Disable IO Checking }
  40. {$Q-} { Disable Overflow Checking }
  41. {$V-} { Turn off strict VAR strings }
  42. {====================================================================}
  43. USES
  44. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  45. Windows, { Standard units }
  46. {$ENDIF}
  47. {$IFDEF OS_OS2} { OS2 CODE }
  48. Os2Def, Os2Base, OS2PmApi, { Standard units }
  49. {$ENDIF}
  50. Dos,
  51. Video,
  52. GFVGraph, { GFV standard unit }
  53. FVCommon, Memory, { GFV standard units }
  54. Objects, Drivers, Views, Menus, HistList, Dialogs,
  55. MsgBox;
  56. {***************************************************************************}
  57. { PUBLIC CONSTANTS }
  58. {***************************************************************************}
  59. {---------------------------------------------------------------------------}
  60. { STANDARD APPLICATION COMMAND CONSTANTS }
  61. {---------------------------------------------------------------------------}
  62. CONST
  63. cmNew = 30; { Open new file }
  64. cmOpen = 31; { Open a file }
  65. cmSave = 32; { Save current }
  66. cmSaveAs = 33; { Save current as }
  67. cmSaveAll = 34; { Save all files }
  68. cmChangeDir = 35; { Change directories }
  69. cmDosShell = 36; { Dos shell }
  70. cmCloseAll = 37; { Close all windows }
  71. {---------------------------------------------------------------------------}
  72. { TApplication PALETTE ENTRIES }
  73. {---------------------------------------------------------------------------}
  74. CONST
  75. apColor = 0; { Coloured app }
  76. apBlackWhite = 1; { B&W application }
  77. apMonochrome = 2; { Monochrome app }
  78. {---------------------------------------------------------------------------}
  79. { TBackGround PALETTES }
  80. {---------------------------------------------------------------------------}
  81. CONST
  82. CBackground = #1; { Background colour }
  83. {---------------------------------------------------------------------------}
  84. { TApplication PALETTES }
  85. {---------------------------------------------------------------------------}
  86. CONST
  87. { Turbo Vision 1.0 Color Palettes }
  88. CColor =
  89. #$81#$70#$78#$74#$20#$28#$24#$17#$1F#$1A#$31#$31#$1E#$71#$1F +
  90. #$37#$3F#$3A#$13#$13#$3E#$21#$3F#$70#$7F#$7A#$13#$13#$70#$7F#$7E +
  91. #$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 +
  92. #$3F#$3E#$1F#$2F#$1A#$20#$72#$31#$31#$30#$2F#$3E#$31#$13#$38#$00;
  93. CBlackWhite =
  94. #$70#$70#$78#$7F#$07#$07#$0F#$07#$0F#$07#$70#$70#$07#$70#$0F +
  95. #$07#$0F#$07#$70#$70#$07#$70#$0F#$70#$7F#$7F#$70#$07#$70#$07#$0F +
  96. #$70#$7F#$7F#$70#$07#$70#$70#$7F#$7F#$07#$0F#$0F#$78#$0F#$78#$07 +
  97. #$0F#$0F#$0F#$70#$0F#$07#$70#$70#$70#$07#$70#$0F#$07#$07#$78#$00;
  98. CMonochrome =
  99. #$70#$07#$07#$0F#$70#$70#$70#$07#$0F#$07#$70#$70#$07#$70#$00 +
  100. #$07#$0F#$07#$70#$70#$07#$70#$00#$70#$70#$70#$07#$07#$70#$07#$00 +
  101. #$70#$70#$70#$07#$07#$70#$70#$70#$0F#$07#$07#$0F#$70#$0F#$70#$07 +
  102. #$0F#$0F#$07#$70#$07#$07#$70#$07#$07#$07#$70#$0F#$07#$07#$70#$00;
  103. { Turbo Vision 2.0 Color Palettes }
  104. CAppColor =
  105. #$71#$70#$78#$74#$20#$28#$24#$17#$1F#$1A#$31#$31#$1E#$71#$1F +
  106. #$37#$3F#$3A#$13#$13#$3E#$21#$3F#$70#$7F#$7A#$13#$13#$70#$7F#$7E +
  107. #$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E#$20#$2B#$2F#$78#$2E#$70#$30 +
  108. #$3F#$3E#$1F#$2F#$1A#$20#$72#$31#$31#$30#$2F#$3E#$31#$13#$38#$00 +
  109. #$17#$1F#$1A#$71#$71#$1E#$17#$1F#$1E#$20#$2B#$2F#$78#$2E#$10#$30 +
  110. #$3F#$3E#$70#$2F#$7A#$20#$12#$31#$31#$30#$2F#$3E#$31#$13#$38#$00 +
  111. #$37#$3F#$3A#$13#$13#$3E#$30#$3F#$3E#$20#$2B#$2F#$78#$2E#$30#$70 +
  112. #$7F#$7E#$1F#$2F#$1A#$20#$32#$31#$71#$70#$2F#$7E#$71#$13#$38#$00;
  113. CAppBlackWhite =
  114. #$70#$70#$78#$7F#$07#$07#$0F#$07#$0F#$07#$70#$70#$07#$70#$0F +
  115. #$07#$0F#$07#$70#$70#$07#$70#$0F#$70#$7F#$7F#$70#$07#$70#$07#$0F +
  116. #$70#$7F#$7F#$70#$07#$70#$70#$7F#$7F#$07#$0F#$0F#$78#$0F#$78#$07 +
  117. #$0F#$0F#$0F#$70#$0F#$07#$70#$70#$70#$07#$70#$0F#$07#$07#$78#$00 +
  118. #$07#$0F#$0F#$07#$70#$07#$07#$0F#$0F#$70#$78#$7F#$08#$7F#$08#$70 +
  119. #$7F#$7F#$7F#$0F#$70#$70#$07#$70#$70#$70#$07#$7F#$70#$07#$78#$00 +
  120. #$70#$7F#$7F#$70#$07#$70#$70#$7F#$7F#$07#$0F#$0F#$78#$0F#$78#$07 +
  121. #$0F#$0F#$0F#$70#$0F#$07#$70#$70#$70#$07#$70#$0F#$07#$07#$78#$00;
  122. CAppMonochrome =
  123. #$70#$07#$07#$0F#$70#$70#$70#$07#$0F#$07#$70#$70#$07#$70#$00 +
  124. #$07#$0F#$07#$70#$70#$07#$70#$00#$70#$70#$70#$07#$07#$70#$07#$00 +
  125. #$70#$70#$70#$07#$07#$70#$70#$70#$0F#$07#$07#$0F#$70#$0F#$70#$07 +
  126. #$0F#$0F#$07#$70#$07#$07#$70#$07#$07#$07#$70#$0F#$07#$07#$70#$00 +
  127. #$70#$70#$70#$07#$07#$70#$70#$70#$0F#$07#$07#$0F#$70#$0F#$70#$07 +
  128. #$0F#$0F#$07#$70#$07#$07#$70#$07#$07#$07#$70#$0F#$07#$07#$70#$00 +
  129. #$70#$70#$70#$07#$07#$70#$70#$70#$0F#$07#$07#$0F#$70#$0F#$70#$07 +
  130. #$0F#$0F#$07#$70#$07#$07#$70#$07#$07#$07#$70#$0F#$07#$07#$70#$00;
  131. {---------------------------------------------------------------------------}
  132. { STANDRARD HELP CONTEXT CONSTANTS }
  133. {---------------------------------------------------------------------------}
  134. CONST
  135. { Note: range $FF00 - $FFFF of help contexts are reserved by Borland }
  136. hcNew = $FF01; { New file help }
  137. hcOpen = $FF02; { Open file help }
  138. hcSave = $FF03; { Save file help }
  139. hcSaveAs = $FF04; { Save file as help }
  140. hcSaveAll = $FF05; { Save all files help }
  141. hcChangeDir = $FF06; { Change dir help }
  142. hcDosShell = $FF07; { Dos shell help }
  143. hcExit = $FF08; { Exit program help }
  144. hcUndo = $FF10; { Clipboard undo help }
  145. hcCut = $FF11; { Clipboard cut help }
  146. hcCopy = $FF12; { Clipboard copy help }
  147. hcPaste = $FF13; { Clipboard paste help }
  148. hcClear = $FF14; { Clipboard clear help }
  149. hcTile = $FF20; { Desktop tile help }
  150. hcCascade = $FF21; { Desktop cascade help }
  151. hcCloseAll = $FF22; { Desktop close all }
  152. hcResize = $FF23; { Window resize help }
  153. hcZoom = $FF24; { Window zoom help }
  154. hcNext = $FF25; { Window next help }
  155. hcPrev = $FF26; { Window previous help }
  156. hcClose = $FF27; { Window close help }
  157. {***************************************************************************}
  158. { PUBLIC OBJECT DEFINITIONS }
  159. {***************************************************************************}
  160. {---------------------------------------------------------------------------}
  161. { TBackGround OBJECT - BACKGROUND OBJECT }
  162. {---------------------------------------------------------------------------}
  163. TYPE
  164. TBackGround = OBJECT (TView)
  165. Pattern: Char; { Background pattern }
  166. CONSTRUCTOR Init (Var Bounds: TRect; APattern: Char);
  167. CONSTRUCTOR Load (Var S: TStream);
  168. FUNCTION GetPalette: PPalette; Virtual;
  169. PROCEDURE DrawBackGround; Virtual;
  170. PROCEDURE Store (Var S: TStream);
  171. END;
  172. PBackGround = ^TBackGround;
  173. {---------------------------------------------------------------------------}
  174. { TDeskTop OBJECT - DESKTOP OBJECT }
  175. {---------------------------------------------------------------------------}
  176. TYPE
  177. TDeskTop = OBJECT (TGroup)
  178. Background : PBackground; { Background view }
  179. TileColumnsFirst: Boolean; { Tile direction }
  180. CONSTRUCTOR Init (Var Bounds: TRect);
  181. CONSTRUCTOR Load (Var S: TStream);
  182. PROCEDURE TileError; Virtual;
  183. PROCEDURE InitBackGround; Virtual;
  184. PROCEDURE Tile (Var R: TRect);
  185. PROCEDURE Store (Var S: TStream);
  186. PROCEDURE Cascade (Var R: TRect);
  187. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  188. END;
  189. PDeskTop = ^TDeskTop;
  190. {---------------------------------------------------------------------------}
  191. { TProgram OBJECT - PROGRAM ANCESTOR OBJECT }
  192. {---------------------------------------------------------------------------}
  193. TYPE
  194. TProgram = OBJECT (TGroup)
  195. CONSTRUCTOR Init;
  196. DESTRUCTOR Done; Virtual;
  197. FUNCTION GetPalette: PPalette; Virtual;
  198. FUNCTION CanMoveFocus: Boolean;
  199. FUNCTION ValidView (P: PView): PView;
  200. FUNCTION InsertWindow (P: PWindow): PWindow;
  201. FUNCTION ExecuteDialog (P: PDialog; Data: Pointer): Word;
  202. PROCEDURE Run; Virtual;
  203. PROCEDURE Idle; Virtual;
  204. PROCEDURE InitScreen; Virtual;
  205. procedure DoneScreen; virtual;
  206. PROCEDURE InitDeskTop; Virtual;
  207. PROCEDURE OutOfMemory; Virtual;
  208. PROCEDURE InitMenuBar; Virtual;
  209. PROCEDURE InitStatusLine; Virtual;
  210. PROCEDURE SetScreenMode (Mode: Word);
  211. PROCEDURE SetScreenVideoMode(const Mode: TVideoMode);
  212. PROCEDURE PutEvent (Var Event: TEvent); Virtual;
  213. PROCEDURE GetEvent (Var Event: TEvent); Virtual;
  214. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  215. END;
  216. PProgram = ^TProgram;
  217. {---------------------------------------------------------------------------}
  218. { TApplication OBJECT - APPLICATION OBJECT }
  219. {---------------------------------------------------------------------------}
  220. TYPE
  221. TApplication = OBJECT (TProgram)
  222. CONSTRUCTOR Init;
  223. DESTRUCTOR Done; Virtual;
  224. PROCEDURE Tile;
  225. PROCEDURE Cascade;
  226. PROCEDURE DosShell;
  227. PROCEDURE GetTileRect (Var R: TRect); Virtual;
  228. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  229. procedure WriteShellMsg; virtual;
  230. END;
  231. PApplication = ^TApplication; { Application ptr }
  232. {***************************************************************************}
  233. { INTERFACE ROUTINES }
  234. {***************************************************************************}
  235. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  236. { STANDARD MENU AND STATUS LINES ROUTINES }
  237. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  238. {-StdStatusKeys------------------------------------------------------
  239. Returns a pointer to a linked list of commonly used status line keys.
  240. The default status line for TApplication uses StdStatusKeys as its
  241. complete list of status keys.
  242. 22Oct99 LdB
  243. ---------------------------------------------------------------------}
  244. FUNCTION StdStatusKeys (Next: PStatusItem): PStatusItem;
  245. {-StdFileMenuItems---------------------------------------------------
  246. Returns a pointer to a list of menu items for a standard File menu.
  247. The standard File menu items are New, Open, Save, Save As, Save All,
  248. Change Dir, OS Shell, and Exit.
  249. 22Oct99 LdB
  250. ---------------------------------------------------------------------}
  251. FUNCTION StdFileMenuItems (Next: PMenuItem): PMenuItem;
  252. {-StdEditMenuItems---------------------------------------------------
  253. Returns a pointer to a list of menu items for a standard Edit menu.
  254. The standard Edit menu items are Undo, Cut, Copy, Paste, and Clear.
  255. 22Oct99 LdB
  256. ---------------------------------------------------------------------}
  257. FUNCTION StdEditMenuItems (Next: PMenuItem): PMenuItem;
  258. {-StdWindowMenuItems-------------------------------------------------
  259. Returns a pointer to a list of menu items for a standard Window menu.
  260. The standard Window menu items are Tile, Cascade, Close All,
  261. Size/Move, Zoom, Next, Previous, and Close.
  262. 22Oct99 LdB
  263. ---------------------------------------------------------------------}
  264. FUNCTION StdWindowMenuItems (Next: PMenuItem): PMenuItem;
  265. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  266. { OBJECT REGISTER ROUTINES }
  267. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  268. {-RegisterApp--------------------------------------------------------
  269. Calls RegisterType for each of the object types defined in this unit.
  270. 22oct99 LdB
  271. ---------------------------------------------------------------------}
  272. PROCEDURE RegisterApp;
  273. {***************************************************************************}
  274. { OBJECT REGISTRATION }
  275. {***************************************************************************}
  276. {---------------------------------------------------------------------------}
  277. { TBackGround STREAM REGISTRATION }
  278. {---------------------------------------------------------------------------}
  279. CONST
  280. RBackGround: TStreamRec = (
  281. ObjType: 30; { Register id = 30 }
  282. VmtLink: TypeOf(TBackGround);
  283. Load: @TBackGround.Load; { Object load method }
  284. Store: @TBackGround.Store { Object store method }
  285. );
  286. {---------------------------------------------------------------------------}
  287. { TDeskTop STREAM REGISTRATION }
  288. {---------------------------------------------------------------------------}
  289. CONST
  290. RDeskTop: TStreamRec = (
  291. ObjType: 31; { Register id = 31 }
  292. VmtLink: TypeOf(TDeskTop);
  293. Load: @TDeskTop.Load; { Object load method }
  294. Store: @TDeskTop.Store { Object store method }
  295. );
  296. {***************************************************************************}
  297. { INITIALIZED PUBLIC VARIABLES }
  298. {***************************************************************************}
  299. {---------------------------------------------------------------------------}
  300. { INITIALIZED PUBLIC VARIABLES }
  301. {---------------------------------------------------------------------------}
  302. CONST
  303. AppPalette: Integer = apColor; { Application colour }
  304. Desktop: PDeskTop = Nil; { Desktop object }
  305. MenuBar: PMenuView = Nil; { Application menu }
  306. StatusLine: PStatusLine = Nil; { App status line }
  307. Application : PApplication = Nil; { Application object }
  308. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  309. IMPLEMENTATION
  310. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  311. uses
  312. Mouse,Resource;
  313. {***************************************************************************}
  314. { PRIVATE DEFINED CONSTANTS }
  315. {***************************************************************************}
  316. {***************************************************************************}
  317. { PRIVATE INITIALIZED VARIABLES }
  318. {***************************************************************************}
  319. {---------------------------------------------------------------------------}
  320. { INITIALIZED PRIVATE VARIABLES }
  321. {---------------------------------------------------------------------------}
  322. CONST Pending: TEvent = (What: evNothing); { Pending event }
  323. {---------------------------------------------------------------------------}
  324. { Tileable -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  325. {---------------------------------------------------------------------------}
  326. FUNCTION Tileable (P: PView): Boolean;
  327. BEGIN
  328. Tileable := (P^.Options AND ofTileable <> 0) AND { View is tileable }
  329. (P^.State AND sfVisible <> 0); { View is visible }
  330. END;
  331. {---------------------------------------------------------------------------}
  332. { ISqr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  333. {---------------------------------------------------------------------------}
  334. FUNCTION ISqr (X: Sw_Integer): Sw_Integer;
  335. VAR I: Sw_Integer;
  336. BEGIN
  337. I := 0; { Set value to zero }
  338. Repeat
  339. Inc(I); { Inc value }
  340. Until (I * I > X); { Repeat till Sqr > X }
  341. ISqr := I - 1; { Return result }
  342. END;
  343. {---------------------------------------------------------------------------}
  344. { MostEqualDivisors -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  345. {---------------------------------------------------------------------------}
  346. PROCEDURE MostEqualDivisors (N: Integer; Var X, Y: Integer; FavorY: Boolean);
  347. VAR I: Integer;
  348. BEGIN
  349. I := ISqr(N); { Int square of N }
  350. If ((N MOD I) <> 0) Then { Initial guess }
  351. If ((N MOD (I+1)) = 0) Then Inc(I); { Add one row/column }
  352. If (I < (N DIV I)) Then I := N DIV I; { In first page }
  353. If FavorY Then Begin { Horz preferred }
  354. X := N DIV I; { Calc x position }
  355. Y := I; { Set y position }
  356. End Else Begin { Vert preferred }
  357. Y := N DIV I; { Calc y position }
  358. X := I; { Set x position }
  359. End;
  360. END;
  361. {***************************************************************************}
  362. { OBJECT METHODS }
  363. {***************************************************************************}
  364. {--TBackGround--------------------------------------------------------------}
  365. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  366. {---------------------------------------------------------------------------}
  367. CONSTRUCTOR TBackGround.Init (Var Bounds: TRect; APattern: Char);
  368. BEGIN
  369. Inherited Init(Bounds); { Call ancestor }
  370. GrowMode := gfGrowHiX + gfGrowHiY; { Set grow modes }
  371. Pattern := APattern; { Hold pattern }
  372. END;
  373. {--TBackGround--------------------------------------------------------------}
  374. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  375. {---------------------------------------------------------------------------}
  376. CONSTRUCTOR TBackGround.Load (Var S: TStream);
  377. BEGIN
  378. Inherited Load(S); { Call ancestor }
  379. S.Read(Pattern, SizeOf(Pattern)); { Read pattern data }
  380. END;
  381. {--TBackGround--------------------------------------------------------------}
  382. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  383. {---------------------------------------------------------------------------}
  384. FUNCTION TBackGround.GetPalette: PPalette;
  385. CONST P: String[Length(CBackGround)] = CbackGround; { Always normal string }
  386. BEGIN
  387. GetPalette := @P; { Return palette }
  388. END;
  389. {--TBackGround--------------------------------------------------------------}
  390. { DrawBackground -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  391. {---------------------------------------------------------------------------}
  392. PROCEDURE TBackground.DrawBackground;
  393. VAR B: TDrawBuffer;
  394. BEGIN
  395. MoveChar(B, Pattern, GetColor($01), Size.X); { Fill draw buffer }
  396. WriteLine(0, 0, Size.X, Size.Y, B); { Draw to area }
  397. END;
  398. {--TBackGround--------------------------------------------------------------}
  399. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  400. {---------------------------------------------------------------------------}
  401. PROCEDURE TBackGround.Store (Var S: TStream);
  402. BEGIN
  403. TView.Store(S); { TView store called }
  404. S.Write(Pattern, SizeOf(Pattern)); { Write pattern data }
  405. END;
  406. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  407. { TDesktop OBJECT METHODS }
  408. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  409. {--TDesktop-----------------------------------------------------------------}
  410. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  411. {---------------------------------------------------------------------------}
  412. CONSTRUCTOR TDesktop.Init (Var Bounds: Objects.TRect);
  413. BEGIN
  414. Inherited Init(Bounds); { Call ancestor }
  415. GrowMode := gfGrowHiX + gfGrowHiY; { Set growmode }
  416. InitBackground; { Create background }
  417. If (Background <> Nil) Then Insert(Background); { Insert background }
  418. END;
  419. {--TDesktop-----------------------------------------------------------------}
  420. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  421. {---------------------------------------------------------------------------}
  422. CONSTRUCTOR TDesktop.Load (Var S: TStream);
  423. BEGIN
  424. Inherited Load(S); { Call ancestor }
  425. GetSubViewPtr(S, Background); { Load background }
  426. S.Read(TileColumnsFirst, SizeOf(TileColumnsFirst));{ Read data }
  427. END;
  428. {--TDesktop-----------------------------------------------------------------}
  429. { TileError -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  430. {---------------------------------------------------------------------------}
  431. PROCEDURE TDeskTop.TileError;
  432. BEGIN { Abstract method }
  433. END;
  434. {--TDesktop-----------------------------------------------------------------}
  435. { InitBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  436. {---------------------------------------------------------------------------}
  437. PROCEDURE TDesktop.InitBackground;
  438. CONST Ch: Char = #176;
  439. VAR R: TRect;
  440. BEGIN
  441. GetExtent(R); { Get desktop extents }
  442. BackGround := New(PBackground, Init(R, Ch)); { Insert a background }
  443. END;
  444. {--TDesktop-----------------------------------------------------------------}
  445. { Tile -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  446. {---------------------------------------------------------------------------}
  447. PROCEDURE TDeskTop.Tile (Var R: TRect);
  448. VAR NumCols, NumRows, NumTileable, LeftOver, TileNum: Integer;
  449. FUNCTION DividerLoc (Lo, Hi, Num, Pos: Integer): Integer;
  450. BEGIN
  451. DividerLoc := LongInt( LongInt(Hi - Lo) * Pos)
  452. DIV Num + Lo; { Calc position }
  453. END;
  454. PROCEDURE DoCountTileable (P: PView); FAR;
  455. BEGIN
  456. If Tileable(P) Then Inc(NumTileable); { Count tileable views }
  457. END;
  458. PROCEDURE CalcTileRect (Pos: Integer; Var NR: TRect);
  459. VAR X, Y, D: Integer;
  460. BEGIN
  461. D := (NumCols - LeftOver) * NumRows; { Calc d value }
  462. If (Pos<D) Then Begin
  463. X := Pos DIV NumRows; Y := Pos MOD NumRows; { Calc positions }
  464. End Else Begin
  465. X := (Pos - D) div (NumRows + 1) +
  466. (NumCols - LeftOver); { Calc x position }
  467. Y := (Pos - D) mod (NumRows + 1); { Calc y position }
  468. End;
  469. NR.A.X := DividerLoc(R.A.X, R.B.X, NumCols, X); { Top left x position }
  470. NR.B.X := DividerLoc(R.A.X, R.B.X, NumCols, X+1);{ Right x position }
  471. If (Pos >= D) Then Begin
  472. NR.A.Y := DividerLoc(R.A.Y, R.B.Y,NumRows+1,Y);{ Top y position }
  473. NR.B.Y := DividerLoc(R.A.Y, R.B.Y, NumRows+1,
  474. Y+1); { Bottom y position }
  475. End Else Begin
  476. NR.A.Y := DividerLoc(R.A.Y, R.B.Y,NumRows,Y); { Top y position }
  477. NR.B.Y := DividerLoc(R.A.Y, R.B.Y, NumRows,
  478. Y+1); { Bottom y position }
  479. End;
  480. END;
  481. PROCEDURE DoTile(P: PView); FAR;
  482. VAR PState: Word; R: TRect;
  483. BEGIN
  484. If Tileable(P) Then Begin
  485. CalcTileRect(TileNum, R); { Calc tileable area }
  486. PState := P^.State; { Hold view state }
  487. P^.State := P^.State AND NOT sfVisible; { Temp not visible }
  488. P^.Locate(R); { Locate view }
  489. P^.State := PState; { Restore view state }
  490. Dec(TileNum); { One less to tile }
  491. End;
  492. END;
  493. BEGIN
  494. NumTileable := 0; { Zero tileable count }
  495. ForEach(@DoCountTileable); { Count tileable views }
  496. If (NumTileable>0) Then Begin
  497. MostEqualDivisors(NumTileable, NumCols, NumRows,
  498. NOT TileColumnsFirst); { Do pre calcs }
  499. If ((R.B.X - R.A.X) DIV NumCols = 0) OR
  500. ((R.B.Y - R.A.Y) DIV NumRows = 0) Then TileError { Can't tile }
  501. Else Begin
  502. LeftOver := NumTileable MOD NumCols; { Left over count }
  503. TileNum := NumTileable-1; { Tileable views }
  504. ForEach(@DoTile); { Tile each view }
  505. DrawView; { Now redraw }
  506. End;
  507. End;
  508. END;
  509. {--TDesktop-----------------------------------------------------------------}
  510. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  511. {---------------------------------------------------------------------------}
  512. PROCEDURE TDesktop.Store (Var S: TStream);
  513. BEGIN
  514. TGroup.Store(S); { Call group store }
  515. PutSubViewPtr(S, Background); { Store background }
  516. S.Write(TileColumnsFirst,SizeOf(TileColumnsFirst));{ Write data }
  517. END;
  518. {--TDesktop-----------------------------------------------------------------}
  519. { Cascade -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  520. {---------------------------------------------------------------------------}
  521. PROCEDURE TDeskTop.Cascade (Var R: TRect);
  522. VAR CascadeNum: Integer; LastView: PView; Min, Max: TPoint;
  523. PROCEDURE DoCount (P: PView); FAR;
  524. BEGIN
  525. If Tileable(P) Then Begin
  526. Inc(CascadeNum); LastView := P; { Count cascadable }
  527. End;
  528. END;
  529. PROCEDURE DoCascade (P: PView); FAR;
  530. VAR PState: Word; NR: TRect;
  531. BEGIN
  532. If Tileable(P) AND (CascadeNum >= 0) Then Begin { View cascadable }
  533. NR.Copy(R); { Copy rect area }
  534. Inc(NR.A.X, CascadeNum); { Inc x position }
  535. Inc(NR.A.Y, CascadeNum); { Inc y position }
  536. PState := P^.State; { Hold view state }
  537. P^.State := P^.State AND NOT sfVisible; { Temp stop draw }
  538. P^.Locate(NR); { Locate the view }
  539. P^.State := PState; { Now allow draws }
  540. Dec(CascadeNum); { Dec count }
  541. End;
  542. END;
  543. BEGIN
  544. CascadeNum := 0; { Zero cascade count }
  545. ForEach(@DoCount); { Count cascadable }
  546. If (CascadeNum>0) Then Begin
  547. LastView^.SizeLimits(Min, Max); { Check size limits }
  548. If (Min.X > R.B.X - R.A.X - CascadeNum) OR
  549. (Min.Y > R.B.Y - R.A.Y - CascadeNum) Then
  550. TileError Else Begin { Check for error }
  551. Dec(CascadeNum); { One less view }
  552. ForEach(@DoCascade); { Cascade view }
  553. DrawView; { Redraw now }
  554. End;
  555. End;
  556. END;
  557. {--TDesktop-----------------------------------------------------------------}
  558. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11May98 LdB }
  559. {---------------------------------------------------------------------------}
  560. PROCEDURE TDesktop.HandleEvent (Var Event: TEvent);
  561. BEGIN
  562. Inherited HandleEvent(Event); { Call ancestor }
  563. If (Event.What = evCommand) Then Begin
  564. Case Event.Command of { Command event }
  565. cmNext: FocusNext(False); { Focus next view }
  566. cmPrev: If (BackGround <> Nil) Then Begin
  567. If Valid(cmReleasedFocus) Then
  568. Current^.PutInFrontOf(Background); { Focus last view }
  569. End Else FocusNext(True); { Focus prior view }
  570. Else Exit;
  571. End;
  572. ClearEvent(Event); { Clear the event }
  573. End;
  574. END;
  575. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  576. { TProgram OBJECT METHODS }
  577. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  578. {--TProgram-----------------------------------------------------------------}
  579. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  580. {---------------------------------------------------------------------------}
  581. CONSTRUCTOR TProgram.Init;
  582. VAR I: Integer; R: TRect;
  583. BEGIN
  584. R.Assign(0, 0, -(GetMaxX(TextModeGFV)+1),
  585. -(GetMaxY(TextModeGFV)+1)); { Full screen area }
  586. Inherited Init(R); { Call ancestor }
  587. Application := @Self; { Set application ptr }
  588. Drivers.InitVideo;
  589. InitScreen; { Initialize screen }
  590. State := sfVisible + sfSelected + sfFocused +
  591. sfModal + sfExposed; { Deafult states }
  592. Options := 0; { No options set }
  593. Size.X := ScreenWidth; { Set x size value }
  594. Size.Y := ScreenHeight; { Set y size value }
  595. RawSize.X := ScreenWidth * SysFontWidth - 1; { Set rawsize x }
  596. RawSize.Y := ScreenHeight * SysFontHeight - 1; { Set rawsize y }
  597. InitDesktop; { Create desktop }
  598. InitStatusLine; { Create status line }
  599. InitMenuBar; { Create a bar menu }
  600. If (Desktop <> Nil) Then Insert(Desktop); { Insert desktop }
  601. If (StatusLine <> Nil) Then Insert(StatusLine); { Insert status line }
  602. If (MenuBar <> Nil) Then Insert(MenuBar); { Insert menu bar }
  603. END;
  604. {--TProgram-----------------------------------------------------------------}
  605. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  606. {---------------------------------------------------------------------------}
  607. DESTRUCTOR TProgram.Done;
  608. VAR I: Integer;
  609. BEGIN
  610. { Do not free the Buffer of Video Unit }
  611. If Buffer = Views.PVideoBuf(VideoBuf) then
  612. Buffer:=nil;
  613. If (Desktop <> Nil) Then Dispose(Desktop, Done); { Destroy desktop }
  614. If (MenuBar <> Nil) Then Dispose(MenuBar, Done); { Destroy menu bar }
  615. If (StatusLine <> Nil) Then
  616. Dispose(StatusLine, Done); { Destroy status line }
  617. Application := Nil; { Clear application }
  618. Inherited Done; { Call ancestor }
  619. END;
  620. {--TProgram-----------------------------------------------------------------}
  621. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  622. {---------------------------------------------------------------------------}
  623. FUNCTION TProgram.GetPalette: PPalette;
  624. CONST P: Array[apColor..apMonochrome] Of String = (CAppColor, CAppBlackWhite,
  625. CAppMonochrome);
  626. BEGIN
  627. GetPalette := @P[AppPalette]; { Return palette }
  628. END;
  629. {--TProgram-----------------------------------------------------------------}
  630. { CanMoveFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep97 LdB }
  631. {---------------------------------------------------------------------------}
  632. FUNCTION TProgram.CanMoveFocus: Boolean;
  633. BEGIN
  634. If (Desktop <> Nil) Then { Valid desktop view }
  635. CanMovefocus := DeskTop^.Valid(cmReleasedFocus) { Check focus move }
  636. Else CanMoveFocus := True; { No desktop who cares! }
  637. END;
  638. {--TProgram-----------------------------------------------------------------}
  639. { ValidView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  640. {---------------------------------------------------------------------------}
  641. FUNCTION TProgram.ValidView (P: PView): PView;
  642. BEGIN
  643. ValidView := Nil; { Preset failure }
  644. If (P <> Nil) Then Begin
  645. If LowMemory Then Begin { Check memroy }
  646. Dispose(P, Done); { Dispose view }
  647. OutOfMemory; { Call out of memory }
  648. Exit; { Now exit }
  649. End;
  650. If NOT P^.Valid(cmValid) Then Begin { Check view valid }
  651. Dispose(P, Done); { Dipose view }
  652. Exit; { Now exit }
  653. End;
  654. ValidView := P; { Return view }
  655. End;
  656. END;
  657. {--TProgram-----------------------------------------------------------------}
  658. { InsertWindow -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  659. {---------------------------------------------------------------------------}
  660. FUNCTION TProgram.InsertWindow (P: PWindow): PWindow;
  661. BEGIN
  662. InsertWindow := Nil; { Preset failure }
  663. If (ValidView(P) <> Nil) Then { Check view valid }
  664. If (CanMoveFocus) AND (Desktop <> Nil) { Can we move focus }
  665. Then Begin
  666. Desktop^.Insert(P); { Insert window }
  667. InsertWindow := P; { Return view ptr }
  668. End Else Dispose(P, Done); { Dispose view }
  669. END;
  670. {--TProgram-----------------------------------------------------------------}
  671. { ExecuteDialog -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  672. {---------------------------------------------------------------------------}
  673. FUNCTION TProgram.ExecuteDialog (P: PDialog; Data: Pointer): Word;
  674. VAR ExecResult: Word;
  675. BEGIN
  676. ExecuteDialog := cmCancel; { Preset cancel }
  677. If (ValidView(P) <> Nil) Then Begin { Check view valid }
  678. If (Data <> Nil) Then P^.SetData(Data^); { Set data }
  679. If (P <> Nil) Then P^.SelectDefaultView; { Select default }
  680. ExecResult := Desktop^.ExecView(P); { Execute view }
  681. If (ExecResult <> cmCancel) AND (Data <> Nil)
  682. Then P^.GetData(Data^); { Get data back }
  683. Dispose(P, Done); { Dispose of dialog }
  684. ExecuteDialog := ExecResult; { Return result }
  685. End;
  686. END;
  687. {--TProgram-----------------------------------------------------------------}
  688. { Run -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  689. {---------------------------------------------------------------------------}
  690. PROCEDURE TProgram.Run;
  691. BEGIN
  692. Execute; { Call execute }
  693. END;
  694. {--TProgram-----------------------------------------------------------------}
  695. { Idle -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Oct99 LdB }
  696. {---------------------------------------------------------------------------}
  697. PROCEDURE TProgram.Idle;
  698. BEGIN
  699. If (StatusLine <> Nil) Then StatusLine^.Update; { Update statusline }
  700. If CommandSetChanged Then Begin { Check command change }
  701. Message(@Self, evBroadcast, cmCommandSetChanged,
  702. Nil); { Send message }
  703. CommandSetChanged := False; { Clear flag }
  704. End;
  705. END;
  706. {--TProgram-----------------------------------------------------------------}
  707. { InitScreen -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  708. {---------------------------------------------------------------------------}
  709. PROCEDURE TProgram.InitScreen;
  710. BEGIN
  711. { the orginal code can't be used here because of the limited
  712. video unit capabilities, the mono modus can't be handled
  713. }
  714. if (ScreenMode.Col div ScreenMode.Row<2) then
  715. ShadowSize.X := 1
  716. else
  717. ShadowSize.X := 2;
  718. ShadowSize.Y := 1;
  719. ShowMarkers := False;
  720. if ScreenMode.color then
  721. AppPalette := apColor
  722. else
  723. AppPalette := apBlackWhite;
  724. Buffer := Views.PVideoBuf(VideoBuf);
  725. END;
  726. procedure TProgram.DoneScreen;
  727. begin
  728. DoneVideo;
  729. Buffer:=nil;
  730. end;
  731. {--TProgram-----------------------------------------------------------------}
  732. { InitDeskTop -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  733. {---------------------------------------------------------------------------}
  734. PROCEDURE TProgram.InitDesktop;
  735. VAR R: TRect;
  736. BEGIN
  737. GetExtent(R); { Get view extent }
  738. If (MenuBar <> Nil) Then Inc(R.A.Y); { Adjust top down }
  739. If (StatusLine <> Nil) Then Dec(R.B.Y); { Adjust bottom up }
  740. DeskTop := New(PDesktop, Init(R)); { Create desktop }
  741. END;
  742. {--TProgram-----------------------------------------------------------------}
  743. { OutOfMemory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08May98 LdB }
  744. {---------------------------------------------------------------------------}
  745. PROCEDURE TProgram.OutOfMemory;
  746. BEGIN { Abstract method }
  747. END;
  748. {--TProgram-----------------------------------------------------------------}
  749. { InitMenuBar -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  750. {---------------------------------------------------------------------------}
  751. PROCEDURE TProgram.InitMenuBar;
  752. VAR R: TRect;
  753. BEGIN
  754. GetExtent(R); { Get view extents }
  755. R.B.Y := R.A.Y + 1; { One line high }
  756. MenuBar := New(PMenuBar, Init(R, Nil)); { Create menu bar }
  757. END;
  758. {--TProgram-----------------------------------------------------------------}
  759. { InitStatusLine -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  760. {---------------------------------------------------------------------------}
  761. PROCEDURE TProgram.InitStatusLine;
  762. VAR R: TRect;
  763. BEGIN
  764. GetExtent(R); { Get view extents }
  765. R.A.Y := R.B.Y - 1; { One line high }
  766. New(StatusLine, Init(R,
  767. NewStatusDef(0, $FFFF,
  768. NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
  769. StdStatusKeys(Nil)), Nil))); { Default status line }
  770. END;
  771. {--TProgram-----------------------------------------------------------------}
  772. { SetScreenMode -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Oct99 LdB }
  773. {---------------------------------------------------------------------------}
  774. PROCEDURE TProgram.SetScreenMode (Mode: Word);
  775. var
  776. R: TRect;
  777. begin
  778. if TextModeGFV then
  779. begin
  780. HideMouse;
  781. DoneMemory;
  782. InitMemory;
  783. InitScreen;
  784. Buffer := Views.PVideoBuf(VideoBuf);
  785. R.Assign(0, 0, ScreenWidth, ScreenHeight);
  786. ChangeBounds(R);
  787. ShowMouse;
  788. end;
  789. end;
  790. procedure TProgram.SetScreenVideoMode(const Mode: TVideoMode);
  791. var
  792. R: TRect;
  793. begin
  794. DoneMouse;
  795. DoneMemory;
  796. ScreenMode:=Mode;
  797. Video.SetVideoMode(Mode);
  798. InitMouse;
  799. InitMemory;
  800. InitScreen;
  801. Buffer := Views.PVideoBuf(VideoBuf);
  802. R.Assign(0, 0, ScreenWidth, ScreenHeight);
  803. ChangeBounds(R);
  804. ShowMouse;
  805. end;
  806. {--TProgram-----------------------------------------------------------------}
  807. { PutEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  808. {---------------------------------------------------------------------------}
  809. PROCEDURE TProgram.PutEvent (Var Event: TEvent);
  810. BEGIN
  811. Pending := Event; { Set pending event }
  812. END;
  813. {--TProgram-----------------------------------------------------------------}
  814. { GetEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 10May98 LdB }
  815. {---------------------------------------------------------------------------}
  816. PROCEDURE TProgram.GetEvent (Var Event: TEvent);
  817. BEGIN
  818. Event.What := evNothing;
  819. If (Event.What = evNothing) Then Begin
  820. If (Pending.What <> evNothing) Then Begin { Pending event }
  821. Event := Pending; { Load pending event }
  822. Pending.What := evNothing; { Clear pending event }
  823. End Else Begin
  824. NextQueuedEvent(Event); { Next queued event }
  825. If (Event.What = evNothing) Then Begin
  826. GetKeyEvent(Event); { Fetch key event }
  827. {$ifdef DEBUG}
  828. If (Event.What = evKeyDown) then
  829. Begin
  830. if Event.keyCode = kbAltF11 then
  831. WriteDebugInfo := not WriteDebugInfo;
  832. if Event.keyCode = kbAltF12 then
  833. ReDraw;
  834. End;
  835. {$endif DEBUG}
  836. If (Event.What = evNothing) Then Begin { No mouse event }
  837. Drivers.GetMouseEvent(Event); { Load mouse event }
  838. If (Event.What = evNothing) Then Idle; { Idle if no event }
  839. End;
  840. End;
  841. End;
  842. End;
  843. END;
  844. {--TProgram-----------------------------------------------------------------}
  845. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  846. {---------------------------------------------------------------------------}
  847. PROCEDURE TProgram.HandleEvent (Var Event: TEvent);
  848. VAR C: Char;
  849. BEGIN
  850. If (Event.What = evKeyDown) Then Begin { Key press event }
  851. C := GetAltChar(Event.KeyCode); { Get alt char code }
  852. If (C >= '1') AND (C <= '9') Then
  853. If (Message(Desktop, evBroadCast, cmSelectWindowNum,
  854. Pointer(Byte(C) - $30)) <> Nil) { Select window }
  855. Then ClearEvent(Event); { Clear event }
  856. End;
  857. Inherited HandleEvent(Event); { Call ancestor }
  858. If (Event.What = evCommand) AND { Command event }
  859. (Event.Command = cmQuit) Then Begin { Quit command }
  860. EndModal(cmQuit); { Endmodal operation }
  861. ClearEvent(Event); { Clear event }
  862. End;
  863. END;
  864. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  865. { TApplication OBJECT METHODS }
  866. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  867. {--TApplication-------------------------------------------------------------}
  868. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  869. {---------------------------------------------------------------------------}
  870. CONSTRUCTOR TApplication.Init;
  871. BEGIN
  872. InitMemory; { Start memory up }
  873. Drivers.InitVideo; { Start video up }
  874. Drivers.InitEvents; { Start event drive }
  875. Drivers.InitSysError; { Start system error }
  876. InitHistory; { Start history up }
  877. InitResource;
  878. InitMsgBox;
  879. Inherited Init; { Call ancestor }
  880. if (TextModeGFV) then
  881. begin
  882. { init mouse and cursor }
  883. Video.SetCursorType(crHidden);
  884. Mouse.SetMouseXY(1,1);
  885. end;
  886. END;
  887. {--TApplication-------------------------------------------------------------}
  888. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  889. {---------------------------------------------------------------------------}
  890. DESTRUCTOR TApplication.Done;
  891. BEGIN
  892. Inherited Done; { Call ancestor }
  893. DoneHistory; { Close history }
  894. Drivers.DoneSysError; { Close system error }
  895. Drivers.DoneEvents; { Close event drive }
  896. Drivers.DoneVideo; { Close video }
  897. DoneMemory; { Close memory }
  898. END;
  899. {--TApplication-------------------------------------------------------------}
  900. { Tile -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  901. {---------------------------------------------------------------------------}
  902. PROCEDURE TApplication.Tile;
  903. VAR R: TRect;
  904. BEGIN
  905. GetTileRect(R); { Tileable area }
  906. If (Desktop <> Nil) Then Desktop^.Tile(R); { Tile desktop }
  907. END;
  908. {--TApplication-------------------------------------------------------------}
  909. { Cascade -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  910. {---------------------------------------------------------------------------}
  911. PROCEDURE TApplication.Cascade;
  912. VAR R: TRect;
  913. BEGIN
  914. GetTileRect(R); { Cascade area }
  915. If (Desktop <> Nil) Then Desktop^.Cascade(R); { Cascade desktop }
  916. END;
  917. {--TApplication-------------------------------------------------------------}
  918. { DosShell -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Oct99 LdB }
  919. {---------------------------------------------------------------------------}
  920. PROCEDURE TApplication.DosShell;
  921. BEGIN { Compatability only }
  922. DoneSysError;
  923. DoneEvents;
  924. DoneScreen;
  925. DoneDosMem;
  926. WriteShellMsg;
  927. SwapVectors;
  928. Exec(GetEnv('COMSPEC'), '');
  929. SwapVectors;
  930. InitDosMem;
  931. InitScreen;
  932. InitEvents;
  933. InitSysError;
  934. Redraw;
  935. END;
  936. {--TApplication-------------------------------------------------------------}
  937. { GetTileRect -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  938. {---------------------------------------------------------------------------}
  939. PROCEDURE TApplication.GetTileRect (Var R: TRect);
  940. BEGIN
  941. If (DeskTop <> Nil) Then Desktop^.GetExtent(R) { Desktop extents }
  942. Else GetExtent(R); { Our extents }
  943. END;
  944. {--TApplication-------------------------------------------------------------}
  945. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  946. {---------------------------------------------------------------------------}
  947. PROCEDURE TApplication.HandleEvent (Var Event: TEvent);
  948. BEGIN
  949. Inherited HandleEvent(Event); { Call ancestor }
  950. If (Event.What = evCommand) Then Begin
  951. Case Event.Command Of
  952. cmTile: Tile; { Tile request }
  953. cmCascade: Cascade; { Cascade request }
  954. cmDosShell: DosShell; { DOS shell request }
  955. Else Exit; { Unhandled exit }
  956. End;
  957. ClearEvent(Event); { Clear the event }
  958. End;
  959. END;
  960. procedure TApplication.WriteShellMsg;
  961. begin
  962. PrintStr(Strings^.Get(sTypeExitOnReturn));
  963. end;
  964. {***************************************************************************}
  965. { INTERFACE ROUTINES }
  966. {***************************************************************************}
  967. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  968. { STANDARD MENU AND STATUS LINES ROUTINES }
  969. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  970. {---------------------------------------------------------------------------}
  971. { StdStatusKeys -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  972. {---------------------------------------------------------------------------}
  973. FUNCTION StdStatusKeys (Next: PStatusItem): PStatusItem;
  974. BEGIN
  975. StdStatusKeys :=
  976. NewStatusKey('', kbAltX, cmQuit,
  977. NewStatusKey('', kbF10, cmMenu,
  978. NewStatusKey('', kbAltF3, cmClose,
  979. NewStatusKey('', kbF5, cmZoom,
  980. NewStatusKey('', kbCtrlF5, cmResize,
  981. NewStatusKey('', kbF6, cmNext,
  982. NewStatusKey('', kbShiftF6, cmPrev,
  983. Next)))))));
  984. END;
  985. {---------------------------------------------------------------------------}
  986. { StdFileMenuItems -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  987. {---------------------------------------------------------------------------}
  988. FUNCTION StdFileMenuItems (Next: PMenuItem): PMenuItem;
  989. BEGIN
  990. StdFileMenuItems :=
  991. NewItem('~N~ew', '', kbNoKey, cmNew, hcNew,
  992. NewItem('~O~pen...', 'F3', kbF3, cmOpen, hcOpen,
  993. NewItem('~S~ave', 'F2', kbF2, cmSave, hcSave,
  994. NewItem('S~a~ve as...', '', kbNoKey, cmSaveAs, hcSaveAs,
  995. NewItem('Save a~l~l', '', kbNoKey, cmSaveAll, hcSaveAll,
  996. NewLine(
  997. NewItem('~C~hange dir...', '', kbNoKey, cmChangeDir, hcChangeDir,
  998. NewItem('OS shell', '', kbNoKey, cmDosShell, hcDosShell,
  999. NewItem('E~x~it', 'Alt+X', kbAltX, cmQuit, hcExit,
  1000. Next)))))))));
  1001. END;
  1002. {---------------------------------------------------------------------------}
  1003. { StdEditMenuItems -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  1004. {---------------------------------------------------------------------------}
  1005. FUNCTION StdEditMenuItems (Next: PMenuItem): PMenuItem;
  1006. BEGIN
  1007. StdEditMenuItems :=
  1008. NewItem('~U~ndo', '', kbAltBack, cmUndo, hcUndo,
  1009. NewLine(
  1010. NewItem('Cu~t~', 'Shift+Del', kbShiftDel, cmCut, hcCut,
  1011. NewItem('~C~opy', 'Ctrl+Ins', kbCtrlIns, cmCopy, hcCopy,
  1012. NewItem('~P~aste', 'Shift+Ins', kbShiftIns, cmPaste, hcPaste,
  1013. NewItem('C~l~ear', 'Ctrl+Del', kbCtrlDel, cmClear, hcClear,
  1014. Next))))));
  1015. END;
  1016. {---------------------------------------------------------------------------}
  1017. { StdWindowMenuItems -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  1018. {---------------------------------------------------------------------------}
  1019. FUNCTION StdWindowMenuItems (Next: PMenuItem): PMenuItem;
  1020. BEGIN
  1021. StdWindowMenuItems :=
  1022. NewItem('~T~ile', '', kbNoKey, cmTile, hcTile,
  1023. NewItem('C~a~scade', '', kbNoKey, cmCascade, hcCascade,
  1024. NewItem('Cl~o~se all', '', kbNoKey, cmCloseAll, hcCloseAll,
  1025. NewLine(
  1026. NewItem('~S~ize/Move','Ctrl+F5', kbCtrlF5, cmResize, hcResize,
  1027. NewItem('~Z~oom', 'F5', kbF5, cmZoom, hcZoom,
  1028. NewItem('~N~ext', 'F6', kbF6, cmNext, hcNext,
  1029. NewItem('~P~revious', 'Shift+F6', kbShiftF6, cmPrev, hcPrev,
  1030. NewItem('~C~lose', 'Alt+F3', kbAltF3, cmClose, hcClose,
  1031. Next)))))))));
  1032. END;
  1033. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1034. { OBJECT REGISTER ROUTINES }
  1035. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1036. {---------------------------------------------------------------------------}
  1037. { RegisterApp -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  1038. {---------------------------------------------------------------------------}
  1039. PROCEDURE RegisterApp;
  1040. BEGIN
  1041. RegisterType(RBackground); { Register background }
  1042. RegisterType(RDesktop); { Register desktop }
  1043. END;
  1044. END.
  1045. {
  1046. $Log$
  1047. Revision 1.13 2001-08-05 02:03:13 peter
  1048. * view redrawing and small cursor updates
  1049. * merged some more FV extensions
  1050. Revision 1.12 2001/08/04 19:14:32 peter
  1051. * Added Makefiles
  1052. * added FV specific units and objects from old FV
  1053. Revision 1.11 2001/05/31 21:39:11 pierre
  1054. + AltF12 to force Redraw of Application
  1055. Revision 1.10 2001/05/31 12:15:24 pierre
  1056. + some debug stuff added
  1057. Revision 1.9 2001/05/10 16:46:26 pierre
  1058. + some improovements made
  1059. Revision 1.8 2001/05/07 22:22:03 pierre
  1060. * removed NO_WINDOW cond, added GRAPH_API
  1061. Revision 1.7 2001/05/04 15:43:45 pierre
  1062. * several more fixes
  1063. Revision 1.6 2001/05/04 08:42:54 pierre
  1064. * some corrections for linux
  1065. Revision 1.5 2001/05/03 22:32:52 pierre
  1066. new bunch of changes, displays something for dos at least
  1067. Revision 1.4 2001/04/10 21:57:55 pierre
  1068. + first adds for Use_API define
  1069. Revision 1.3 2001/04/10 21:29:54 pierre
  1070. * import of Leon de Boer's files
  1071. Revision 1.2 2000/08/24 11:43:13 marco
  1072. * Added CVS log and ID entries.
  1073. }
  1074. {******************[ REVISION HISTORY ]********************}
  1075. { Version Date Fix }
  1076. { ------- --------- --------------------------------- }
  1077. { 1.00 12 Dec 96 First multi platform release }
  1078. { 1.10 12 Sep 97 FPK pascal 0.92 conversion added. }
  1079. { 1.20 29 Aug 97 Platform.inc sort added. }
  1080. { 1.30 05 May 98 Virtual pascal 2.0 code added. }
  1081. { 1.40 22 Oct 99 Object registration added. }
  1082. { 1.50 22 Oct 99 Complete recheck preformed }
  1083. { 1.51 03 Nov 99 FPC Windows support added }
  1084. { 1.60 26 Nov 99 Graphics stuff moved to GFVGraph }