home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / DLOGManager 1.02 / Source Code / CGestisciMenu_v003.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-14  |  6.3 KB  |  244 lines  |  [TEXT/KAHL]

  1. /*****
  2.  *    CGestisciMenu_v003.h
  3.  *
  4.  *    Gestisce una risorsa di tipo 'MENU'.
  5.  *    © 1994-96 Francesco Cadili.
  6.  *
  7.  ****/
  8. #ifndef __CGestisciMenu__
  9. #define __CGestisciMenu__
  10. #include <Types.h>
  11. #include <Menus.h>
  12. #include <Windows.h>
  13. #include <Dialogs.h>
  14.  
  15. class CMenuRec
  16. {
  17.     friend class CGestisciMenu;
  18.     protected:
  19.         MenuHandle    menu;                //    menu pointer
  20.         short        menuID;                //    menu ID
  21.         short        fatherMenuID;        //    the ID of the father
  22.         short        fatherItemPos;        //    the position in the father (v003)
  23.         short        menuFlag;            //    bit (7-0) the position in the menu bar.
  24.                                         //    bit 8 (inMenuBar_mask) if the menu is in the 
  25.                                         //        MBAR. (v001)
  26.                                         //    bit 9 (readFromResource_mask) if the menu is 
  27.                                         //        read from the resource file (v001).
  28.                                         //    The <menuFlag> replaces the field <inMenuBar>
  29.                                         //        and <readFromResource>. (v002)
  30.     public:
  31.         enum {pos_mask = 0xFF, inMenuBar_mask = 0x100, readFromResource_mask = 0x200};
  32.         
  33.         /*** constructor
  34.          *
  35.          ****/
  36.         CMenuRec(void);
  37.         
  38.         /*** destructor
  39.          *
  40.          ****/
  41.         ~CMenuRec(void);
  42.  
  43.         /*** "Dispose(Boolean delete)
  44.          *
  45.          *    Toglie un menu dalla barra dei menu. Il menu viene eliminato
  46.          *    dalle risorse se delete è true. (v001)
  47.          *    
  48.          *    Val OUTPUT:    true se errore, false altrimenti.
  49.          *
  50.          ****/
  51.         Boolean Dispose(Boolean del);
  52.  
  53.         /***
  54.          *    menuData(&menuHdl, &menuID)
  55.          *
  56.          *    Get the data of the choice.
  57.          *
  58.          *    Par OUTPUT:    <menuHdl> the handle of the menu.
  59.          *                <menuID> the ID of the menu.
  60.          *
  61.          ***/
  62.         Boolean menuChoiceData(MenuHandle *menuHdl, short *menuID);
  63.  
  64.         /***
  65.          *    Link a submenu to a item in the main menu.
  66.          *
  67.          *    Par INPUT:    <fatherID>    the ID of the main menu,
  68.          *                <posInFM>    the position in the main menu,
  69.          *                <subID>    the ID of the submenu,
  70.          *                <pos>    the position in the subMenu.
  71.          ****/
  72.         Boolean getCurrentPos(short *fatherID, short *posInFM, short *subID);
  73.  
  74.         /***
  75.          *    DisegnaItem(theWPtr, menuData);
  76.          *
  77.          *    Disegna il campo selezionato dal pop up.
  78.          *    
  79.          ****/
  80.         void DrawMenu(WindowPtr theDialog, short itemInDialog, Boolean drawText, 
  81.                       short itemInMenu);
  82.  
  83.         /***
  84.          *    Link a submenu to a item in the main menu.
  85.          *
  86.          *    Par INPUT:    'elOrdHdl'    the menu data,
  87.          *                <fatherID>    the ID of the main menu,
  88.          *                <fatherItemPos>    the position in the main menu,
  89.          *                <subMenuID>    the ID of the submenu,
  90.          *                <subMenu>    the subMenu handle,
  91.          *                <readFromRes>    true if the menu is read from a resource file.
  92.          ****/
  93.         Boolean InsertSubmenu(short fatherID, short fatherItemPos, short subMenuID,
  94.                               MenuHandle subMenu, Boolean readFromRes, short subMenuNum);
  95. };
  96.  
  97. class CGestisciMenu
  98. {
  99.     private:
  100.         /*** "InitData_gestMenu(kPopUpID, itemInDialog)"
  101.          *
  102.          *    Inizializza i dati relativi al DLOG.
  103.          *    (Presuppone che i primi dati della struttura globale
  104.          *    siano presenti, strongly modify on v002).
  105.          *
  106.          *    Par INPUT:    'textFont' la fonte del campo text edit,
  107.          *                'textHeight' l'altezza del campo text edit.
  108.          *    Val OUTPUT:    TRUE se errore, FALSE altrimenti.
  109.          *
  110.          ***/
  111.         Boolean InitData(short kPopUpID, short itemInDialog);
  112.  
  113.         /***
  114.          *    setDefault_gestMenu();
  115.          *
  116.          *    set the default value. (v002)
  117.          *
  118.          ***/
  119.         Boolean setDefault(void);
  120.  
  121.         /***
  122.          *    menu = getSubPopUp(item);
  123.          *
  124.          *    From version 002 the main menu is in the submenu list, so if NULL is
  125.          *    returned an error occurs.
  126.          *
  127.          *    Par INPUT:    <menuID> the menu ID.
  128.          *    Par OUTPUT:    <*pos> the position of the menu in the menu array (from 0 to 255)
  129.          *    Val OUTPUT:    the menu handle of the menu with ID <menuID>.
  130.          ***/
  131.         MenuHandle getSubPopUp(short menuID, short *pos);
  132.  
  133.         /***
  134.          *    Link a submenu to a item in the main menu.
  135.          *
  136.          *    Par INPUT:    'elOrdHdl'    the menu data,
  137.          *                <fatherID>    the ID of the main menu,
  138.          *                <fatherItemPos>    the position in the main menu,
  139.          *                <subMenuID>    the ID of the submenu,
  140.          *                <subMenu>    the subMenu handle,
  141.          *                <readFromRes>    true if the menu is read from a resource file.
  142.          ****/
  143.         Boolean InsertSubmenu(short fatherID, short fatherItemPos, short subMenuID,
  144.                               MenuHandle menu, Boolean readFromRes);
  145.  
  146.     protected:
  147.         CMenuRec    ***subMenu;        //    The field <kPopUpID>, <popUpMenu>
  148.                                     //    and <inMenuBar> are in **subMenu. (v002)
  149.         DialogPtr     theDialog;
  150.  
  151.     public:
  152.         short        itemInDialog;
  153.         long        lastValore;
  154.         short        itemInMenu;        //    the position of last item chosen.
  155.         short        posMenuChosen;    //    The fields <sceltaPopUp> and <sceltaID>
  156.                                     //    are replaced by <posMenuChosen>. (v002)
  157.  
  158.         /**** constructor();
  159.          *
  160.          ****/
  161.         CGestisciMenu(void);
  162.  
  163.         /****
  164.          *    result = Alloca_gestMenu(kPopUpID);
  165.          *
  166.          *    Revisoned (use modified SetErrorData)
  167.          *
  168.          *    Alloca la struttura dati "gestElOrdRec" nello Heap.
  169.          *
  170.          *    Par INPUT:    'kPopUpID' l'ID del Menu.
  171.          *                'itemInDialog' item nel dialog.
  172.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  173.          *
  174.          ****/
  175.         Boolean    IGestisciMenu(DialogPtr theDialog, short kPopUpID, short itemInDialog);
  176.         
  177.         /*** Dispose()
  178.          *
  179.          *    Dealloca la struttura dati.
  180.          *    Nota:    da chiamare prima della deallocazione del
  181.          *            dialog <theDialog>.
  182.          *
  183.          ***/
  184.         void Dispose(void);
  185.  
  186.         /***
  187.          *    clickInPopUp(theWPtr, menuData, drawText);
  188.          *
  189.          *    Handle a mouse event in the popUp field.
  190.          *    Draw a check on the item selected. (v001)
  191.          *    
  192.          ****/
  193.         Boolean CGestisciMenu::clickInPopUp(Boolean    drawText);
  194.  
  195.         /***
  196.          *    Link a submenu to a item in the main menu.
  197.          *
  198.          *    Par INPUT:    <fatherID>    the ID of the main menu,
  199.          *                <posInFM>    the position in the main menu,
  200.          *                <subID>    the ID of the submenu,
  201.          *                <pos>    the position in the subMenu.
  202.          ****/
  203.         Boolean getCurrentPos(short *fatherID, short *posInFM, short *subID,
  204.                               short *pos);
  205.  
  206.         /***
  207.          *    menuData(&menuHdl, &menuID)
  208.          *
  209.          *    Get the data of the choice.
  210.          *
  211.          *    Par OUTPUT:    <menuHdl> the handle of the menu.
  212.          *                <menuID> the ID of the menu.
  213.          *
  214.          ***/
  215.         Boolean menuChoiceData(MenuHandle *menuHdl, short *menuID, short *pos);
  216.  
  217.         /***
  218.          *    menuData(&menuHdl, &menuID)
  219.          *
  220.          *    Get the data of the menu.
  221.          *
  222.          *    Par INPUT:    <elOrdHdl> the menu structure.
  223.          *    Par OUTPUT:    <menuHdl> the handle of the menu.
  224.          *                <menuID> the ID of the menu.
  225.          *
  226.          ***/
  227.         Boolean menuData(MenuHandle *menuHdl, short *menuID);
  228.  
  229.         /***
  230.          *    DisegnaItem(theWPtr, menuData);
  231.          *
  232.          *    Disegna il campo selezionato dal pop up.
  233.          *    
  234.          ****/
  235.         void DrawMenu(Boolean drawText);
  236.         
  237.         /***
  238.          *
  239.          *    readItemInMenu();
  240.          *
  241.          ***/
  242.         short readItemInMenu(void);
  243. };
  244. #endif