home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / fonts / a_q / fontpool / PoolSWIs < prev   
Text File  |  1995-01-10  |  15KB  |  223 lines

  1. FontPool v0.12
  2. ------------------------
  3. © Eirik Hansen 1994/1995
  4. ------------------------
  5.  
  6. This utility is Shareware! It means that you should READ AND OBEY THE TERMS STATED AT THE END OF THE FILE 'PoolNB!'.
  7.  
  8. This document:
  9.  - first lists the SWIs that are available in FontPool v0.12
  10.  - then explains how to use FontPool in a program
  11.  - finally lists bug-fixes and other changes/updates.
  12.  
  13. ===============================================================================
  14.                      SWIs available in FontPool v0.12
  15. -------------------------------------------------------------------------------
  16.  
  17. In the following when you see the phrase:
  18.  
  19.  - 'Possibly new menu-pointer' it means that the internal font-menu had to
  20.    be re-built because the Font$Path had changed - this resulting in a different
  21.    menu-pointer.
  22.  
  23.  - 'Alphabetize value' it means how long the menu can grow before font-families
  24.    starting with the same initial character will be collected in a sub-menu.
  25.  
  26. -------------------------------------------------------------------------------
  27.   FontPool_Hello
  28. ------------------
  29.   In:   If bit#31 of R1 is set it means it contains some configuration
  30.         concerning the presentation of the menus as follows:
  31.            bits#0-3    fg col to use on selected items     def. 7
  32.            bits#4-7    bg..                                def. 0
  33.            bits#8-11   fg col to use on unselected items   def. 7
  34.            bits#12-15  bg..                                def. 0
  35.               The selected menu-items will always be ticked - even if the
  36.               specified colour is not the default.
  37.            bits#16-19  'Alphabetize value' for the menu.   def. 12
  38.                        This is to make the programmer able to reconfigure the
  39.                        font-menu if a user with eg. a huge multisync screen
  40.                        should want a longer menu. This value is probably most
  41.                        useful if set with FontPool_Configure (below) because
  42.                        you can there force the menu to be re-built.
  43.            bits#20-30  Reserved
  44.            bit#31      must be set or this word is ignored!
  45.  
  46.   Out:  R0 -> Menu-pointer.
  47.  
  48. Every client should call this SWI once on startup and FontPool_Goodbye when it terminates (or does not need FontPool anymore). R1 overwrites any earlier configuration that might be present if bit#31 is set - else R1 is ignored and the previous configuration reigns. Note that the value for 'alphabetisation' won't come into effect until the font-menu is next built. Calling this SWI by itself does not automatically regenerate the menu. (To force it to be regenerated use FontPool_Configure.)
  49.  
  50. -------------------------------------------------------------------------------
  51.   FontPool_Goodbye
  52. --------------------
  53.   In:  -
  54.  
  55.   Out: -
  56.  
  57. If there are no more clients using FontPool, the internal menu-structure is forgotten and the memory is returned to the RMA.
  58.  
  59. -------------------------------------------------------------------------------
  60.   FontPool_Configure
  61. ----------------------
  62.   In:   R1 = Same as for FontPool_Hello (above). Note that bit#31 must be set
  63.              or R1 is ignored!
  64.         R2 = TRUE  => The menu is rebuilt instantly by (re-)reading the
  65.                       available fonts from disc.
  66.            = FALSE => the menu is not rebuilt until FontPool detects a change
  67.                       in the number of available fonts.
  68.         R3 -> FontName for font-menu font. If system-font is required R3
  69.               should point to a null-string.
  70.            =  0 => Ignored!
  71.         R4 =  &xxxyyyhh  where
  72.                  xxx = x-point size (*16)
  73.                  yyy = y-point size (*16)
  74.                   hh = Menu-item height. Since small values would make the
  75.                        menu unreadable, values 0 through 7 are reserved for
  76.                        special actions:
  77.                      = 0 => check strings before deciding height (will be
  78.                             somewhat more compact than =1).
  79.                      = 1 => use natural font-height (line-spacing)
  80.  
  81.                          The difference between a value of 0 and 1 becomes
  82.                          apparent if you try eg. the font 'Portrhouse.Standard'
  83.                          (at size 10).
  84.  
  85.                      2-7 are reserved for future expansion. (Might in the
  86.                          future be used to specify if the given font should
  87.                          apply to either selected or unselected menu-items.
  88.                          This way the selected font can be 'highlighted' by
  89.                          using bold or italic.)
  90.  
  91.               R4 is used only if R3 is not 0!
  92.  
  93.   Out:  R0 -> Possibly new menu-pointer.
  94.  
  95. Note that the menu MUST be rebuilt if changes to the alphabetisation value is to come into effect. This means that bit#31 of the configuration word (in R1) must be set and R2 must be TRUE. (The alphabetisation value is the only parameter that requires the font-menu to be rebuilt before it is actually applied to the menu.)
  96.  
  97. You can force the menu to be re-built at ANY time without changing the configuration by calling with R1=0 (actually bit#31 clear) and R2=TRUE. This is to aid RISC OS 3 programmers. This feature would only be rarely needed since re-reading the menu is probably best deferred until the user actually needs to access the font-menu (ie. when either of FontPool_Create(Sub)Menu is called).
  98.  
  99. Note that if an anti-aliased font is specified the forground and background colours will always be black on white.
  100.  
  101. -------------------------------------------------------------------------------
  102.   FontPool_CreateMenu
  103. -----------------------
  104.   In:   R1 can be any of the following:
  105.            = Handle of font to be ticked
  106.            ->FontName  (This is necessary because the old font manager maps 
  107.                        font-handles to different names than what is produced
  108.                        by Font_ListFonts.)
  109.            = -1 => do not tick any
  110.            =  0 => do not tick any
  111.         R2 = x of top-left corner of menu.
  112.         R3 = y..
  113.         R4 ->Parent menu or
  114.            = 0 => use font-menu directly.
  115.  
  116.   Out:  R0 -> Possibly new menu-pointer.
  117.  
  118. R4 might seem superflous, but it is meant to be used if the user does a menu-selection with ADJUST (to make the menu stay on screen) and the font-menu was opened with FontPool_CreateSubMenu below. You then specify the root-menu in R4 to reproduce the full menu-structure.
  119.  
  120. -------------------------------------------------------------------------------
  121.   FontPool_CreateSubMenu
  122. --------------------------
  123.   In:   R1 can be any of the following:
  124.            = Handle of font to be ticked
  125.            ->FontName
  126.            = -1 => do not tick any
  127.            =  0 => do not tick any
  128.         R2 = x of top-left corner of menu.
  129.         R3 = y..
  130.         R4 ->Parent menu or
  131.            = 0 => use font-menu directly.
  132.  
  133.   Out:  R0 -> Possibly new menu-pointer.
  134.  
  135. If R1 > 255 on entry it is taken as a pointer to a font-name, else it is either a font-handle or null. R1 can also point to a null-string in which case it is the same as calling with R1=0.
  136.  
  137. -------------------------------------------------------------------------------
  138.   FontPool_MenuSelection
  139. --------------------------
  140.   In:   R1 ->Menu data-structure. or
  141.            = 0 => The top level menu was the font-menu itself.
  142.         R2 ->Block as returned by Wimp_Poll(9) - list of MenuSelections
  143.         R3 ->Buffer where to put FontName or
  144.            = 0 => Use internal buffer for FontName and return pointer in R3.
  145.  
  146.   Out:  If the exact menu-item you selected was ticked then
  147.            R0 = FALSE (can be regarded as if the system font is selected)
  148.            R3 = bogus (actually ->FontName on entry)
  149.         else
  150.            R0 = TRUE
  151.            R3 ->FontName (which might be the same as given on entry)
  152.  
  153. If it is deduced that the user clicked on an item not in the font-menu, it will be taken as a deselect-all-fonts command (ie. it returns with R0=FALSE & R3=?).
  154.  
  155. If R3=0 on entry a copy of the returned name should be taken since the internal buffer might be overwritten.
  156.  
  157. ===============================================================================
  158.      The following is an explanation of how to use FontPool in a program.
  159. -------------------------------------------------------------------------------
  160.  
  161. FontPool_Hello & FontPool_Goodbye
  162. ---------------------------------
  163. When FontPool_Hello is called (which would in most cases be when an application starts up), the internal font-menu is built (and the memory 'shrinkwrapped' around it). It is only built, of course, if no font-menu already exists in memory. Calling FontPool_Hello also increases an internal 'client-counter'. This counter is decreased every now and then... just kidding!.. it is decreased when FontPool_Goodbye is called. FontPool_Goodbye should be called when an application no longer needs the services of FontPool (eg. when the application terminates). So when there are no more FontPool clients, the internal font-menu is forgotten about, and the memory occupied by the font-menu is returned to the RMA.
  164.  
  165.  
  166. In between FontPool_Hello and FontPool_Goodbye there are three SWIs available to utilise the font-menu. These SWIs are:
  167.  
  168.    FontPool_CreateMenu
  169.    FontPool_CreateSubMenu
  170.    FontPool_MenuSelection
  171.  
  172. FontPool_CreateMenu
  173. -------------------
  174. When an application wants to show the font-menu directly, FontPool_CreateMenu would be called. This is similar to calling Wimp_CreateMenu and simply displays the full menu at the coordinates specified. In addition to the screen-position, FontPool can be instructed to tick a specified font (eg. the applications current font). This is done by either inputting the font's handle or its name (as read by Font_ListFonts, and also returned by FontPool_MenuSelection below). If a handle is given, it is converted to a font-name by means of Font_ReadDefn. The name is then matched with those currently available in the internal font-menu. If a match is detected, the font is ticked (and possibly coloured).
  175.  
  176. NOTE that the font-handle way is not safe with old FontManagers. This is because Font_ReadDefn might return a different name than Font_ListFonts did when reading in the menu. The net result is that no font will then be ticked. So for compatibility - use the font-name when instructing FontPool to tick a font.
  177.  
  178. FontPool_CreateSubMenu
  179. ----------------------
  180. FontPool_CreateSubMenu makes it possible to attach the font-menu to another menu-item in a higher level menu (this would in most cases be the way applications show their font-menu). Since the available fonts might change between calls to FontPool (because the Font$Path has changed) FontPool_CreateSubMenu should be called as a result of a Msg_SubMenuWarning. Ie. the menu-entry that is to reveal the font-menu should have bit#3 in its item flags set so that the wimp generates a message when the mouse moves over the item.
  181.  
  182. FontPool_MenuSelection
  183. ----------------------
  184. When the application detects a menu-selection in the font-menu it should call FontPool_MenuSelection with pointers to both the menu-structure and the block returned by Wimp_Poll (reason code 9 - list of menu-selections). The menu-structure pointer can be 0 if the font-menu was opened directly (ie. by using FontPool_CreateMenu). If it was opened indirectly (by the FontPool_CreateSubMenu procedure described above) you need to input the pointer to the root-menu (which is one the application has created itself). This is so FontPool can make sense of the list of menu-selections that is returned in Wimp_Poll and return the correct font-name. On exit from FontPool_MenuSelection you are told if there is a font ticked, and if there is, the name of the font is returned. Note that if the user selects (clicks) the item the font-menu is attached to (ie. one level above the actual font-menu) it is taken as a deselect-all-fonts command. This is deduced by the list of menu-selections passed to FontPool_MenuSelection.
  185.  
  186. NOTE that it is completely up to the application programmer to decide what to do when FontPool_MenuSelection returns telling you that there is no font currently selected (when the user clicked on an already selected font). The programmer could then either 'keep' the currently selected font, and pass it on to FontPool the next time the menu is opened to make sure it is ticked. Or she could use this as an indication that the system-font should be used instead. Or he could decide to hang upside-down for a few minutes to get the blood back into his bewildered pale face while willing the font to return.
  187.  
  188. FontPool keeps no internal reference of which font is currently selected (since there can be many clients). This gives more freedom to the programmer.
  189.  
  190. FontPool_Configure
  191. ------------------
  192. This SWI allows you to change FontPool's configuration at any time. The details are found above. Keep in mind though that changing the configuration will affect all applications using FontPool! This might sound as a drawback at first, but the user is actually likely to want the font-menu to look similar (if not identical) in all applications. Also note that FontPool_Configure is the only call that can alter the font used when displaying the menu.
  193.  
  194.  
  195. NOTE1
  196. -----
  197. Two points concerning FontPool_Hello, _Configure, _CreateMenu and _CreateSubMenu:
  198.  
  199. 1) They might return with an error if the FontManager is not available, or the Font$Path is stupid. This error should probably be trapped (and ignored) during the startup-process of the application (_Hello). If not, the application is likely to terminate before it has got its wheels in motion.
  200.  
  201. 2) On exit a pointer to the internal menu-structure is returned. This is important to note if you are displaying the menu by means of FontPool_CreateSubMenu since the submenu-pointer should be updated in the relevant higher level menu-item. If this is not done FontPool_MenuSelection can go horribly wrong !!  The pointer can change between these calls due to more fonts becoming available.
  202.  
  203. NOTE2
  204. -----
  205. If the user selects (clicks) on a non-leaf item in the menu - and the item is not selected (ticked), it is regarded as selecting the top-most item(s) in the rest of the selected item's submenu(s). So clicking directly on the item 'Trinity' is regarded as selecting 'Trinity.Bold.(Plain)', and the font-name returned from FontPool_MenuSelection will be 'Trinity.Bold'.
  206.  
  207. NOTE3
  208. -----
  209. The SWI chunk base number was picked 'semi-random' and was not obtained from Acorn. (The base-number was 'borrowed' from an elderly module that, as far as I know, was never used. If someone out there should experience a clash, please inform me, and I might ask Acorn, the speed-demons, for one.)
  210.  
  211. ===============================================================================
  212.                               Fixes and updates
  213. -------------------------------------------------------------------------------
  214. 09.01.95 (v0.12)  Now discriminates between (seemingly) same font-type.
  215.                   Meaning: eg. the types 'Medi' and 'Medium' are now correctly
  216.                            considered different.
  217.  
  218. 09.01.95 (v0.12)  FontPool_Configure now returns the correct font-menu pointer
  219.                   even if called with R2=0 (don't rebuild menu).
  220.  
  221. 10.01.95 (v0.12)  FontPool_Configure can now take extra parameters to tell the
  222.                   font-menu itself to use an anti-aliased font.
  223.