home *** CD-ROM | disk | FTP | other *** search
/ Totally for Newton 10 / PDA10.toast / mac / Packages / Programming / 2.x / TapBar SDK 1.0 / TapBar Files / TapBarModule.def next >
Encoding:
Text File  |  1996-05-09  |  8.3 KB  |  337 lines  |  [TEXT/R*ch]

  1. /*====================================================================
  2.     TapBarModule.def        TapBar Module Interface file.
  3.         
  4.     ©1995-1996 Yosuke "Basuke" Suzuki.
  5.         
  6.     Date        Who            Comment
  7.     --------------------------------------------------------------
  8.     12/16/95    Basuke        initial draft
  9.     
  10.     12/27/95    Basuke        change the structure of globals
  11.                             add palette definition
  12.     
  13.     3/15/96        Basuke        change its name as "TapBar"
  14.                             add ReallyEnsureInternal interface (debugging)
  15.                             change :ClickFinish() to ClickFinish(success)
  16.     
  17.     3/28/96        Basuke        1.0a0 release
  18.     
  19.     4/3/96        Basuke        now buttons can send Change ClickStart and 
  20.                             ClickFinish message directly to itself, not
  21.                             its parent. More to say it should do so.
  22.                             
  23.     4/6/96        Basuke        add function to display icons instead of 
  24.                             default arrows. use arrowIcons slot.
  25.                             
  26.     4/6/96        Basuke        add grouping facility. bar can have its own 
  27.                             group symbol, and buttons with same group 
  28.                             will be added into that bar. the bar with 
  29.                             group cannot be deleted by user.
  30.                             
  31.     4/10/96        Basuke        1.0a1 release
  32.     
  33.     4/11/96        Basuke        change global frame structure not to hold
  34.                             preference soup entry.
  35.                             
  36.     4/13/96        Basuke        move all static text into localization frame
  37.                             so that easily translate into Japanese using
  38.                             language preference.
  39.                             
  40.     4/14/96        Basuke        add interface to change button order and
  41.                             to turn it on and off.
  42.                             
  43.     4/15/96        Basuke        1.0b0 release
  44.     
  45.     4/16/96        Basuke        change app interface.
  46.     
  47.     4/16/96        Basuke        add dontFormat option.
  48.     
  49.     4/16/96        Basuke        1.0b1 release
  50.     
  51.     4/17/96        Basuke        add function to add buttons into status bar.
  52.     
  53.     4/17/96        Basuke        1.0b2 release
  54.     
  55.     4/18/96        Basuke        add groupOnly option to both buttons and bars.
  56.                             if this slot is true in button, it won't appear
  57.                             on bars except its group. if this slot is true
  58.                             in bar, only its group buttons will appear on it.
  59.                             
  60.     5/9/96        Basuke        1.0 release
  61.     
  62.   ====================================================================*/
  63.  
  64. // ---------------------------------------------
  65. //    kTapBarAppSym
  66. // ---------------------------------------------
  67. //        symbol of TapBar application
  68.  
  69.     constant kTapBarAppSym := '|TapBar:BASUKE|;
  70.  
  71.  
  72. // ---------------------------------------------
  73. //    kTapBarModuleRegistrySym
  74. // ---------------------------------------------
  75. //        symbol of module registry
  76.  
  77.     constant kTapBarModuleRegistrySym := '|Module:TapBar:BASUKE|;
  78.  
  79.  
  80. // ---------------------------------------------
  81. //    kReallyEnsureInternalFunc
  82. // ---------------------------------------------
  83. //        EnsureInternal only if it installed on external memory
  84.  
  85.     DefConst('kReallyEnsureInternalFunc,
  86.     func(object)
  87.     begin
  88.         local onInternal := 
  89.                     (GetVBOStore(ObjectPkgRef(object)) = GetStores()[0]);
  90.         
  91.         if onInternal then
  92.             object;
  93.         else
  94.             EnsureInternal(object);
  95.     end);
  96.  
  97.  
  98. // ---------------------------------------------
  99. //    kNotifyTapBarButtonRegistryFunc
  100. // ---------------------------------------------
  101. //        function to notify change of button registry
  102.  
  103.     DefConst('kNotifyTapBarButtonRegistryFunc,
  104.     func(what, who)
  105.     begin
  106.         local tb := GetGlobals().(kTapBarAppSym);
  107.         if tb then
  108.             tb:PrefChanged(what, who);
  109.     end);
  110.  
  111.  
  112. // ---------------------------------------------
  113. //    kGetTapBarModulePrefFunc
  114. // ---------------------------------------------
  115. //        function to get pref frame of each module
  116.  
  117.     DefConst('kGetTapBarModulePrefFunc,
  118.     func(symbol)
  119.     begin
  120.         local tb := GetGlobals().(kTapBarAppSym);
  121.         if tb then
  122.             tb:GetTapBarModulePref(symbol);
  123.         else
  124.             {};
  125.     end);
  126.  
  127.  
  128. // ---------------------------------------------
  129. //    kSetTapBarModulePrefFunc
  130. // ---------------------------------------------
  131. //        function to set pref frame of each module
  132.  
  133.     DefConst('kSetTapBarModulePrefFunc,
  134.     func(symbol, value)
  135.     begin
  136.         local tb := GetGlobals().(kTapBarAppSym);
  137.         if tb then
  138.             tb:SetTapBarModulePref(symbol, value);
  139.     end);
  140.  
  141.  
  142. // ---------------------------------------------
  143. //    kGetTapBarModuleRegistryFunc : internal use
  144. // ---------------------------------------------
  145. //        function to get module registry frame
  146.  
  147.     constant kDefaultModuleRegistry := '{
  148.         buttons:    {},        // actual button templates
  149.         prefs:        {},        // pref panel templates
  150.         palettes:    {},        // palette definitions
  151.     };
  152.  
  153.  
  154.     DefConst('kGetTapBarModuleRegistryFunc,
  155.     func()
  156.     begin
  157.         if NOT HasSlot(GetGlobals(), kTapBarModuleRegistrySym) then
  158.         begin
  159.             local sym := EnsureInternal(kTapBarModuleRegistrySym);
  160.             
  161.             GetGlobals().(sym) := TotalClone(kDefaultModuleRegistry);
  162.         end;
  163.         
  164.         GetGlobals().(kTapBarModuleRegistrySym);
  165.     end);
  166.  
  167.  
  168. // ---------------------------------------------
  169. //    kRegTapBarSymbolFunc : internal use
  170. // ---------------------------------------------
  171. //        function to register frmae into slot
  172.  
  173.     DefConst('kRegTapBarSymbolFunc,
  174.     func(frameBase, sym, frame)
  175.     begin
  176.         if sym AND frame then
  177.         begin
  178.             local registry;
  179.             
  180.             registry := (call kGetTapBarModuleRegistryFunc with ());
  181.             
  182.             if NOT HasSlot(registry, frameBase) then
  183.             begin
  184.                 frameBase := EnsureInternal(frameBase);
  185.                 registry.(frameBase) := {};
  186.             end;
  187.             
  188.             sym := EnsureInternal(sym);
  189.             registry.(frameBase).(sym) := frame;
  190.         
  191.             sym;
  192.         end
  193.     end);
  194.  
  195.  
  196. // ---------------------------------------------
  197. //    kUnRegTapBarSymbolFunc : internal use
  198. // ---------------------------------------------
  199. //        function to register frmae from slot
  200.  
  201.     DefConst('kUnRegTapBarSymbolFunc,
  202.     func(frameBase, sym)
  203.     begin
  204.         if sym then
  205.         begin
  206.             local registry := (call kGetTapBarModuleRegistryFunc with ());
  207.             
  208.             RemoveSlot(registry.(frameBase), sym);
  209.         end
  210.     end);
  211.  
  212.  
  213. // ---------------------------------------------
  214. //    kRegTapBarButtonFunc
  215. // ---------------------------------------------
  216. //        function to register button
  217.  
  218.     DefConst('kRegTapBarButtonFunc,
  219.     func(sym, button)
  220.     begin
  221.         local slot := call kRegTapBarSymbolFunc
  222.                          with ('buttons, sym, button);
  223.         
  224.         call kNotifyTapBarButtonRegistryFunc with ('buttonAdded, sym);
  225.         
  226.         return slot;
  227.     end);
  228.  
  229.  
  230. // ---------------------------------------------
  231. //    kUnRegTapBarButtonFunc
  232. // ---------------------------------------------
  233. //        function to unregister button
  234.  
  235.     DefConst('kUnRegTapBarButtonFunc,
  236.     func(sym)
  237.     begin
  238.         call kUnRegTapBarSymbolFunc with ('buttons, sym);
  239.         
  240.         call kNotifyTapBarButtonRegistryFunc with ('buttonRemoved, sym);
  241.     end);
  242.  
  243.  
  244. // ---------------------------------------------
  245. //    kRegTapBarPrefFunc
  246. // ---------------------------------------------
  247. //        function to register pref panel
  248.  
  249.     DefConst('kRegTapBarPrefFunc,
  250.     func(sym, pref)
  251.     begin
  252.         local slot := call kRegTapBarSymbolFunc
  253.                          with ('prefs, sym, pref);
  254.         
  255.         call kNotifyTapBarButtonRegistryFunc with ('prefAdded, sym);
  256.         
  257.         return slot;
  258.     end);
  259.  
  260.  
  261. // ---------------------------------------------
  262. //    kUnRegTapBarPrefFunc
  263. // ---------------------------------------------
  264. //        function to unregister pref panel
  265.  
  266.     DefConst('kUnRegTapBarPrefFunc,
  267.     func(sym)
  268.     begin
  269.         call kUnRegTapBarSymbolFunc with ('prefs, sym);
  270.         
  271.         call kNotifyTapBarButtonRegistryFunc with ('prefRemoved, sym);
  272.     end);
  273.  
  274.  
  275. // ---------------------------------------------
  276. //    kRegTapBarPaletteFunc
  277. // ---------------------------------------------
  278. //        function to register palette definition
  279.  
  280.     DefConst('kRegTapBarPaletteFunc,
  281.     func(sym, paletteDef)
  282.     begin
  283.         local slot := call kRegTapBarSymbolFunc
  284.                          with ('palettes, sym, paletteDef);
  285.         
  286.         call kNotifyTapBarButtonRegistryFunc with ('paletteAdded, sym);
  287.         
  288.         return slot;
  289.     end);
  290.  
  291.  
  292. // ---------------------------------------------
  293. //    kUnRegTapBarPaletteFunc
  294. // ---------------------------------------------
  295. //        function to unregister palette definition
  296.  
  297.     DefConst('kUnRegTapBarPaletteFunc,
  298.     func(sym)
  299.     begin
  300.         call kUnRegTapBarSymbolFunc with ('palettes, sym);
  301.         
  302.         call kNotifyTapBarButtonRegistryFunc with ('paletteRemoved, sym);
  303.     end);
  304.  
  305.  
  306. // ---------------------------------------------
  307. //    kTapBarCreateNewBarFunc
  308. // ---------------------------------------------
  309. //        function to unregister palette definition
  310.  
  311.     DefConst('kTapBarCreateNewBarFunc,
  312.     func(groupSym, barPrefFrame)
  313.     begin
  314.         if groupSym then
  315.         begin
  316.             if NOT HasSlot(barPrefFrame, 'version)
  317.              OR ClassOf(barPrefFrame.version) <> 'int then
  318.             begin
  319.                 barPrefFrame := Clone(barPrefFrame);
  320.                 barPrefFrame.version := 0;
  321.             end;
  322.             
  323.             local tb := GetGlobals().(kTapBarAppSym);
  324.             if tb then
  325.             begin
  326.                 tb:CreateNewBar(groupSym, barPrefFrame);
  327.             end
  328.             else
  329.             begin
  330.                 call kRegTapBarSymbolFunc
  331.                          with ('bars, groupSym, barPrefFrame);
  332.             end
  333.         end
  334.     end);
  335.  
  336.  
  337.