home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / acorn / tech / 993 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  3.0 KB

  1. Path: sparky!uunet!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!edcastle!dcs.ed.ac.uk!pjm
  2. From: pjm@dcs.ed.ac.uk (Paul J Murphy)
  3. Newsgroups: comp.sys.acorn.tech
  4. Subject: Re: Indirected icons in templates and resspr.
  5. Message-ID: <Bz7qqK.I4u@dcs.ed.ac.uk>
  6. Date: 13 Dec 92 19:42:20 GMT
  7. References: <1992Dec10.093501.25007@westminster.ac.uk> <1992Dec13.020107.28690@infodev.cam.ac.uk>
  8. Sender: cnews@dcs.ed.ac.uk (UseNet News Admin)
  9. Reply-To: pjm@dcs.ed.ac.uk (Paul J Murphy)
  10. Organization: Laboratory for the Foundations of Computer Science, Edinburgh U
  11. Lines: 54
  12.  
  13. In article <1992Dec13.020107.28690@infodev.cam.ac.uk> idg10@cl.cam.ac.uk (I.D. Griffiths) writes:
  14. >In article <1992Dec10.093501.25007@westminster.ac.uk>, gpcec@westminster.ac.uk (Tom Kirby-Green) writes:
  15. >|> How ( having dynamicly created a sprite area ) do I access the icon
  16. >|> definitions that follow the wimp_wind pointed to by w_handle. According
  17. >|> to the PRMs I need to get hold of the indirected icon's and plug in my
  18. >|> user sprite area before wimp_create_wind'ing the window.
  19.  
  20. Yep, your interpretation of the PRMs is correct.
  21.  
  22. >language like assembler...  C will merely make things difficult for you
  23. >by being awkward about letting you do pointer maths.  Something like
  24. >this may work:
  25. >
  26. >  icon = (wimp_icon *) (((char *) w_handle) + 88 + 32 * icno );
  27.  
  28. I have to disagree withh you on C making it harder - it makes it easier (IMHO).
  29. The following works well, and uses C's handling of pointers to make it easier:
  30. (lifted direct from SparkInfo's source)
  31. {
  32.   wimp_wind *window;
  33.  
  34.   wimpt_init("SparkInfo");
  35.   res_init("SparkInfo");
  36.   resspr_init();
  37.   template_init();
  38.  
  39. ...
  40.  
  41.   window = template_syshandle("ProgInfo");
  42.   window->spritearea = (void *)1;
  43.   ((wimp_icon *)(window+1))[1].data.indirectsprite.spritearea = resspr_area();
  44.                             |
  45.      Icon number __________/
  46. }
  47. NB: This code is from SparkInfo 2.11 which has not yet been released (still
  48. under development), and icon numbers and use in the Templates may be quite
  49. significantly different to that in 2.10.
  50.  
  51. This code makes sprites in windows created from the "ProgInfo" template (which
  52. has been loaded into memory by the template part of RISC_OSLib) default to
  53. coming from the wimp sprite pool. It also says that icon 1 should take its
  54. sprite from the resspr sprite area (icon 1 is an indirected sprite only icon).
  55. This avoids the need to make assumptions about the size of window and icon
  56. blocks (I know they are unlikely to change, but what about in a year or so when
  57. we are on RISC OS 4.00 and Desktop C 5??? - hard coded values are a nightmare,
  58. and unnecessary where we have very good header files).
  59. The only thing with pointer arithmetic is that you have to think carefully
  60. about what data type is being pointed to at each stage, since +1 has a
  61. significantly different meaning for different types.
  62. -- 
  63.  _    _
  64. |_|  |||    1st Year Undergraduate, Department of Computer Science
  65. |aul | |urphy    The University of Edinburgh
  66. email: Paul.Murphy@ed.ac.uk
  67.