lwshelf.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /****
  2. * lwshelf.h
  3. ****
  4. * COPYRIGHT (C) 1999 NewTek, Inc.
  5. ****
  6. */
  7. #ifndef LWSHELF_H
  8. #define LWSHELF_H
  9. /* Standard */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <lwdialog.h>
  13. #include <lwglobsrv.h>
  14. #include <lwtypes.h>
  15. #include <lwimage.h>
  16. #include <lwio.h>
  17. /****
  18. * Callback Prototypes:
  19. * --------------------
  20. * LWShelfLoadOkFunc - Asks the subscribed client if it is ready to accept
  21. * loading a preset.
  22. * LWShelfLoadFunc - Called to have the client load settings
  23. * LWShelfSaveFunc - Called during save to obtain client settings
  24. *
  25. * These load and save callbacks provide for loading and
  26. * saving client settings using the LW Load and Save State (LWIO.H)
  27. * OR as a separate data file.
  28. *
  29. * Use of the LWIO states is recommended.
  30. *
  31. * Which format is used depends on the subscription flags
  32. * where SHLF_BIN or SHLF_ASC uses the corresponding LWIO
  33. * load/save states and SHLF_SEP indicates the client will
  34. * save data to a separate file in whatever manner best suits
  35. * its needs. The filename argument to the Load/SaveFunc
  36. * callbacks is the filename the client should use for this
  37. * activity.
  38. *
  39. * API Description:
  40. * ----------------
  41. * subscribe - Adds a client to the Preset Shelf and returns a client ID.
  42. * unsubscribe - Unsubscribes the client. Clients should, at a minimum,
  43. * do this when its instance is destroyed.
  44. * open - Opens the Preset Shelf window and sets focus to the client.
  45. * close - Closes the Shelf.
  46. * setContext - Grabs the focus of the Shelf. This differs from the Open
  47. * method by making the client the active client but this
  48. * does not open the Shelf window.
  49. * addPreset - Called by the client to add a preset settings
  50. * addNamedPreset file to the Presets Shelf. The 'img' is an
  51. * LWImageID to use as the preset's thumbnail. The
  52. * 'parms' is a NULL terminated list of string
  53. * parameter tags which can be used to conditionally
  54. * load settings from the preset.
  55. * (Independent Operations)
  56. * load/save - These load/save preset settings files to an
  57. * arbitrary location specified by 'filename'. As part
  58. * of the shelf API, the load and save methods reuse
  59. * the client subscription settings (like userdata,
  60. * callbacks, etc.). If 'prompt_user' is true and the
  61. * preset contains a parameter list, this will prompt
  62. * user for input.
  63. ****
  64. */
  65. #define LWSHELFFUNCS_GLOBAL "LWShelfFuncs"
  66. typedef struct st_ShelfClient *LWShelfCltID;
  67. typedef char **LWShelfParmList;
  68. typedef int LWShelfLoadOkFunc ( void *userdata );
  69. typedef void LWShelfLoadFunc ( void *userdata, const LWLoadState *load,
  70. const char *filename, LWShelfParmList parms );
  71. typedef void LWShelfSaveFunc ( void *userdata, const LWSaveState *save,
  72. const char *filename );
  73. /* Load and Save Options */
  74. #define SHLF_BIN (1<<1) /* Binary LWIO State */
  75. #define SHLF_ASC (1<<2) /* Ascii LWIO State */
  76. #define SHLF_SEP (1<<3) /* Client uses separate file */
  77. /* LoadOk Codes */
  78. enum en_SHELF_LOADOK {
  79. SHLC_NOWAY = 0, /* Do not load. Client told user reason */
  80. SHLC_DFLT, /* Use default confirmation dialog. */
  81. SHLC_FORCE /* Load. Do Not confirm with user. */
  82. };
  83. typedef struct st_LWSHELFFUNCS {
  84. /* Client subscriptions */
  85. LWShelfCltID (*subscribe) ( char *name, char *subName,
  86. void *userData, int flags,
  87. LWShelfLoadOkFunc *loadOk_callback,
  88. LWShelfLoadFunc *load_callback,
  89. LWShelfSaveFunc *save_callback );
  90. void (*unsubscribe) ( LWShelfCltID clt );
  91. /* Shelf Operations */
  92. void (*open) ( LWShelfCltID clt );
  93. int (*isOpen) ( LWShelfCltID clt );
  94. void (*close) ( LWShelfCltID clt );
  95. void (*setContext) ( LWShelfCltID clt );
  96. int (*addPreset) ( LWShelfCltID clt,
  97. LWImageID img, LWShelfParmList parms );
  98. /* Independent Load and Save */
  99. void (*load) ( LWShelfCltID clt,
  100. char *filename, int prompt_user );
  101. void (*save) ( LWShelfCltID clt, char *filename,
  102. LWImageID thumimg, LWShelfParmList parms );
  103. int (*addNamedPreset) ( LWShelfCltID clt,
  104. LWImageID img, LWShelfParmList parms,
  105. const char *name, const char *comment );
  106. } LWShelfFuncs;
  107. /* Close the header */
  108. #endif