home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / gcc / !GCC / patches / DeskLib / h / PopUp < prev    next >
Encoding:
Text File  |  1994-10-03  |  9.5 KB  |  323 lines

  1. /*
  2.  *  ####             #    #     # #
  3.  *  #   #            #    #       #          The FreeWare C library for
  4.  *  #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.  *  #   # #  # #     # #  #     # #  #   ___________________________________
  6.  *  #   # ####  ###  ##   #     # #  #
  7.  *  #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.  *  ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.  *  ________________________________________________________________________
  10.  *
  11.  *  File:    PopUp.h
  12.  *  Author:  Copyright © 1993 Jason Williams
  13.  *  Version: 1.00 (20 May 1993)
  14.  *  Purpose: Low and high-level veneers, typedefs for the PopUp system.
  15.  *
  16.  *  NOTE:
  17.  *  The PopUp system requires support of 2 Wimp message numbers. These
  18.  *  should be integrated into Wimp.h so that you can use:
  19.  *    event->data.message.popupxxx. ...
  20.  *
  21.  *  However, to do this requires permanent wiring of the folowing typedefs
  22.  *  into Wimp.h, which is undesirable if you aren't using PopUps in every
  23.  *  .c file, as it will have a bad effect on compile time/memory use.
  24.  *
  25.  *  Thus, I recommend that you simply #include this file as needed, and
  26.  *  cast the generic message data type from Wimp.h into the specific type
  27.  *  of the message as necessary, e.g.
  28.  *
  29.  *  case message_POPUPSTATE:
  30.  *  {
  31.  *    message_popupstate *state;
  32.  *    state = (message_popupstate *) &event->data.message.data;
  33.  *    switch (state->handle) ...
  34.  */
  35.  
  36.  
  37. #ifndef __dl_popup_h
  38. #define __dl_popup_h
  39.  
  40. #ifndef __dl_wimp_h
  41. #include "Wimp.h"
  42. #endif
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. typedef int popup_handle;
  49.  
  50.  
  51. /*  The following are defined in Wimp.h
  52.  *    message_POPUPRQ      0x46D40
  53.  *    message_POPUPREQUEST 0x46D40
  54.  *    message_POPUPSTATE   0x46D41
  55.  *    message_POPUPCLOSED  0x46D42
  56.  */
  57.  
  58. /*
  59.  *  PopUp flag byte: Values of flag bits
  60.  *  Preferably, use the 'all inclusive' values below instead
  61.  */
  62. #define popup_ISLEAF   (0x01)
  63. #define popup_ISSTATIC (0x02)
  64.  
  65.  
  66. /*
  67.  *  All-inclusive PopUp flag byte values
  68.  */
  69. #define popup_STANDALONE (0x00)
  70. #define popup_MENULEAF   (0x01)
  71. #define popup_STATIC     (0x02)
  72.  
  73. /*
  74.  *  PopUp-specific data for SWI PopUp_Open and Message_PopUpState blocks...
  75.  *  See the PopUp documents for details.
  76.  */
  77. typedef struct
  78. {
  79.   int mul, div;
  80.   int minmul, maxmul;
  81.   int mindiv, maxdiv;
  82. } popup_magnify;
  83.  
  84. typedef struct
  85. {
  86.   char appname[32];
  87.   char purpose[32];
  88.   char author[32];
  89.   char version[32];
  90. } popup_proginfo;
  91.  
  92. typedef struct
  93. {
  94.   struct
  95.   {
  96.     unsigned int cancel     : 1;    /* Has cancel button / cancel was chosen */
  97.     unsigned int ok         : 1;    /* Has OK button     / OK was chosen     */
  98.     unsigned int reserved   : 6;
  99.     unsigned int userhandle : 24;   /* Put anything you find useful here     */
  100.   } flags;
  101.   char oktext[12];                  /* Text for OK button (if any)           */
  102.   char canceltext[12];              /* Text for cancel button (if any)       */
  103.   char appname[12];                 /* Application name for window titlebar  */
  104.   char message[188];                /* Text message to report to the user    */
  105. } popup_report;
  106.  
  107. typedef struct
  108. {
  109.   char iconsprite[12];              /* Save As file icon's Iconsprite name   */
  110.   char filename[212];               /* Default text to put into writable icn */
  111. } popup_saveas;                     /* NOTE a different block is RETURNED... */
  112.  
  113. typedef struct
  114. {
  115.   struct
  116.   {                                /* If TRUE:           | If FALSE:         */
  117.     unsigned int wasdragged : 1;   /* File was dragged   | OK was 'pressed'  */
  118.     unsigned int shiftdown  : 1;   /* SHIFT key was down | SHIFT key wasn't  */
  119.     unsigned int reserved   : 30;
  120.   } flags;
  121.  
  122.   int  reserved;
  123.   char filename[212];              /* if (wasdragged) this is a leafname,
  124.                                     * else            this is a full pathname
  125.                                     */
  126. } popup_saveasreturn;
  127.  
  128. typedef struct
  129. {
  130.   char colour;                     /* Colour 0..15 */
  131. } popup_wimpcolour;
  132.  
  133.  
  134. typedef struct
  135. {
  136.   unsigned int transparency : 8;
  137.   unsigned int red          : 8;
  138.   unsigned int green        : 8;
  139.   unsigned int blue         : 8;
  140. } colour_rgb;
  141.  
  142. typedef struct
  143. {
  144.   unsigned int value        : 8;    /* 0..255 */
  145.   unsigned int saturation   : 8;    /* 0..255 */
  146.   unsigned int hue          : 16;   /* 0..359 */
  147. } colour_hsv;
  148.  
  149. typedef struct
  150. {
  151.   unsigned int key          : 8;
  152.   unsigned int yellow       : 8;
  153.   unsigned int magenta      : 8;
  154.   unsigned int cyan         : 8;
  155. } colour_cmyk;
  156.  
  157. /*
  158.  *  Colour model numbers. See below for examples of use
  159.  */
  160. #define popuptc_RGB  0
  161. #define popuptc_HSV  1
  162. #define popuptc_CMYK 2
  163.  
  164. /*  Values to OR in to flag value for no transparency, 1 transparency value
  165.  *  ('none' option) and full transparency (256 transparency levels)
  166.  */
  167. #define popuptc_TRANSPARENT0   0x00000
  168. #define popuptc_TRANSPARENT1   0x10000
  169. #define popuptc_TRANSPARENT256 0x20000
  170.  
  171. /*  Examples:
  172.  *  'Draw' style colour:   colourmodel  = popuptc_RGB | popuptc_TRANSPARENT1;
  173.  *  Full transparency HSV: colour model = popuptc_HSV | popuptc_TRANSPARENT256;
  174.  */
  175.  
  176. typedef struct
  177. {
  178.   int colourmodel;                /* eg: popuptc_RGB + popuptc_TRANSPARENCY1 */
  179.   union
  180.   {
  181.     colour_rgb  rgb;
  182.     colour_hsv  hsv;
  183.     colour_cmyk cmyk;
  184.   } colour;
  185.  
  186.   int transparency;                 /* 0..255 */
  187. } popup_truecolour;
  188.  
  189.  
  190. typedef struct
  191. {
  192.   char       name[12];              /* PopUp type name, eg "SaveAs"          */
  193.   wimp_point openpos;               /* Position (top left) to open window at */
  194.   char       flags;                 /* menuleaf/standalone/static popup?     */
  195.   char       reserved1, reserved2, reserved3;
  196. } popup_header;
  197.  
  198.  
  199. typedef union
  200. {
  201.   popup_magnify    magnify;
  202.   popup_proginfo   proginfo;
  203.   popup_report     report;
  204.   popup_saveas     saveas;
  205.   popup_wimpcolour wimpcolour;
  206.   popup_truecolour truecolour;
  207. } popup_data;                               /* Data to send to popup manager */
  208.  
  209.  
  210. typedef struct
  211. {
  212.   popup_magnify    magnify;
  213.   popup_report     report;
  214.   popup_saveas     saveasreturn;
  215.   popup_wimpcolour wimpcolour;
  216.   popup_truecolour truecolour;
  217. } popup_returndata;                     /* Data recieved in a PopUpState msg */
  218.  
  219.  
  220. typedef struct
  221. {
  222.   window_handle window;                /* Pass this data directly to         */
  223.   wimp_point    openpos;               /* Wimp_CreateSubMenu. Do not pass GO */
  224. } message_popuprequest;
  225.  
  226.  
  227. typedef struct
  228. {
  229.   popup_handle     handle;                /* PopUp handle                    */
  230.   char             name[12];              /* PopUp type nam, e.g. "ProgInfo" */
  231.   popup_returndata data;                  /* Returned state data             */
  232. } message_popupstate;
  233.  
  234.  
  235. typedef struct
  236. {
  237.   popup_header header;
  238.   popup_data   data;
  239. } popup_block;                                /* Block to send to PopUp_Open */
  240.  
  241.  
  242.  
  243. /* --------------------------------------------------------------------------
  244.  *  Functions
  245.  * --------------------------------------------------------------------------
  246.  */
  247.  
  248.   /*  PopUp_Open
  249.    *  Straight SWI veneer for PopUp_Open swi.
  250.    *  (You shouldn't have to call this function - use PopUpShowXXXX, below)
  251.    */
  252. extern popup_handle PopUp_Open(popup_block *params);
  253.  
  254.  
  255.   /*  PopUp_Close
  256.    *  Straight SWI veneer for PopUp_Close swi.
  257.    *  This will close any PopUp, given the handle as returned by other
  258.    *  PopUp calls (PopUp_Open, PopUp_Show)
  259.    *  Note that this is only necessary for STATIC PopUps, and that illegal
  260.    *  calls (popup isn't open, etc) will be ignored.
  261.    */
  262. extern void PopUp_Close(popup_handle handle);
  263.  
  264.  
  265.  /*  PopUp_ShowMenuLeaf
  266.   *  Higher level interface to PopUp_Open, which will show a MENU-LEAF PopUp
  267.   *  given the PopUp type name and popup-specific data, plus the "menuwarn"
  268.   *  message that induced your desire to open the PopUp in the first place.
  269.   *
  270.   *  'name'       is the PopUp type name (e.g. "FontSelect")
  271.   *  'definition' is the popup-specific description.
  272.   *
  273.   *  Hypothetical example of use:
  274.   *  case message_MENUWARN:
  275.   *    switch(event->data.message.data.menuwarn.selection[0])
  276.   *    {
  277.   *      case 3: |* Save => menu item *|
  278.   *      {
  279.   *        popup_data pud;
  280.   *
  281.   *        strcpy(pud.saveas.iconsprite, "file_aff");   |* iconsprite name   *|
  282.   *        strcpy(pud.saveas.filename, "DrawFile");     |* Default file name *|
  283.   *        PopUp_ShowMenuLeaf("SaveAs", &pud,
  284.   *                            &event->data.message.datamenuwarn);
  285.   */
  286. extern popup_handle PopUp_ShowMenuLeaf(char *name, popup_data *definition,
  287.                                        message_menuwarn *msg);
  288.  
  289.  
  290.  /*  PopUp_ShowPtr
  291.   *  Higher level interface to PopUp_Open, which will open a STANDALONE MENU
  292.   *  or STATIC PopUp by filling in the position to open at (over the pointer)
  293.   *  and other header data for you, and open the PopUp as defined by the
  294.   *  passed in "popup_data" block.
  295.   *
  296.   *  'name'       is the PopUp type name (e.g. "FontSelect")
  297.   *  'isstatic'   indicates if the PopUp should be a static or menu PopUp.
  298.   *  'definition' is the popup-specific description.
  299.   *
  300.   *  Rather than calling ShowPtr directly, use the macros that follow...
  301.   */
  302. extern popup_handle PopUp_ShowPtr(char *name, BOOL isstatic,
  303.                                   popup_data *definition);
  304.  
  305.  
  306. /*  Show macros
  307.  *  These macros simply make PopUp_ShowPtr nicer to use without causing more
  308.  *  code bulk. They are used to show a standalone-menu or a static (permanent
  309.  *  window) PopUp respectively. Prototypes:
  310.  *
  311.  *  popup_handle PopUp_ShowStandalone(char *name, popup_data *definition);
  312.  *  popup_handle PopUp_ShowStatic(char *name, popup_data *definition);
  313.  */
  314.  
  315. #define PopUp_ShowStandalone(N, D) PopUp_ShowPtr(N, 0, D)
  316. #define PopUp_ShowStatic(N, D) PopUp_ShowPtr(N, 1, D)
  317.  
  318. #ifdef __cplusplus
  319.            }
  320. #endif
  321.  
  322. #endif
  323.