app.pas 60 KB

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