gem.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. {
  2. Copyright (c) 2022 by Free Pascal development team
  3. GEM interface unit for Atari TOS
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {
  11. This is used for Pure-Pascal compatibility. For newly written code,
  12. consider using the aes/vdi units instead.
  13. }
  14. {$MODE FPC}
  15. {$MODESWITCH OUT+}
  16. {$PACKRECORDS 2}
  17. {$IFNDEF FPC_DOTTEDUNITS}
  18. unit gem;
  19. {$ENDIF FPC_DOTTEDUNITS}
  20. interface
  21. {$IFDEF FPC_DOTTEDUNITS}
  22. uses AtariApi.Aes, AtariApi.Vdi, AtariApi.Gemcmmn;
  23. {$ELSE FPC_DOTTEDUNITS}
  24. uses aes, vdi, gemcmmn;
  25. {$ENDIF FPC_DOTTEDUNITS}
  26. const
  27. LWhite = DWHITE;
  28. LBlack = DBLACK;
  29. LRed = DRED;
  30. LGreen = DGREEN;
  31. LBlue = DBLUE;
  32. LCyan = DCYAN;
  33. LYellow = DYELLOW;
  34. LMagenta = DMAGENTA;
  35. const
  36. BackSpace = $0E08;
  37. Tab = $0F09;
  38. S_Delete = $537F;
  39. S_Insert = $5200;
  40. Shift_Ins = $5230;
  41. Return = $1C0D;
  42. Enter = $720D;
  43. Undo = $6100;
  44. Help = $6200;
  45. Home = $4700;
  46. Cur_Up = $4800;
  47. Cur_Down = $5000;
  48. Cur_Left = $4B00;
  49. Cur_Right = $4D00;
  50. Shift_Home = $4737;
  51. Shift_CU = $4838;
  52. Shift_CD = $5032;
  53. Shift_CL = $4B34;
  54. Shift_CR = $4D36;
  55. Esc = $011B;
  56. Ctrl_A = $1E01;
  57. Ctrl_B = $3002;
  58. Ctrl_C = $2E03;
  59. Ctrl_D = $2004;
  60. Ctrl_E = $1205;
  61. Ctrl_F = $2106;
  62. Ctrl_G = $2207;
  63. Ctrl_H = $2308;
  64. Ctrl_I = $1709;
  65. Ctrl_J = $240A;
  66. Ctrl_K = $250B;
  67. Ctrl_L = $260C;
  68. Ctrl_M = $320D;
  69. Ctrl_N = $310E;
  70. Ctrl_O = $180F;
  71. Ctrl_P = $1910;
  72. Ctrl_Q = $1011;
  73. Ctrl_R = $1312;
  74. Ctrl_S = $1F13;
  75. Ctrl_T = $1414;
  76. Ctrl_U = $1615;
  77. Ctrl_V = $2F16;
  78. Ctrl_W = $1117;
  79. Ctrl_X = $2D18;
  80. Ctrl_Y = $2C19;
  81. Ctrl_Z = $151A;
  82. Ctrl_1 = $0211;
  83. Ctrl_2 = $0300;
  84. Ctrl_3 = $0413;
  85. Ctrl_4 = $0514;
  86. Ctrl_5 = $0615;
  87. Ctrl_6 = $071E;
  88. Ctrl_7 = $0817;
  89. Ctrl_8 = $0918;
  90. Ctrl_9 = $0A19;
  91. Ctrl_0 = $0B10;
  92. Alt_A = $1E00;
  93. Alt_B = $3000;
  94. Alt_C = $2E00;
  95. Alt_D = $2000;
  96. Alt_E = $1200;
  97. Alt_F = $2100;
  98. Alt_G = $2200;
  99. Alt_H = $2300;
  100. Alt_I = $1700;
  101. Alt_J = $2400;
  102. Alt_K = $2500;
  103. Alt_L = $2600;
  104. Alt_M = $3200;
  105. Alt_N = $3100;
  106. Alt_O = $1800;
  107. Alt_P = $1900;
  108. Alt_Q = $1000;
  109. Alt_R = $1300;
  110. Alt_S = $1F00;
  111. Alt_T = $1400;
  112. Alt_U = $1600;
  113. Alt_V = $2F00;
  114. Alt_W = $1100;
  115. Alt_X = $2D00;
  116. Alt_Y = $2C00;
  117. Alt_Z = $1500;
  118. Alt_1 = $7800;
  119. Alt_2 = $7900;
  120. Alt_3 = $7A00;
  121. Alt_4 = $7B00;
  122. Alt_5 = $7C00;
  123. Alt_6 = $7D00;
  124. Alt_7 = $7E00;
  125. Alt_8 = $7F00;
  126. Alt_9 = $8000;
  127. Alt_0 = $8100;
  128. F1 = $3B00;
  129. F2 = $3C00;
  130. F3 = $3D00;
  131. F4 = $3E00;
  132. F5 = $3F00;
  133. F6 = $4000;
  134. F7 = $4100;
  135. F8 = $4200;
  136. F9 = $4300;
  137. F10 = $4400;
  138. Shift_F1 = $5400;
  139. Shift_F2 = $5500;
  140. Shift_F3 = $5600;
  141. Shift_F4 = $5700;
  142. Shift_F5 = $5800;
  143. Shift_F6 = $5900;
  144. Shift_F7 = $5A00;
  145. Shift_F8 = $5B00;
  146. Shift_F9 = $5C00;
  147. Shift_F10 = $5D00;
  148. Ctrl_AE = $2804;
  149. Ctrl_OE = $2714;
  150. Ctrl_UE = $1A01;
  151. Alt_AE = $285D;
  152. Alt_OE = $275B;
  153. Alt_UE = $1A40;
  154. SH_Alt_AE = $287D;
  155. SH_Alt_OE = $277B;
  156. SH_Alt_UE = $1A5C;
  157. type
  158. control_ARRAY = ARRAY[0..4] of smallint;
  159. AESPBPtr = ^AESPB;
  160. AESPB = record
  161. control: ^control_ARRAY;
  162. global: PAESGlobal;
  163. intin: PAESIntIn;
  164. intout: PAESIntOut;
  165. addrin: PAESAddrIn;
  166. addrout: PAESAddrOut;
  167. end;
  168. AESOBJECT = TAESOBJECT;
  169. AESOBJECTPtr = ^TAESOBJECT;
  170. VDIPB = TVDIPB;
  171. VDIPBPtr = ^VDIPB;
  172. TEDINFO = TTEDINFO;
  173. TEDINFOPtr = ^TEDINFO;
  174. ICONBLK = TICONBLK;
  175. ICONBLKPtr = ^ICONBLK;
  176. CICON = TCICON;
  177. CICONPtr = ^CICON;
  178. CICONBLK = TCICONBLK;
  179. CICONBLKPtr = ^CICONBLK;
  180. BITBLK = TBITBLK;
  181. BITBLKPtr = ^BITBLK;
  182. MFORM = TMFORM;
  183. MFORMPtr = ^MFORM;
  184. USERBLK = TUSERBLK;
  185. USERBLKPtr = ^USERBLK;
  186. OBSPEC = TOBSPEC;
  187. OBSPECPtr = ^OBSPEC;
  188. PARMBLK = TPARMBLK;
  189. PARMBLKPtr = ^PARMBLK;
  190. AESTree = TAESTree;
  191. AESTreePtr = ^AESTree;
  192. RSHDR = TRSHDR;
  193. RSHDRPtr = ^RSHDR;
  194. EVENT = TEVENT;
  195. EVENTPtr = ^EVENT;
  196. MENU = TMENU;
  197. MENUPtr = ^MENU;
  198. MN_SET = TMN_SET;
  199. MN_SETPtr = ^MN_SET;
  200. FONT_HDR = TFONT_HDR;
  201. FONT_HDRPtr = ^FONT_HDR;
  202. MFDB = vdi.TMFDB;
  203. MFDBPtr = ^MFDB;
  204. global_ARRAY = TAESGlobal;
  205. workout_ARRAY = ARRAY[0..56] of smallint;
  206. workin_ARRAY = ARRAY[0..10] of smallint;
  207. intin_ARRAY = TVDIIntIn;
  208. intout_ARRAY = TVDIIntOut;
  209. ptsin_ARRAY = TVDIPtsIn;
  210. ptsout_ARRAY = TVDIPtsOut;
  211. (*
  212. * PurePascal has all the AES parameter arrays exposed.
  213. * We don't want to do that, because various arrays are
  214. * implementation specific. For Compatibility we
  215. * need to make the global array available however;
  216. *)
  217. type
  218. AES_block = record
  219. global : TAESGlobal;
  220. end;
  221. var Gem_pb: AES_block; external name 'aes_global';
  222. (*
  223. * we also need to make the parameter block available,
  224. * so applications can define missing functions
  225. * that are not yet implemented here.
  226. *)
  227. var
  228. AES_pb: AESPB; external name 'aespb';
  229. VDI_pb: TVDIPB; external name 'vdipb';
  230. {*
  231. * overloaded AES functions that take an AESTreePtr as parameter
  232. *}
  233. function menu_bar(me_btree: AESTreePtr; me_bshow: smallint): smallint; overload;
  234. function menu_icheck(me_ctree: AESTreePtr; me_citem, me_ccheck: smallint): smallint; overload;
  235. function menu_ienable(me_etree: AESTreePtr; me_eitem, me_eenable: smallint): smallint; overload;
  236. function menu_tnormal(me_ntree: AESTreePtr; me_ntitle, me_nnormal: smallint): smallint; overload;
  237. function menu_text(me_ttree: AESTreePtr; me_titem: smallint; me_ttext: String): smallint; overload;
  238. function menu_attach(me_flag: smallint; me_tree: AESTreePtr; me_item: smallint; me_mdata: PMENU): smallint; overload;
  239. function menu_istart(me_flag: smallint; me_tree: AESTreePtr; me_imenu, me_item: smallint): smallint; overload;
  240. function objc_add(ob_atree: AESTreePtr; ob_aparent, ob_achild: smallint): smallint; overload;
  241. function objc_delete(ob_dltree: AESTreePtr; ob_dlobject: smallint): smallint; overload;
  242. function objc_draw(ob_drtree: AESTreePtr;
  243. ob_drstartob, ob_drdepth,
  244. ob_drxclip, ob_dryclip,
  245. ob_drwclip, ob_drhclip: smallint): smallint; overload;
  246. function objc_find(ob_ftree: AESTreePtr;
  247. ob_fstartob, ob_fdepth,
  248. ob_fmx, ob_fmy: smallint): smallint; overload;
  249. function objc_offset(ob_oftree: AESTreePtr;
  250. ob_ofobject: smallint;
  251. out ob_ofxoff, ob_ofyoff: smallint): smallint; overload;
  252. function objc_order(ob_ortree: AESTreePtr;
  253. ob_orobject, ob_ornewpos: smallint): smallint; overload;
  254. function objc_edit(ob_edtree: AESTreePtr;
  255. ob_edobject, ob_edchar: smallint;
  256. var ob_edidx: smallint;
  257. ob_edkind: smallint): smallint; overload;
  258. function objc_change(ob_ctree: AESTreePtr;
  259. ob_cobject, ob_cresvd,
  260. ob_xclip, ob_yclip,
  261. ob_wclip, ob_hclip,
  262. ob_cnewstate,
  263. ob_credraw: smallint): smallint; overload;
  264. function form_do(fo_dotree: AESTreePtr; fo_dostartob: smallint): smallint; overload;
  265. function form_center(fo_ctree: AESTreePtr; out fo_cx, fo_cy, fo_cw, fo_ch: smallint): smallint; overload;
  266. function form_keybd(fo_ktree: AESTreePtr;
  267. fo_kobject, fo_kobnext, fo_kchar: smallint;
  268. out fo_knxtobject, fo_knxtchar: smallint): smallint; overload;
  269. function form_button(fo_btree: AESTreePtr; fo_bobject, fo_bclicks: smallint;
  270. out fo_bnxtobj: smallint): smallint; overload;
  271. function rsrc_obfix(re_obtree: AESTreePtr; re_oobject: smallint): smallint; overload;
  272. {*
  273. * overloaded VDI functions
  274. *}
  275. procedure v_opnwk(const WorkIn: workin_Array; out handle: smallint; out WorkOut: workout_Array); overload;
  276. procedure v_opnvwk(const WorkIn: workin_Array; var handle: smallint; out WorkOut: workout_Array); overload;
  277. procedure vq_extnd(handle, owflag: smallint; out WorkOut: workout_Array); overload;
  278. procedure vro_cpyfm(handle, vr_mode: smallint; const pxyarray: ARRAY_8; const psrcMFDB, pdesMFDB: TMFDB); overload;
  279. procedure vrt_cpyfm(handle, vr_mode: smallint; const pxyarray: ARRAY_8; const psrcMFDB, pdesMFDB: TMFDB; const color_index: ARRAY_2); overload;
  280. procedure vqt_extent(handle: smallint; const calcString: String; out extent: ARRAY_8); overload;
  281. procedure vqt_f_extent(handle: smallint; const str: String; out extent: ARRAY_8);
  282. {*
  283. * Utility functions
  284. *}
  285. procedure SetFreeString(tree: PAESTree; obj: smallint; const str: String);
  286. procedure GetFreeString(tree: PAESTree; obj: smallint; out str: String);
  287. procedure SetPtext(tree: PAESTree; obj: smallint; const str: String);
  288. procedure GetPtext(tree: PAESTree; obj: smallint; out str: String);
  289. procedure SetPtmplt(tree: PAESTree; obj: smallint; const str: String);
  290. procedure GetPtmplt(tree: PAESTree; obj: smallint; out str :String);
  291. procedure SetPvalid(tree: PAESTree; obj: smallint; const str: String);
  292. procedure GetPvalid(tree: PAESTree; obj: smallint; out str: String);
  293. procedure SetIcontext(tree: PAESTree; obj: smallint; const str: String);
  294. procedure GetIcontext(tree: PAESTree; obj: smallint; out str: String);
  295. procedure WindSetTitle(handle: smallint; const str: String; var buf: String);
  296. procedure WindSetInfo(handle: smallint; const str: String; var buf: String);
  297. procedure WindSetNewDesk(tree: PAESTree; firstObj: smallint);
  298. implementation
  299. type
  300. aesstr = array[0..255] of AnsiChar;
  301. function string_to_vdi(const src: String; dst: psmallint): smallint;
  302. var
  303. i, len: longint;
  304. begin
  305. len:=length(src);
  306. for i:=0 to len-1 do
  307. dst[i]:=byte(src[i + 1]);
  308. string_to_vdi:=len;
  309. end;
  310. procedure v_opnwk(const WorkIn: workin_Array; out handle: smallint; out WorkOut: workout_Array);
  311. begin
  312. vdi.v_opnwk(@workin[0], @handle, @workout[0]);
  313. end;
  314. procedure v_opnvwk(const WorkIn: workin_Array; var handle: smallint; out WorkOut: workout_Array);
  315. begin
  316. vdi.v_opnvwk(@workin[0], @handle, @workout[0]);
  317. end;
  318. procedure vq_extnd(handle, owflag: smallint; out WorkOut: workout_Array);
  319. begin
  320. vdi.vq_extnd(handle, owflag, @workout[0]);
  321. end;
  322. procedure vro_cpyfm(handle, vr_mode: smallint; const pxyarray: ARRAY_8; const psrcMFDB, pdesMFDB: TMFDB);
  323. begin
  324. vdi.vro_cpyfm(handle, vr_mode, @pxyarray, @psrcMFDB, @pdesMFDB);
  325. end;
  326. procedure vrt_cpyfm(handle, vr_mode: smallint; const pxyarray: ARRAY_8; const psrcMFDB, pdesMFDB: TMFDB; const color_index: ARRAY_2);
  327. begin
  328. vdi.vrt_cpyfm(handle, vr_mode, @pxyarray, @psrcMFDB, @pdesMFDB, @color_index);
  329. end;
  330. procedure vqt_extent(handle: smallint; const calcString: String; out extent: ARRAY_8);
  331. var len: smallint;
  332. begin
  333. len:=string_to_vdi(calcstring, @vdi_pb.intin^[0]);
  334. vdi_pb.control^[0]:=116;
  335. vdi_pb.control^[1]:=0;
  336. vdi_pb.control^[3]:=len;
  337. vdi_pb.control^[5]:=0;
  338. vdi_pb.control^[6]:=handle;
  339. vdi.vdi;
  340. extent[0]:=vdi_pb.ptsout^[0];
  341. extent[1]:=vdi_pb.ptsout^[1];
  342. extent[2]:=vdi_pb.ptsout^[2];
  343. extent[3]:=vdi_pb.ptsout^[3];
  344. extent[4]:=vdi_pb.ptsout^[4];
  345. extent[5]:=vdi_pb.ptsout^[5];
  346. extent[6]:=vdi_pb.ptsout^[6];
  347. extent[7]:=vdi_pb.ptsout^[7];
  348. end;
  349. procedure vqt_f_extent(handle: smallint; const str: String;
  350. out extent: ARRAY_8);
  351. var len: longint;
  352. begin
  353. len:=string_to_vdi(str, @vdi_pb.intin^[0]);
  354. vdi_pb.control^[0]:=240;
  355. vdi_pb.control^[1]:=0;
  356. vdi_pb.control^[3]:=len;
  357. vdi_pb.control^[5]:=0;
  358. vdi_pb.control^[6]:=handle;
  359. vdi.vdi;
  360. extent[0]:=vdi_pb.ptsout^[0];
  361. extent[1]:=vdi_pb.ptsout^[1];
  362. extent[2]:=vdi_pb.ptsout^[2];
  363. extent[3]:=vdi_pb.ptsout^[3];
  364. extent[4]:=vdi_pb.ptsout^[4];
  365. extent[5]:=vdi_pb.ptsout^[5];
  366. extent[6]:=vdi_pb.ptsout^[6];
  367. extent[7]:=vdi_pb.ptsout^[7];
  368. end;
  369. function menu_bar(me_btree: AESTreePtr; me_bshow: smallint): smallint;
  370. begin
  371. menu_bar := aes.menu_bar(@me_btree[0], me_bshow);
  372. end;
  373. function menu_icheck(me_ctree: AESTreePtr; me_citem, me_ccheck: smallint): smallint;
  374. begin
  375. menu_icheck := aes.menu_icheck(@me_ctree[0], me_citem, me_ccheck);
  376. end;
  377. function menu_ienable(me_etree: AESTreePtr; me_eitem, me_eenable: smallint): smallint;
  378. begin
  379. menu_ienable := aes.menu_ienable(@me_etree[0], me_eitem, me_eenable);
  380. end;
  381. function menu_tnormal(me_ntree: AESTreePtr; me_ntitle, me_nnormal: smallint): smallint;
  382. begin
  383. menu_tnormal := aes.menu_tnormal(@me_ntree[0], me_ntitle, me_nnormal);
  384. end;
  385. function menu_text(me_ttree: AESTreePtr; me_titem: smallint; me_ttext: String): smallint;
  386. var s: aesstr;
  387. begin
  388. s:=me_ttext;
  389. menu_text:=aes.menu_text(@me_ttree[0], me_titem, @s);
  390. end;
  391. function menu_attach(me_flag: smallint; me_tree: AESTreePtr; me_item: smallint; me_mdata: PMENU): smallint;
  392. begin
  393. menu_attach:=aes.menu_attach(me_flag, @me_tree[0], me_item, me_mdata);
  394. end;
  395. function menu_istart(me_flag: smallint; me_tree: AESTreePtr; me_imenu, me_item: smallint): smallint; overload;
  396. begin
  397. menu_istart:=aes.menu_istart(me_flag, @me_tree[0], me_imenu, me_item);
  398. end;
  399. function objc_add(ob_atree: AESTreePtr; ob_aparent, ob_achild: smallint): smallint;
  400. begin
  401. objc_add:=aes.objc_add(@ob_atree[0], ob_aparent, ob_achild);
  402. end;
  403. function objc_delete(ob_dltree: AESTreePtr; ob_dlobject: smallint): smallint;
  404. begin
  405. objc_delete:=aes.objc_delete(@ob_dltree[0], ob_dlobject);
  406. end;
  407. function objc_draw(ob_drtree: AESTreePtr;
  408. ob_drstartob, ob_drdepth,
  409. ob_drxclip, ob_dryclip,
  410. ob_drwclip, ob_drhclip: smallint): smallint;
  411. begin
  412. objc_draw:=aes.objc_draw(@ob_drtree[0], ob_drstartob, ob_drdepth, ob_drxclip, ob_dryclip, ob_drwclip, ob_drhclip);
  413. end;
  414. function objc_find(ob_ftree: AESTreePtr;
  415. ob_fstartob, ob_fdepth,
  416. ob_fmx, ob_fmy: smallint): smallint;
  417. begin
  418. objc_find:=aes.objc_find(@ob_ftree[0], ob_fstartob, ob_fdepth, ob_fmx, ob_fmy);
  419. end;
  420. function objc_offset(ob_oftree: AESTreePtr;
  421. ob_ofobject: smallint;
  422. out ob_ofxoff, ob_ofyoff: smallint): smallint;
  423. begin
  424. objc_offset:=aes.objc_offset(@ob_oftree[0], ob_ofobject, ob_ofxoff, ob_ofyoff);
  425. end;
  426. function objc_order(ob_ortree: AESTreePtr;
  427. ob_orobject, ob_ornewpos: smallint): smallint;
  428. begin
  429. objc_order:=aes.objc_order(@ob_ortree[0], ob_orobject, ob_ornewpos);
  430. end;
  431. function objc_edit(ob_edtree: AESTreePtr;
  432. ob_edobject, ob_edchar: smallint;
  433. var ob_edidx: smallint;
  434. ob_edkind: smallint): smallint;
  435. begin
  436. objc_edit:=aes.objc_edit(@ob_edtree[0], ob_edobject, ob_edchar, ob_edidx, ob_edkind);
  437. end;
  438. function objc_change(ob_ctree: AESTreePtr;
  439. ob_cobject, ob_cresvd,
  440. ob_xclip, ob_yclip,
  441. ob_wclip, ob_hclip,
  442. ob_cnewstate,
  443. ob_credraw: smallint): smallint;
  444. begin
  445. objc_change:=aes.objc_change(@ob_ctree[0], ob_cobject, ob_cresvd, ob_xclip, ob_yclip, ob_wclip, ob_hclip, ob_cnewstate, ob_credraw);
  446. end;
  447. function form_do(fo_dotree: AESTreePtr; fo_dostartob: smallint): smallint;
  448. begin
  449. form_do:=aes.form_do(@fo_dotree[0], fo_dostartob);
  450. end;
  451. function form_center(fo_ctree: AESTreePtr; out fo_cx, fo_cy, fo_cw, fo_ch: smallint): smallint;
  452. begin
  453. form_center:=aes.form_center(@fo_ctree[0], fo_cx, fo_cy, fo_cw, fo_ch);
  454. end;
  455. function form_keybd(fo_ktree: AESTreePtr;
  456. fo_kobject, fo_kobnext, fo_kchar: smallint;
  457. out fo_knxtobject, fo_knxtchar: smallint): smallint;
  458. begin
  459. form_keybd:=aes.form_keybd(@fo_ktree[0], fo_kobject, fo_kobnext, fo_kchar, fo_knxtobject, fo_knxtchar);
  460. end;
  461. function form_button(fo_btree: AESTreePtr; fo_bobject, fo_bclicks: smallint;
  462. out fo_bnxtobj: smallint): smallint;
  463. begin
  464. form_button:=aes.form_button(@fo_btree[0], fo_bobject, fo_bclicks, fo_bnxtobj);
  465. end;
  466. function rsrc_obfix(re_obtree: AESTreePtr; re_oobject: smallint): smallint;
  467. begin
  468. rsrc_obfix:=aes.rsrc_obfix(@re_obtree[0], re_oobject);
  469. end;
  470. procedure SetFreeString(tree: PAESTree; obj: smallint; const str: String);
  471. var len: SizeInt;
  472. p: PAnsiChar;
  473. begin
  474. len:=length(str);
  475. p:=tree^[obj].ob_spec.free_string;
  476. move(str[1], p^, len);
  477. p[len]:=#0;
  478. end;
  479. procedure GetFreeString(tree: PAESTree; obj: smallint; out str: String);
  480. begin
  481. str := tree^[obj].ob_spec.free_string;
  482. end;
  483. procedure SetPtext(tree: PAESTree; obj: smallint; const str: String);
  484. var len: SizeInt;
  485. p: PAnsiChar;
  486. begin
  487. len:=length(str);
  488. p:=tree^[obj].ob_spec.ted_info^.te_ptext;
  489. if (len >= tree^[obj].ob_spec.ted_info^.te_txtlen) then
  490. len := tree^[obj].ob_spec.ted_info^.te_txtlen-1;
  491. move(str[1], p^, len);
  492. p[len]:=#0;
  493. end;
  494. procedure GetPtext(tree: PAESTree; obj: smallint; out str: String);
  495. begin
  496. str := tree^[obj].ob_spec.ted_info^.te_ptext;
  497. end;
  498. procedure SetPtmplt(tree: PAESTree; obj: smallint; const str: String);
  499. var len: SizeInt;
  500. p: PAnsiChar;
  501. begin
  502. len:=length(str);
  503. p:=tree^[obj].ob_spec.ted_info^.te_ptmplt;
  504. if (len >= tree^[obj].ob_spec.ted_info^.te_tmplen) then
  505. len := tree^[obj].ob_spec.ted_info^.te_tmplen-1;
  506. move(str[1], p^, len);
  507. p[len]:=#0;
  508. end;
  509. procedure GetPtmplt(tree: PAESTree; obj: smallint; out str: String);
  510. begin
  511. str := tree^[obj].ob_spec.ted_info^.te_ptmplt;
  512. end;
  513. procedure SetPvalid(tree: PAESTree; obj: smallint; const str: String);
  514. var len: SizeInt;
  515. p: PAnsiChar;
  516. begin
  517. len:=length(str);
  518. p:=tree^[obj].ob_spec.ted_info^.te_pvalid;
  519. move(str[1], p^, len);
  520. p[len]:=#0;
  521. end;
  522. procedure GetPvalid(tree: PAESTree; obj: smallint; out str: String);
  523. begin
  524. str := tree^[obj].ob_spec.ted_info^.te_pvalid;
  525. end;
  526. procedure SetIcontext(tree: PAESTree; obj: smallint; const str: String);
  527. var len: SizeInt;
  528. p: PAnsiChar;
  529. begin
  530. len:=length(str);
  531. p:=tree^[obj].ob_spec.icon_blk^.ib_ptext;
  532. move(str[1], p^, len);
  533. p[len]:=#0;
  534. end;
  535. procedure GetIcontext(tree: PAESTree; obj: smallint; out str: String);
  536. begin
  537. str := tree^[obj].ob_spec.icon_blk^.ib_ptext;
  538. end;
  539. procedure WindSetTitle(handle: smallint; const str: String; var buf: String);
  540. var len: SizeInt;
  541. pstr: PAnsiChar;
  542. begin
  543. pstr := @buf[0];
  544. len:=length(str);
  545. move(str[1], pstr^, len);
  546. pstr[len]:=#0;
  547. wind_set(handle, WF_NAME, Pointer(pstr));
  548. end;
  549. procedure WindSetInfo(handle: smallint; const str: String; var buf: String);
  550. var len: SizeInt;
  551. pstr: PAnsiChar;
  552. begin
  553. pstr := @buf[0];
  554. len:=length(str);
  555. move(str[1], pstr^, len);
  556. pstr[len]:=#0;
  557. wind_set(handle, WF_INFO, Pointer(pstr));
  558. end;
  559. procedure WindSetNewDesk(tree: PAESTree; firstObj: smallint);
  560. begin
  561. {$PUSH}
  562. {$WARN 4055 OFF} { Conversion between ordinals and pointers is not portable }
  563. wind_set(0, WF_NEWDESK, hi(ptruint(tree)), lo(ptruint(tree)), firstObj, 0);
  564. {$POP}
  565. end;
  566. end.