home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / dialoglib / dialog.h < prev    next >
C/C++ Source or Header  |  1993-03-07  |  8KB  |  196 lines

  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3.  
  4. #include <exec/types.h>
  5. #include <utility/hooks.h>
  6. #include <utility/tagitem.h>
  7. #include <limits.h>
  8.  
  9. /*** implementation specific constants ***/
  10. #define MAX_SPACE SHRT_MAX
  11.  
  12. /*************** data types **************/
  13.  
  14. struct __DialogElement
  15. {
  16.     struct Hook hook;
  17.     struct TagItem *taglist;
  18.     APTR object;        /* zero this after disposing the object! (DIALOGM_CLEAR) */
  19.     ULONG structure;    /* dispatchers may utilize this field in any way they see fit! */
  20.     ULONG idcmp_mask;
  21.     LONG minWidth, minHeight, minLeftExtent, minRightExtent, minTopExtent, minBottomExtent;
  22.     LONG maxWidth, maxHeight, maxLeftExtent, maxRightExtent, maxTopExtent, maxBottomExtent;
  23.     struct __DialogElement *root;
  24. };
  25. typedef struct __DialogElement DialogElement;
  26.  
  27. struct __DialogMessage
  28. {
  29.     ULONG dm_MethodID;
  30. #define DIALOGM_SETUP            1
  31. #define DIALOGM_LAYOUT            2
  32. #define DIALOGM_CLEAR            3
  33. #define DIALOGM_MATCH            4
  34. #define DIALOGM_SETATTRS        5
  35. #define DIALOGM_GETSTRUCT        100
  36. #define DIALOGM_GETSPACE        101
  37. };
  38. typedef struct __DialogMessage DialogMessage;
  39.  
  40. struct __LayoutMessage
  41. {
  42.     ULONG lm_MethodID;
  43.     LONG lm_X, lm_Y, lm_Width, lm_Height, lm_Left, lm_Right, lm_Top, lm_Bottom;
  44.     APTR *lm_PreviousPtr;
  45. };
  46. typedef struct __LayoutMessage LayoutMessage;
  47.  
  48. /*** dialog element structure flags (as reported by DIALOGM_GETSTRUCT) ***/
  49. #define DESB_HBaseline    0
  50. #define DESF_HBaseline    (1<<DESB_HBaseline)
  51. #define DESB_VBaseline    1
  52. #define DESF_VBaseline    (1<<DESB_VBaseline)
  53.  
  54. struct __MatchMessage
  55. {
  56.     ULONG mm_MethodID;
  57.     struct IntuiMessage *mm_IntuiMsg;
  58. };
  59. typedef struct __MatchMessage MatchMessage;
  60.  
  61. struct __SetAttrsMessage
  62. {
  63.     ULONG sam_MethodID;
  64.     struct Window *sam_Window;
  65.     struct Requester *sam_Requester;
  66. };
  67. typedef struct __SetAttrsMessage SetAttrsMessage;
  68.  
  69. typedef ULONG (*DialogCallback)( struct Hook *, DialogElement *, DialogMessage * );
  70.  
  71. /************** tags **************/
  72.  
  73. /*
  74.  *    The tag base may be redefined externally if this one happens
  75.  *    to conflict with another one.
  76.  *    Of course you will have to re-compile the library then.
  77.  */
  78. #ifndef DA_TagBase
  79.     #define DA_TagBase        (TAG_USER + 0x2000)
  80. #endif
  81. #define NGDA_TextAttr            (DA_TagBase + 0x00)
  82. #define NGDA_VisualInfo            (DA_TagBase + 0x01)
  83. #define NGDA_GadgetText            (DA_TagBase + 0x02)
  84. #define NGDA_Flags                (DA_TagBase + 0x03)
  85. #define NGDA_Width                (DA_TagBase + 0x04)
  86. #define NGDA_Height                (DA_TagBase + 0x05)
  87. #define DA_Screen                (DA_TagBase + 0x10)
  88. #define DA_Title                (DA_TagBase + 0x11)
  89. #define DA_Member                (DA_TagBase + 0x12)
  90. #define DA_XSpacing                (DA_TagBase + 0x13)
  91. #define DA_YSpacing                (DA_TagBase + 0x14)
  92. #define DA_Alignment            (DA_TagBase + 0x15)
  93. #define DA_Storage                (DA_TagBase + 0x16)
  94. #define DA_Termination            (DA_TagBase + 0x17)
  95. #define DA_EquivalentKey        (DA_TagBase + 0x18)
  96. #define DA_MatchEventClasses    (DA_TagBase + 0x19)
  97. #define DA_MatchEventCode        (DA_TagBase + 0x1a)
  98. #define DA_MatchEventQualifier    (DA_TagBase + 0x1b)
  99. #define DA_CAR                    (DA_TagBase + 0x1c)
  100. #define DA_CDR                    (DA_TagBase + 0x1d)
  101. #define DA_HelpHook                (DA_TagBase + 0x1e)
  102.  
  103. /************** error codes *************/
  104. #define DIALOGERR_NO_ERROR    0
  105. #define DIALOGERR_OK        DIALOGERR_NO_ERROR
  106. #define DIALOGERR_NO_MEMORY    1    /* some object could no be allocated */
  107. #define DIALOGERR_BAD_ARGS    2    /* bad arguments supplied */
  108.  
  109. /************** prototypes **************/
  110.  
  111. /*** for dialog element implementors ***/
  112. VOID setMinWidth( DialogElement *, LONG );
  113. VOID setMinHeight( DialogElement *, LONG );
  114. VOID setMinLeftExtent( DialogElement *, LONG );
  115. VOID setMinRightExtent( DialogElement *, LONG );
  116. VOID setMinTopExtent( DialogElement *, LONG );
  117. VOID setMinBottomExtent( DialogElement *, LONG );
  118. VOID setMaxWidth( DialogElement *, LONG );
  119. VOID setMaxHeight( DialogElement *, LONG );
  120. VOID setMaxLeftExtent( DialogElement *, LONG );
  121. VOID setMaxRightExtent( DialogElement *, LONG );
  122. VOID setMaxTopExtent( DialogElement *, LONG );
  123. VOID setMaxBottomExtent( DialogElement *, LONG );
  124. LONG getMinWidth( DialogElement * );
  125. LONG getMinHeight( DialogElement * );
  126. LONG getMinLeftExtent( DialogElement * );
  127. LONG getMinRightExtent( DialogElement * );
  128. LONG getMinTopExtent( DialogElement * );
  129. LONG getMinBottomExtent( DialogElement * );
  130. LONG getMaxWidth( DialogElement * );
  131. LONG getMaxHeight( DialogElement * );
  132. LONG getMaxLeftExtent( DialogElement * );
  133. LONG getMaxRightExtent( DialogElement * );
  134. LONG getMaxTopExtent( DialogElement * );
  135. LONG getMaxBottomExtent( DialogElement * );
  136. VOID prepareLayoutX( LayoutMessage *, LONG );
  137. VOID prepareLayoutY( LayoutMessage *, LONG );
  138. VOID prepareLayoutNoVBaseline( LayoutMessage *, LONG );
  139. VOID prepareLayoutVBaseline( LayoutMessage *, LONG, LONG );
  140. VOID prepareLayoutNoHBaseline( LayoutMessage *, LONG );
  141. VOID prepareLayoutHBaseline( LayoutMessage *, LONG, LONG );
  142. ULONG prepareMemberLayoutH( LayoutMessage *,
  143.     DialogElement *, DialogElement *, LayoutMessage * );
  144. ULONG prepareMemberLayoutV( LayoutMessage *,
  145.     DialogElement *, DialogElement *, LayoutMessage * );
  146.  
  147. /*** support functions for gadtools-based elements ***/
  148. VOID setGTAttrs( DialogElement *, SetAttrsMessage * );
  149. ULONG getTextPlacement( ULONG, ULONG );
  150. VOID setupGT( DialogElement *, ULONG );
  151. VOID layoutGTSingleLined( struct NewGadget *, LayoutMessage *, ULONG );
  152.  
  153. /*** for clients (and implementors) ***/
  154. VOID initDialogElement( DialogElement *, DialogElement *, DialogCallback, ULONG *,
  155.     ULONG , ... );
  156. VOID initDialogElementA( DialogElement *, DialogElement *, DialogCallback, ULONG *,
  157.     struct TagItem * );
  158. VOID cleanupDialogElement( DialogElement * );
  159. VOID setupDialogElement( DialogElement * );
  160. ULONG getDialogElementStructure( DialogElement * );
  161. ULONG layoutDialogElement( DialogElement *, LayoutMessage *, APTR );
  162. DialogElement *mapDialogEvent( DialogElement *, struct IntuiMessage * );
  163. ULONG setDialogElementAttrsA( DialogElement *,
  164.     struct Window *, struct Requester *, struct TagItem * );
  165. ULONG setDialogElementAttrs( DialogElement *,
  166.     struct Window *, struct Requester *, ULONG, ... );
  167. VOID clearDialogElement( DialogElement * );
  168.  
  169. ULONG dispatchRoot( struct Hook *, DialogElement *, DialogMessage * );
  170. ULONG dispatchHStack( struct Hook *, DialogElement *, DialogMessage * );
  171. ULONG dispatchVStack( struct Hook *, DialogElement *, DialogMessage * );
  172. ULONG dispatchHCons( struct Hook *, DialogElement *, DialogMessage * );
  173. ULONG dispatchVCons( struct Hook *, DialogElement *, DialogMessage * );
  174. ULONG dispatchHBumper( struct Hook *, DialogElement *, DialogMessage * );
  175. ULONG dispatchVBumper( struct Hook *, DialogElement *, DialogMessage * );
  176. ULONG dispatchHSpring( struct Hook *, DialogElement *, DialogMessage * );
  177. ULONG dispatchVSpring( struct Hook *, DialogElement *, DialogMessage * );
  178. ULONG dispatchButton( struct Hook *, DialogElement *, DialogMessage * );
  179. ULONG dispatchCheckBox( struct Hook *, DialogElement *, DialogMessage * );
  180. ULONG dispatchString( struct Hook *, DialogElement *, DialogMessage * );
  181. ULONG dispatchInteger( struct Hook *, DialogElement *, DialogMessage * );
  182. ULONG dispatchListView( struct Hook *, DialogElement *, DialogMessage * );
  183. ULONG dispatchMX( struct Hook *, DialogElement *, DialogMessage * );
  184. ULONG dispatchCycle( struct Hook *, DialogElement *, DialogMessage * );
  185. ULONG dispatchText( struct Hook *, DialogElement *, DialogMessage * );
  186. ULONG dispatchNumber( struct Hook *, DialogElement *, DialogMessage * );
  187.  
  188. ULONG openDialogWindow( DialogElement *, ULONG, ... );
  189. ULONG openDialogWindowA( DialogElement *, struct TagItem * );
  190. VOID closeDialogWindow( DialogElement * );
  191. struct Window *getDialogWindow( DialogElement * );
  192. DialogElement *runSimpleDialog( DialogElement *, ULONG, ... );
  193. DialogElement *runSimpleDialogA( DialogElement *, struct TagItem * );
  194.  
  195. #endif
  196.