home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsd / evntshell / !EvntShell / Extensions / FontMenu (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1995-10-22  |  7.3 KB  |  175 lines

  1.  Module FontMenu
  2.  -----------------------------------------------------------------------
  3.  FontMenu Handling Routines (version 1.04 14-Oct-95)
  4.  This library contains routines that handle the interface to the
  5.  FontMenu Relocatable Module by Joris R
  6. ling (version 1.16)
  7.  -----------------------------------------------------------------------
  8.  Structure of Data used in this module
  9.  Public Methods Supported:
  10.    FN_shell_FontMenu_Init                 Initialises module
  11.    FNshell_FontMenu_IsInitialised
  12.    FNshell_FontMenu_GetHandle
  13.    FNshell_FontMenu_OffersSystemFont
  14.    FNshell_FontMenu_GetLastSelectedFont
  15.    FNshell_FontMenu_GetNrFonts
  16.    PROCshell_AttachFontMenu
  17.    PROCshell_AttachFontSubMenu
  18.    PROCshell_FontMenu_SelectFont
  19.    PROCshell_FontMenu_AllowSystemFont
  20.    PROCshell_FontMenu_DisallowSystemFont
  21.    PROCshell_FontMenu_SelectFont
  22.  Responses to events raised by other modules
  23.    PROCshell_FontMenu_ShowMenu
  24.    PROCshell_FontMenu_Deregister
  25.  Private Methods Supported:
  26.    PROCshell_FontMenu_Init
  27.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  28.  Public routines..
  29.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  30. +"*|Start FN_shell_FontMenu_Init
  31. _shell_FontMenu_Init
  32.  Module constants
  33. /$_c_FontMenu_NotDefined%     = -1
  34. 0._c_FontMenu_SystemFont$     = "SystemFont"
  35. 1%_c_FontMenu_MaxNameLength%  = 256
  36. 2#_c_FontMenu_ValidSelFlag%   = 1
  37. 4=_c_FontMenu_ErrMess_Create$ = "Unable to create FontMenu"
  38. 5A_c_FontMenu_ErrMess_Load$   = "FontMenu module is not loaded"
  39.  Module variables
  40. 8;_m_FontMenu_Handle%           = _c_FontMenu_NotDefined%
  41. 9%_m_FontMenu_Initialised%      = 
  42. :&_m_FontMenu_LastSelectedFont$ = ""
  43. ;%_m_FontMenu_NrFontsFound%     = 0
  44. <%_m_FontMenu_OfferSystemFont%  = 
  45. @!*|Stop FN_shell_FontMenu_Init
  46. D'*|Start FNshell_FontMenu_GetNrFonts
  47. shell_FontMenu_GetNrFonts
  48. = _m_FontMenu_NrFontsFound%
  49. H&*|Stop FNshell_FontMenu_GetNrFonts
  50. L.*|Start PROCshell_FontMenu_AllowSystemFont
  51. shell_FontMenu_AllowSystemFont
  52. N$_m_FontMenu_OfferSystemFont% = 
  53. shell_FontMenu_SelectFont( _m_FontMenu_LastSelectedFont$ )
  54. R-*|Stop PROCshell_FontMenu_AllowSystemFont
  55. V1*|Start PROCshell_FontMenu_DisallowSystemFont
  56. shell_FontMenu_DisallowSystemFont
  57. X$_m_FontMenu_OfferSystemFont% = 
  58. shell_FontMenu_SelectFont( _m_FontMenu_LastSelectedFont$ )
  59. \0*|Stop PROCshell_FontMenu_DisallowSystemFont
  60. `/*|Start FNshell_FontMenu_ContainsSystemFont
  61. shell_FontMenu_OffersSystemFont
  62. b"= _m_FontMenu_OfferSystemFont%
  63. c.*|Stop FNshell_FontMenu_ContainsSystemFont
  64. g$*|Start PROCshell_AttachFontMenu
  65. *|Define Using_FontMenu
  66. shell_AttachFontMenu( wh%, menuic%, display_ic%, sel_fn$, maker_fn$ )
  67. shell_FontMenu_Init
  68.  "FontMenu_Select", "" + 
  69. 0, _m_FontMenu_OfferSystemFont% 
  70.  , _m_FontMenu_Handle%
  71.  wh% > 0 
  72.  menuic% >= 0 
  73. shell_IconSetButtonType( wh%, menuic%, 3 )
  74. shell_EvntAdd_PopUpMenu( 
  75. shell_GetWindowIdentifier( wh% ), menuic%, display_ic%, _POPUP_TYPE_FONTMENU, sel_fn$, maker_fn$, _POPUP_TYPE_FONTMENU )
  76.  PROCshell_Tracef0( "AttachFontMenu:Attaching font menu" )
  77. w#*|Stop PROCshell_AttachFontMenu
  78. {'*|Start PROCshell_AttachFontSubMenu
  79. *|Define Using_FontMenu
  80. shell_AttachFontSubMenu(item%,warn_fn$,sel_fn$)
  81.  itemstart%,menu%,temp%,ctr%
  82. shell_FontMenu_Init
  83.  "FontMenu_Select",""+
  84. 0, _m_FontMenu_OfferSystemFont% 
  85.  ,menu%
  86.  "MenuUtil_SubMenu",item%,menu%
  87.  "MenuUtil_Warning",,
  88.  Store menu ptr in shell memory..
  89. _U%!252=menu%
  90. shell_EventListMenuWarn(item%,menu%,warn_fn$,sel_fn$)
  91. *|ifdef PROCshell_TraceInit
  92. shell_Tracef0("AttachFontSubMenu:Attaching font menu &"+
  93. ~menu%)
  94. *|endif
  95. &*|Stop PROCshell_AttachFontSubMenu
  96. )*|Start PROCshell_FontMenu_SelectFont
  97. shell_FontMenu_SelectFont( fontname$ )
  98.  fontname$ = "" 
  99.  "FontMenu_Select", "" + 
  100. ( 0 ), _m_FontMenu_OfferSystemFont% 
  101.  , _m_FontMenu_Handle%
  102.  "FontMenu_Select",fontname$, _m_FontMenu_OfferSystemFont% 
  103.  , _m_FontMenu_Handle%
  104. -_m_FontMenu_LastSelectedFont$ = fontname$
  105. *|ifdef TraceInit
  106. shell_Tracef0("FontMenuSelectFont:Font is '"+fontname$+"'")
  107. *|endif
  108. (*|Stop PROCshell_FontMenu_SelectFont
  109. 0*|Start FNshell_FontMenu_GetLastSelectedFont
  110. shell_FontMenu_GetLastSelectedFont
  111. #= _m_FontMenu_LastSelectedFont$
  112. /*|Stop FNshell_FontMenu_GetLastSelectedFont
  113. **|Start FNshell_FontMenu_IsInitialised
  114. shell_FontMenu_IsInitialised
  115. = _m_FontMenu_Initialised%
  116. )*|Stop FNshell_FontMenu_IsInitialised
  117. &*|Start FNshell_FontMenu_GetHandle
  118. shell_FontMenu_GetHandle
  119. = _m_FontMenu_Handle%
  120. %*|Stop FNshell_FontMenu_GetHandle
  121. #*|Start FNshell_FontMenu_Decode
  122. shell_FontMenu_Decode( select_block% )
  123.  menu_block%, fontmenuflag%, selected_font$
  124. Emenu_block% = 
  125. shell_HeapBlockFetch( _c_FontMenu_MaxNameLength% )
  126.  "FontMenu_DecodeFontMenu", select_block%, menu_block% 
  127.  fontmenuflag%
  128. selected_font$ = ""
  129.  fontmenuflag% = _c_FontMenu_ValidSelFlag% 
  130.  sensible selection made..
  131. 6  selected_font$ = 
  132. shell_GetString( menu_block% )
  133.  selected_font$ = "" 
  134. 0    selected_font$ = _c_FontMenu_SystemFont$
  135. shell_FontMenu_SelectFont( selected_font$ )
  136. Evnts_GetLastMouseButton = _MSE_ADJUSTBUT 
  137. _    
  138.  "Wimp_CreateMenu", , 
  139. shell_MenuLastHandle, 
  140. shell_MenuLastXPos, 
  141. shell_MenuLastYPos
  142. shell_HeapBlockReturn( menu_block% )
  143. = selected_font$
  144. "*|Stop FNshell_FontMenu_Decode
  145.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  146.  Responses to events raised by other modules..
  147.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  148. )*|Start PROCshell_FontMenu_Deregister
  149. shell_FontMenu_Deregister
  150.  Called when application closes down. Allows FontMenu to kill
  151.  itself when the number of users falls to zero.
  152.  "XFontMenu_Release"
  153. (*|Stop PROCshell_FontMenu_Deregister
  154. '*|Start PROCshell_FontMenu_ShowMenu
  155. shell_FontMenu_ShowMenu( _Q%, menu_handle%, _window_handle%, _icon_handle%, popup% )
  156. shell_HandleMenuOpen( _Q%, _m_FontMenu_Handle%, _window_handle%, _icon_handle%, 
  157. &*|Stop PROCshell_FontMenu_ShowMenu
  158.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  159.  Private module routines
  160.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  161. #*|Start PROCshell_FontMenu_Init
  162. shell_FontMenu_Init
  163.  flags%
  164.  _m_FontMenu_Initialised% = 
  165.  ( "RMEnsure FontMenu 1.16 Error " + _c_FontMenu_ErrMess_Load$ )
  166.  "XFontMenu_Create" 
  167.  _m_FontMenu_NrFontsFound%;flags%
  168.  flags% 
  169. )    
  170.  99, _c_FontMenu_ErrMess_Create$
  171. $    _m_FontMenu_Initialised% = 
  172. $    
  173. shell_ExReg_FontMenu_Loaded
  174. "*|Stop PROCshell_FontMenu_Init
  175.