home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / utility / poplibsr / popup.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-19  |  6.0 KB  |  117 lines

  1. /******************************************************************************/
  2. /* @(#)    popup.h       1.0 -- standard include file for popup menu usage 09.07.88 */
  3. /*                                          */
  4. /* This header file and the corresponding shared library are in the public    */
  5. /* domain. They can be copied and distributed for non-commercial usage.       */
  6. /*                                          */
  7. /* (c) 10/1987 by    Edgar Roeder                          */
  8. /*            Liesbet-Dill-Str. 3                      */
  9. /*            D-6602 Dudweiler                      */
  10. /*            W-Germany                          */
  11. /*             E-mail: roeder@sbsvax.UUCP or                  */
  12. /*                 roeder@eansb.informatik.uni-saarland.dbp&de   */
  13. /******************************************************************************/
  14.  
  15. #define POPUP_LIB    "popup menus"
  16. #define POPUP_VERSION    1
  17.  
  18. /*
  19.  * usage of this package:
  20.  *
  21.  * menu_id = DefineMenu(str,args);
  22.  * value = DoMenu(menu_id);
  23.  * err = FreeMenu(menu_id);
  24.  *
  25.  * example:
  26.  *
  27.  * long    menu_id;
  28.  * menu_id = DefineMenu(" testmenu %t| first | second | third ");
  29.  * switch(DoMenu(menu_id)) {
  30.  *     case -2 : printf("Right mouse cancelled menu\n"); break;
  31.  *     case -1 : printf("No menu item selected\n"); break;
  32.  * ...
  33.  * }
  34.  * if(FreeMenu(menu_id)) fprintf(stderr,"Cannot free this menu");
  35.  *
  36.  */
  37.  
  38. typedef long    menu;
  39. typedef int    Value;
  40.  
  41. /******************************************************************************
  42.  *                                                                            *
  43.  * DefineMenu   returns a new menu id, which can be used to display the       *
  44.  *              defined menu or 0 if an error occured                         *
  45.  * DoMenu       returns as standard value the number of the selected item     *
  46.  *              -2 is returned if the button is pressed outside the menu      *
  47.  *              -1 is returned if no selection was made                       *
  48.  *               0 is returned if there was an error                          *
  49.  * FreeMenu     returns 0 if no error occured (menu_id is deleted)            *
  50.  * ConfigRows   sets the maximum number of rows in a column (default is 5)    *
  51.  *              and returns the old value for this                            *
  52.  * ConfigScreen sets the border of the screen usable to display popup menus   *
  53.  *              (the default values are: 0, 0, 639, 399 for mono screen)      *
  54.  *                                                                            *
  55.  *    complete definition of advanced menu formats (decreasing priority):     *
  56.  *                                                                            *
  57.  * format modifier |  required arguments  |          effect                   *
  58.  * ----------------+----------------------+---------------------------------- *
  59.  *       %t        | no additional args   | make a non selectable menu title  *
  60.  * ----------------+----------------------+---------------------------------- *
  61.  *       %v        | one int argument     | supply non standard return value  *
  62.  *                 |                      |                                   *
  63.  * ----------------+----------------------+---------------------------------- *
  64.  *       %m        | one menu identifier  | invoke submenu                    *
  65.  *                 |                      |                                   *
  66.  * ----------------+----------------------+---------------------------------- *
  67.  *       %c        | no additional args   | continue with menu if this item   *
  68.  *                 |                      | is selected or no selection       *
  69.  * ----------------+----------------------+---------------------------------- *
  70.  *       %x        | no additional args   | continue with menu if no entry    *
  71.  *                 |                      | selected                          *
  72.  * ----------------+----------------------+---------------------------------- *
  73.  *       %s        | no additional args   | selection required in this part   *
  74.  * ----------------+----------------------+---------------------------------- *
  75.  *       %o        | no additional args   | overlay this submenu (or all)     *
  76.  * ----------------+----------------------+---------------------------------- *
  77.  *       %f        | one function pointer | call function with standard       *
  78.  *                 |                      | value as single argument          *
  79.  * ----------------+----------------------+---------------------------------- *
  80.  *       %h        | one function pointer | call function if user pressed     *
  81.  *                 |                      | the Help key                      *
  82.  *                                                                            *
  83.  * if more than one format is given, the effects are occuring in order of     *
  84.  * decreasing priority (you could attach a function to a whole menu with      *
  85.  * %f and %m given in any order, or invoke the function with a non standard   *
  86.  * value given with %v %f, in %m %v format the non standard value overrides   *
  87.  * a return value of -1 if no selection occured during submenu invocation)    *
  88.  *                                                                            *
  89.  ******************************************************************************/
  90.  
  91. #ifdef LATTICE
  92. extern Procedure *PopupLibBase;
  93. #else
  94. extern Library PopupLibBase;
  95. #endif LATTICE
  96.  
  97. #ifdef POPUP_IMPLEMENTATION
  98. extern menu    DefineMenu();    /* define a popup menu                        */
  99. extern long    FreeMenu();    /* free the given menu                        */
  100. extern Value    DoMenu();    /* display the given menu and handle input    */
  101. extern int    ConfigMenu();    /* configure display parameters for defined   */
  102.                 /* menus                      */
  103.  
  104. /* this function is used by DoMenu with the actual mouse coordinates as input */
  105. extern Value    DoXYMenu();    /* display menu at given coordinates          */
  106.                 /* usage: DoXYMenu(screen_handle,menu_id,x,y) */
  107. #else
  108. #define DefineMenu        (*PopupLibBase[0])
  109. #define DoMenu            (*PopupLibBase[1])
  110. #define FreeMenu        (*PopupLibBase[2])
  111. #define DoXYMenu        (*PopupLibBase[3])
  112. #define ConfigMenu        (*PopupLibBase[4])
  113. #define ConfigRows(r)        ConfigMenu(r)
  114. #define ConfigScreen(x,y,w,h)    ConfigMenu(0,x,y,w,h)
  115. #define FormAlert        (*PopupLibBase[5])
  116. #endif
  117.