1# 2# francy: Interactive Discrete Mathematics in GAP 3# 4#! @Chapter Francy Menus 5#! Menus are agregators of actions that are represented here by <C>Callbacks</C>. 6#! Menus can have SubMenus, and are constituted by a Title and a Callback. 7#! <P/> 8#! Please see Francy-JS for client implementation. 9 10 11#! @Section Categories 12#! In this section we show all Francy Menu Categories. 13 14#! @Description 15#! Identifies <C>Menu</C> objects. 16DeclareCategory("IsMenu", IsFrancyObject); 17 18 19#! @Section Families 20#! In this section we show all Francy Menu Families. 21 22#! @Description 23#! This Family identifies all <C>Menu</C> objects 24#! @Returns <C>MenuFamily</C> 25BindGlobal("MenuFamily", NewFamily("MenuFamily", IsMenu)); 26 27 28#! @Section Representations 29#! In this section we show all Francy Menu Representations. 30 31#! @Description 32#! Checks whether an <C>Object</C> has a <C>Menu</C> internal representation. 33DeclareRepresentation("IsMenuRep", IsComponentObjectRep, [], IsMenu); 34 35#! @Description 36#! Creates a new type for <C>Menu/C> objects. 37BindGlobal("MenuObjectType", NewType(MenuFamily, IsMenu and IsMenuRep)); 38 39 40#! @Section Operations 41#! In this section we show all Francy Menu Operations. 42 43#! @Description 44#! Creates a Menu for a <C>Callback</C> 45#! Is up to the client implementation to sort out the Menu and invoke the <C>Callback</C> 46#! @Arguments IsString(title), [IsCallback] 47#! @Returns <C>Menu</C> 48DeclareOperation("Menu", [IsString, IsCallback]); 49 50#! @Description 51#! Add <C>Menu</C> to a specific <C>Menu</C> creating a Submenu. 52#! Is up to the client implementation to handle this. 53#! @Arguments IsMenu, [IsMenu, List(IsMenu)] 54#! @Returns <C>Menu</C> 55#DeclareOperation("Add", [IsMenu, IsMenu]); 56 57#! @Description 58#! Remove <C>Menu</C> from a specific <C>Menu</C>. 59#! The client should be able to handle this. 60#! @Arguments IsMenu, [IsMenu, List(IsMenu)] 61#! @Returns <C>Menu</C> 62#DeclareOperation("Remove", [IsMenu, IsMenu]); 63 64 65#! @Section Attributes 66#! In this section we show all Francy Core Attributes 67 68#! @Description 69#! A title on a <C>Menu</C> is used to identify the menu entry. 70#! @Returns <C>IsString</C> with the title of the object 71DeclareAttribute("Title", IsMenu); 72InstallMethod(Title, "menu", [IsMenu], o -> o!.title); 73#! @Description 74#! Sets the title of the <C>Menu</C>. 75#! @Arguments IsMenu, IsString 76InstallMethod(SetTitle, "menu, string", [IsMenu, IsString], function(o, s) o!.title := s; end); 77