home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / colourpick < prev    next >
Encoding:
Text File  |  1994-09-14  |  17.1 KB  |  515 lines

  1. #ifndef colourpicker_H
  2. #define colourpicker_H
  3.  
  4. /* C header file for ColourPicker
  5.  * written by DefMod (Sep  7 1994) on Wed Sep 14 13:19:23 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. #ifndef wimp_H
  24.    #include "wimp.h"
  25. #endif
  26.  
  27. /**********************************
  28.  * SWI names and SWI reason codes *
  29.  **********************************/
  30. #undef  ColourPicker_RegisterModel
  31. #define ColourPicker_RegisterModel              0x47700
  32. #undef  XColourPicker_RegisterModel
  33. #define XColourPicker_RegisterModel             0x67700
  34. #undef  ColourPicker_DeregisterModel
  35. #define ColourPicker_DeregisterModel            0x47701
  36. #undef  XColourPicker_DeregisterModel
  37. #define XColourPicker_DeregisterModel           0x67701
  38. #undef  ColourPicker_OpenDialogue
  39. #define ColourPicker_OpenDialogue               0x47702
  40. #undef  XColourPicker_OpenDialogue
  41. #define XColourPicker_OpenDialogue              0x67702
  42. #undef  ColourPicker_CloseDialogue
  43. #define ColourPicker_CloseDialogue              0x47703
  44. #undef  XColourPicker_CloseDialogue
  45. #define XColourPicker_CloseDialogue             0x67703
  46. #undef  ColourPicker_UpdateDialogue
  47. #define ColourPicker_UpdateDialogue             0x47704
  48. #undef  XColourPicker_UpdateDialogue
  49. #define XColourPicker_UpdateDialogue            0x67704
  50. #undef  ColourPicker_ReadDialogue
  51. #define ColourPicker_ReadDialogue               0x47705
  52. #undef  XColourPicker_ReadDialogue
  53. #define XColourPicker_ReadDialogue              0x67705
  54. #undef  ColourPicker_SetColour
  55. #define ColourPicker_SetColour                  0x47706
  56. #undef  XColourPicker_SetColour
  57. #define XColourPicker_SetColour                 0x67706
  58. #undef  ColourPicker_HelpReply
  59. #define ColourPicker_HelpReply                  0x47707
  60. #undef  XColourPicker_HelpReply
  61. #define XColourPicker_HelpReply                 0x67707
  62. #undef  ColourPicker_ModelSWI
  63. #define ColourPicker_ModelSWI                   0x47708
  64. #undef  XColourPicker_ModelSWI
  65. #define XColourPicker_ModelSWI                  0x67708
  66. #undef  ColourPickerModelSWI_ColourChanged
  67. #define ColourPickerModelSWI_ColourChanged      0x0
  68. #undef  ColourPickerModelSWI_ColourChangedByDragging
  69. #define ColourPickerModelSWI_ColourChangedByDragging 0x1
  70. #undef  ColourPickerModelSWI_ClaimEvent
  71. #define ColourPickerModelSWI_ClaimEvent         0x2
  72. #undef  ColourPickerModelSWI_ReleaseEvent
  73. #define ColourPickerModelSWI_ReleaseEvent       0x3
  74. #undef  ColourPickerModelSWI_ProcessKey
  75. #define ColourPickerModelSWI_ProcessKey         0x4
  76. #undef  Service_ColourPickerLoaded
  77. #define Service_ColourPickerLoaded              0x93
  78.  
  79. /************************************
  80.  * Structure and union declarations *
  81.  ************************************/
  82. typedef struct colourpicker_d_                  *colourpicker_d;
  83. typedef struct colourpicker_colour              colourpicker_colour;
  84. typedef struct colourpicker_dialogue            colourpicker_dialogue;
  85. typedef struct colourpicker_model               colourpicker_model;
  86. typedef struct colourpicker_message_colour_choice colourpicker_message_colour_choice;
  87. typedef struct colourpicker_message_colour_changed colourpicker_message_colour_changed;
  88. typedef struct colourpicker_message_open_parent_request colourpicker_message_open_parent_request;
  89. typedef struct colourpicker_message_close_dialogue_request colourpicker_message_close_dialogue_request;
  90.  
  91. /********************
  92.  * Type definitions *
  93.  ********************/
  94. struct colourpicker_colour
  95.    {  os_colour colour;
  96.       int size;
  97.       int info [UNKNOWN];
  98.    };
  99.  
  100. #define colourpicker_COLOUR(N) \
  101.    struct \
  102.       {  os_colour colour; \
  103.          int size; \
  104.          int info [N]; \
  105.       }
  106.  
  107. #define colourpicker_SIZEOF_COLOUR(N) \
  108.    (offsetof (colourpicker_colour, info) + \
  109.          (N)*sizeof ((colourpicker_colour *) NULL)->info)
  110.  
  111. struct colourpicker_dialogue
  112.    {  bits flags;
  113.       char *title;
  114.       os_box visible;
  115.       int xscroll;
  116.       int yscroll;
  117.       os_colour colour;
  118.       int size;
  119.       int info [UNKNOWN];
  120.    };
  121.  
  122. #define colourpicker_DIALOGUE(N) \
  123.    struct \
  124.       {  bits flags; \
  125.          char *title; \
  126.          os_box visible; \
  127.          int xscroll; \
  128.          int yscroll; \
  129.          os_colour colour; \
  130.          int size; \
  131.          int info [N]; \
  132.       }
  133.  
  134. #define colourpicker_SIZEOF_DIALOGUE(N) \
  135.    (offsetof (colourpicker_dialogue, info) + \
  136.          (N)*sizeof ((colourpicker_dialogue *) NULL)->info)
  137.  
  138. struct colourpicker_model
  139.    {  bits flags;
  140.       char *name;
  141.       char *description;
  142.       int info_size;
  143.       os_coord pane_size;
  144.       void *entries [8];
  145.    };
  146.  
  147. struct colourpicker_message_colour_choice
  148.    {  colourpicker_d d;
  149.       bits flags;
  150.       os_colour colour;
  151.       int size;
  152.       int info [UNKNOWN];
  153.    };
  154.  
  155. #define colourpicker_MESSAGE_COLOUR_CHOICE(N) \
  156.    struct \
  157.       {  colourpicker_d d; \
  158.          bits flags; \
  159.          os_colour colour; \
  160.          int size; \
  161.          int info [N]; \
  162.       }
  163.  
  164. #define colourpicker_SIZEOF_MESSAGE_COLOUR_CHOICE(N) \
  165.    (offsetof (colourpicker_message_colour_choice, info) + \
  166.          (N)*sizeof ((colourpicker_message_colour_choice *) NULL)->info)
  167.  
  168. struct colourpicker_message_colour_changed
  169.    {  colourpicker_d d;
  170.       bits flags;
  171.       os_colour colour;
  172.       int size;
  173.       int info [UNKNOWN];
  174.    };
  175.  
  176. #define colourpicker_MESSAGE_COLOUR_CHANGED(N) \
  177.    struct \
  178.       {  colourpicker_d d; \
  179.          bits flags; \
  180.          os_colour colour; \
  181.          int size; \
  182.          int info [N]; \
  183.       }
  184.  
  185. #define colourpicker_SIZEOF_MESSAGE_COLOUR_CHANGED(N) \
  186.    (offsetof (colourpicker_message_colour_changed, info) + \
  187.          (N)*sizeof ((colourpicker_message_colour_changed *) NULL)->info)
  188.  
  189. struct colourpicker_message_open_parent_request
  190.    {  colourpicker_d d;
  191.    };
  192.  
  193. struct colourpicker_message_close_dialogue_request
  194.    {  colourpicker_d d;
  195.    };
  196.  
  197. /************************
  198.  * Constant definitions *
  199.  ************************/
  200. #define error_COLOUR_PICKER_UNINIT              0x20D00u
  201. #define error_COLOUR_PICKER_BAD_MODEL           0x20D01u
  202. #define error_COLOUR_PICKER_BAD_HANDLE          0x20D02u
  203. #define error_COLOUR_PICKER_BAD_FLAGS           0x20D03u
  204. #define error_COLOUR_PICKER_IN_USE              0x20D04u
  205. #define error_COLOUR_PICKER_MODEL_IN_USE        0x20D05u
  206. #define error_COLOUR_PICKER_BAD_REASON          0x20D06u
  207. #define colourpicker_DIALOGUE_OFFERS_TRANSPARENT 0x1u
  208. #define colourpicker_DIALOGUE_TRANSPARENT       0x2u
  209. #define colourpicker_DIALOGUE_TYPE              0xCu
  210. #define colourpicker_DIALOGUE_TYPE_SHIFT        2
  211. #define colourpicker_DIALOGUE_TYPE_NEVER        0x0u
  212. #define colourpicker_DIALOGUE_TYPE_CLICK        0x1u
  213. #define colourpicker_DIALOGUE_TYPE_CLICK_DRAG   0x2u
  214. #define colourpicker_DIALOGUE_IGNORE_HELP       0x10u
  215. #define colourpicker_OPEN_TRANSIENT             0x1u
  216. #define colourpicker_OPEN_SUB_MENU              0x2u
  217. #define colourpicker_OPEN_TOOLBOX               0x2u
  218. #define colourpicker_UPDATE_OFFERS_TRANSPARENT  0x1u
  219. #define colourpicker_UPDATE_TRANSPARENT         0x2u
  220. #define colourpicker_UPDATE_TYPE                0x4u
  221. #define colourpicker_UPDATE_VISIBLE             0x8u
  222. #define colourpicker_UPDATE_SCROLL              0x10u
  223. #define colourpicker_UPDATE_TITLE               0x20u
  224. #define colourpicker_UPDATE_COLOUR              0x40u
  225. #define colourpicker_UPDATE_MODEL               0x80u
  226. #define colourpicker_UPDATE_IGNORE_HELP         0x100u
  227. #define colourpicker_COLOUR_TRANSPARENT         0x1u
  228. #define colourpicker_COLOUR_DRAGGING            0x2u
  229. #define colourpicker_ENTRY_DIALOGUE_STARTING    0
  230. #define colourpicker_ENTRY_DIALOGUE_FINISHING   1
  231. #define colourpicker_ENTRY_REDRAW_AREA          2
  232. #define colourpicker_ENTRY_UPDATE_AREA          3
  233. #define colourpicker_ENTRY_READ_VALUES          4
  234. #define colourpicker_ENTRY_SET_VALUES           5
  235. #define colourpicker_ENTRY_PROCESS_EVENT        6
  236. #define colourpicker_ENTRY_SET_COLOUR           7
  237. #define colourpicker_ENTRY_LIMIT                8
  238. #define colourpicker_MODEL_SIZE_RGB             16
  239. #define colourpicker_MODEL_SIZE_CMYK            20
  240. #define colourpicker_MODEL_SIZE_HSV             16
  241. #define colourpicker_MODEL_RGB                  0
  242. #define colourpicker_MODEL_CMYK                 1
  243. #define colourpicker_MODEL_HSV                  2
  244. #define message_COLOUR_PICKER_COLOUR_CHOICE     0x47700u
  245. #define message_COLOUR_PICKER_COLOUR_CHANGED    0x47701u
  246. #define message_COLOUR_PICKER_CLOSE_DIALOGUE_REQUEST 0x47702u
  247. #define message_COLOUR_PICKER_OPEN_PARENT_REQUEST 0x47703u
  248.  
  249. /*************************
  250.  * Function declarations *
  251.  *************************/
  252.  
  253. #ifdef __cplusplus
  254.    extern "C" {
  255. #endif
  256.  
  257. /*************************************************************
  258.  * NOTE: The following functions provide direct access to    *
  259.  *       the SWI's noted in the function description.        *
  260.  *       Please read the relevant PRM section for more       *
  261.  *       information on their input/output parameters.       *
  262.  *************************************************************/
  263.  
  264. /* ------------------------------------------------------------------------
  265.  * Function:      colourpicker_register_model()
  266.  *
  267.  * Description:   For internal use only
  268.  *
  269.  * Input:         model_no - value of R0 on entry
  270.  *                model - value of R1 on entry
  271.  *                workspace - value of R2 on entry
  272.  *
  273.  * Other notes:   Calls SWI 0x47700.
  274.  */
  275.  
  276. extern os_error *xcolourpicker_register_model (int model_no,
  277.       colourpicker_model *model,
  278.       byte *workspace);
  279. extern void colourpicker_register_model (int model_no,
  280.       colourpicker_model *model,
  281.       byte *workspace);
  282.  
  283. /* ------------------------------------------------------------------------
  284.  * Function:      colourpicker_deregister_model()
  285.  *
  286.  * Description:   For internal use only
  287.  *
  288.  * Input:         model_no - value of R0 on entry
  289.  *
  290.  * Other notes:   Calls SWI 0x47701.
  291.  */
  292.  
  293. extern os_error *xcolourpicker_deregister_model (int model_no);
  294. extern void colourpicker_deregister_model (int model_no);
  295.  
  296. /* ------------------------------------------------------------------------
  297.  * Function:      colourpicker_open_dialogue()
  298.  *
  299.  * Description:   Creates and opens a colour picker dialogue
  300.  *
  301.  * Input:         flags - value of R0 on entry
  302.  *                dialogue - value of R1 on entry
  303.  *
  304.  * Output:        d - value of R0 on exit (X version only)
  305.  *                w - value of R1 on exit
  306.  *
  307.  * Returns:       R0 (non-X version only)
  308.  *
  309.  * Other notes:   Calls SWI 0x47702.
  310.  */
  311.  
  312. extern os_error *xcolourpicker_open_dialogue (bits flags,
  313.       colourpicker_dialogue *dialogue,
  314.       colourpicker_d *d,
  315.       wimp_w *w);
  316. extern colourpicker_d colourpicker_open_dialogue (bits flags,
  317.       colourpicker_dialogue *dialogue,
  318.       wimp_w *w);
  319.  
  320. /* ------------------------------------------------------------------------
  321.  * Function:      colourpicker_close_dialogue()
  322.  *
  323.  * Description:   Closes a colour picker dialogue which is in progress
  324.  *
  325.  * Input:         flags - value of R0 on entry
  326.  *                d - value of R1 on entry
  327.  *
  328.  * Other notes:   Calls SWI 0x47703.
  329.  */
  330.  
  331. extern os_error *xcolourpicker_close_dialogue (bits flags,
  332.       colourpicker_d d);
  333. extern void colourpicker_close_dialogue (bits flags,
  334.       colourpicker_d d);
  335.  
  336. /* ------------------------------------------------------------------------
  337.  * Function:      colourpicker_update_dialogue()
  338.  *
  339.  * Description:   Updates some or all of the contents of a colour picker
  340.  *                dialogue
  341.  *
  342.  * Input:         flags - value of R0 on entry
  343.  *                d - value of R1 on entry
  344.  *                dialogue - value of R2 on entry
  345.  *
  346.  * Other notes:   Calls SWI 0x47704.
  347.  */
  348.  
  349. extern os_error *xcolourpicker_update_dialogue (bits flags,
  350.       colourpicker_d d,
  351.       colourpicker_dialogue *dialogue);
  352. extern void colourpicker_update_dialogue (bits flags,
  353.       colourpicker_d d,
  354.       colourpicker_dialogue *dialogue);
  355.  
  356. /* ------------------------------------------------------------------------
  357.  * Function:      colourpicker_read_dialogue()
  358.  *
  359.  * Description:   Reads the current state of a colour picker dialogue
  360.  *                without changing it
  361.  *
  362.  * Input:         flags - value of R0 on entry
  363.  *                d - value of R1 on entry
  364.  *                dialogue - value of R2 on entry
  365.  *
  366.  * Output:        w - value of R1 on exit
  367.  *                size - value of R2 on exit
  368.  *
  369.  * Other notes:   Calls SWI 0x47705.
  370.  */
  371.  
  372. extern os_error *xcolourpicker_read_dialogue (bits flags,
  373.       colourpicker_d d,
  374.       colourpicker_dialogue *dialogue,
  375.       wimp_w *w,
  376.       int *size);
  377. extern void colourpicker_read_dialogue (bits flags,
  378.       colourpicker_d d,
  379.       colourpicker_dialogue *dialogue,
  380.       wimp_w *w,
  381.       int *size);
  382.  
  383. /* ------------------------------------------------------------------------
  384.  * Function:      colourpicker_set_colour()
  385.  *
  386.  * Description:   Reserved for future expansion
  387.  *
  388.  * Input:         flags - value of R0 on entry
  389.  *                colour - value of R1 on entry
  390.  *
  391.  * Other notes:   Calls SWI 0x47706.
  392.  */
  393.  
  394. extern os_error *xcolourpicker_set_colour (bits flags,
  395.       colourpicker_colour *colour);
  396. extern void colourpicker_set_colour (bits flags,
  397.       colourpicker_colour *colour);
  398.  
  399. /* ------------------------------------------------------------------------
  400.  * Function:      colourpicker_help_reply()
  401.  *
  402.  * Description:   Makes a colour picker respond to a Message_HelpRequest
  403.  *                with its own help text
  404.  *
  405.  * Input:         flags - value of R0 on entry
  406.  *                help_request - value of R1 on entry
  407.  *
  408.  * Other notes:   Calls SWI 0x47707.
  409.  */
  410.  
  411. extern os_error *xcolourpicker_help_reply (bits flags,
  412.       wimp_message *help_request);
  413. extern void colourpicker_help_reply (bits flags,
  414.       wimp_message *help_request);
  415.  
  416. /* ------------------------------------------------------------------------
  417.  * Function:      colourpickermodelswi_colour_changed()
  418.  *
  419.  * Description:   Informs the front end to send a message to the client, if
  420.  *                required
  421.  *
  422.  * Input:         colour - value of R1 on entry
  423.  *
  424.  * Other notes:   Calls SWI 0x47708 with R0 = 0x0.
  425.  */
  426.  
  427. extern os_error *xcolourpickermodelswi_colour_changed (colourpicker_colour *colour);
  428. extern void colourpickermodelswi_colour_changed (colourpicker_colour *colour);
  429.  
  430. /* ------------------------------------------------------------------------
  431.  * Function:      colourpickermodelswi_colour_changed_by_dragging()
  432.  *
  433.  * Description:   Informs the front end to send a dragging message to the
  434.  *                client, if required
  435.  *
  436.  * Input:         colour - value of R1 on entry
  437.  *
  438.  * Other notes:   Calls SWI 0x47708 with R0 = 0x1.
  439.  */
  440.  
  441. extern os_error *xcolourpickermodelswi_colour_changed_by_dragging (colourpicker_colour *colour);
  442. extern void colourpickermodelswi_colour_changed_by_dragging (colourpicker_colour *colour);
  443.  
  444. /* ------------------------------------------------------------------------
  445.  * Function:      colourpickermodelswi_claim_event()
  446.  *
  447.  * Description:   Informs the front end that the back end wants an event
  448.  *                type
  449.  *
  450.  * Input:         event - value of R1 on entry
  451.  *                colour - value of R2 on entry
  452.  *
  453.  * Other notes:   Calls SWI 0x47708 with R0 = 0x2.
  454.  */
  455.  
  456. extern os_error *xcolourpickermodelswi_claim_event (int event,
  457.       colourpicker_colour *colour);
  458. extern void colourpickermodelswi_claim_event (int event,
  459.       colourpicker_colour *colour);
  460.  
  461. /* ------------------------------------------------------------------------
  462.  * Function:      colourpickermodelswi_release_event()
  463.  *
  464.  * Description:   Informs the front end that the back end no longer wants
  465.  *                an event type
  466.  *
  467.  * Input:         event - value of R1 on entry
  468.  *                colour - value of R2 on entry
  469.  *
  470.  * Other notes:   Calls SWI 0x47708 with R0 = 0x3.
  471.  */
  472.  
  473. extern os_error *xcolourpickermodelswi_release_event (int event,
  474.       colourpicker_colour *colour);
  475. extern void colourpickermodelswi_release_event (int event,
  476.       colourpicker_colour *colour);
  477.  
  478. /* ------------------------------------------------------------------------
  479.  * Function:      colourpickermodelswi_process_key()
  480.  *
  481.  * Description:   Passes an unhandled key press on to the front end
  482.  *
  483.  * Input:         c - value of R1 on entry
  484.  *                colour - value of R2 on entry
  485.  *
  486.  * Other notes:   Calls SWI 0x47708 with R0 = 0x4.
  487.  */
  488.  
  489. extern os_error *xcolourpickermodelswi_process_key (int c,
  490.       colourpicker_colour *colour);
  491. extern void colourpickermodelswi_process_key (int c,
  492.       colourpicker_colour *colour);
  493.  
  494. /* ------------------------------------------------------------------------
  495.  * Function:      service_colour_picker_loaded()
  496.  *
  497.  * Description:   For internal use only
  498.  *
  499.  * Input:         loaded_service - value of R2 on entry
  500.  *                workspace - value of R3 on entry
  501.  *
  502.  * Other notes:   Calls SWI 0x30 with R1 = 0x93.
  503.  */
  504.  
  505. extern os_error *xservice_colour_picker_loaded (void *loaded_service,
  506.       byte *workspace);
  507. extern void service_colour_picker_loaded (void *loaded_service,
  508.       byte *workspace);
  509.  
  510. #ifdef __cplusplus
  511.    }
  512. #endif
  513.  
  514. #endif
  515.