home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Developers / PopupCDEF-10b5 / Source / PopupLib.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-30  |  5.5 KB  |  145 lines  |  [TEXT/KAHL]

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994 Ari Halberstadt */
  3.     
  4. #pragma once
  5.  
  6. #include <QDOffscreen.h>
  7. #include "PopupCDEF.h"
  8.  
  9. /* M68K JMP instruction (for MDEF and CDEF glue) */
  10. #define ASM_M68K_JMP            (0x4EF9)
  11.  
  12. /*    Private part codes. */
  13. #define kPopupPartFirst                (128)    /* first part code */
  14. #define kPopupPartTitle                (128)    /* title rectangle */
  15. #define kPopupPartItem                (129)    /* current item rectangle */
  16. #define kPopupPartIcon                (130) /* current item icon */
  17. #define kPopupPartTriangle            (131)    /* triangle */
  18. #define kPopupPartFrame                (132)    /* frame around current item */
  19. #define kPopupPartShadow            (133)    /* drop shadow */
  20. #define kPopupPartLast                (134)    /* last part code + 1 */
  21.  
  22. /* for saving/restoring a port's text state */
  23. typedef struct {
  24.     short    font;
  25.     Style    face;
  26.     short    mode;
  27.     short    size;
  28. } TextState;
  29.  
  30. /* for saving/restoring a port's color state */
  31. typedef struct {
  32.     RGBColor fore;
  33.     RGBColor back;
  34. } ColorState;
  35.  
  36. /* Drawing environment data which must be remembered before any drawing
  37.     of the popup menu is begun and restored after all drawing has finished. */
  38. typedef struct {
  39.     GrafPtr        port;            /* graf port on entry to popup cdef */
  40.     PenState        pen;            /* saved pen state for popup's port */
  41.     TextState    text;            /* saved text state for popup's port */
  42.     ColorState    color;        /* saved color state for popup's port */
  43.     RgnHandle    clip;            /* saved clip region for popup's port */
  44.     short            sysfont;        /* saved system font */
  45.     short            syssize;        /* saved system font size */
  46. } PopupEnvType;
  47.  
  48. /* rectangles defining the various areas of a popup menu */
  49. typedef struct {
  50.     Rect maxbounds;            /* maximum bounding rectangle of popup */
  51.     Rect bounds;                /* rectangle around all of popup */
  52.     Rect hilite;                /* hilited when a selection is being made */
  53.     Rect title;                    /* contains the popup's title */
  54.     Rect selection;            /* contains the currently selected item */
  55.     Rect triangle;                /* contains the triangle */
  56. } PopupRectanglesType;
  57.  
  58. /* structure containing all the data needed by the popup menu */
  59. typedef struct {
  60.  
  61.     /* these first two fields will never be changed, other fields may change */
  62.     PopupPrivateType private;    /* for compatability with Apple's CDEF */
  63.     short                version;        /* version of the code that created this popup menu */
  64.  
  65.     /* fields specified on creation of the popup menu (maxbounds is in
  66.         rectangles field) */
  67.     GrafPtr            port;            /* port to draw into */
  68.     MenuHandle        menu;            /* handle to menu */
  69.     ControlHandle    ctl;            /* handle to control */
  70.     
  71.     /* for patching the menu definition function */
  72.     Handle            menuProc;    /* glue to call our own MDEF */
  73.     
  74.     /* information needed when drawing */
  75.     struct {
  76.         GDHandle        gdevice;        /* graphics device to draw into */
  77.         short            gdepth;        /* pixel depth of graphics device */
  78.         GWorldPtr    gworld;        /* offscreen graphics world */
  79.         RgnHandle    utilRgn;        /* utility region */
  80.         PopupEnvType save;         /* saved drawing environment */
  81.     } draw;
  82.     
  83.     /* internal state information */
  84.     PopupRectanglesType r;        /* rectangles enclosing areas of the popup menu */
  85.     struct {
  86.         short            current;        /* currently selected item number */
  87.         Boolean        drawset:1;    /* true after drawing environment has been setup */
  88.         Boolean        gotmenu:1;    /* used by CDEF; true means CDEF created menu */
  89.         Boolean        changed:1;    /* true if popup's image changed and needs redrawing */
  90.     } state;
  91.     
  92.     /* User settable attributes of the menu. External functions
  93.         are provided to manipulate these fields. */
  94.     struct {
  95.         void            *data;        /* pointer to application defined data */
  96.         Boolean        draw:1;        /* false disables drawing and calculating */
  97.         Boolean        visible:1;    /* true means popup is visible */
  98.         Boolean        enabled:1;    /* true if menu is enabled */
  99.         Boolean        typein:1;    /* true shows only triangle, like a type-in menu */
  100.         Boolean        wfont:1;        /* true uses window font, not system font */
  101.         Boolean        fixedwidth:1;/* true uses fixed width for menu */
  102.         char            mark;            /* character used to mark current item */
  103.         char            just;            /* text justification */
  104.         struct {
  105.             Style        style;        /* style of popup's title */
  106.             short        width;        /* width of title; 0 if resized dynamically */
  107.             Handle    str;            /* popup's title string */
  108.         } title;
  109.     } attr;
  110. } PopupType, *PopupPtr, **PopupHandle;
  111.  
  112. Boolean PopupValid(PopupHandle popup);
  113.  
  114. void PopupCalculate(PopupHandle popup);
  115. void PopupDraw(PopupHandle popup);
  116. void PopupHilite(PopupHandle popup);
  117. void PopupSelect(PopupHandle popup);
  118. Boolean PopupWithin(PopupHandle popup, Point pt);
  119.  
  120. short PopupVersion(PopupHandle popup);
  121. short PopupCurrent(PopupHandle popup);
  122. void PopupCurrentSet(PopupHandle popup, short current);
  123. void PopupDrawSet(PopupHandle popup, Boolean draw);
  124. void PopupVisibleSet(PopupHandle popup, Boolean visible);
  125. void PopupMarkSet(PopupHandle popup, char mark);
  126. void PopupEnableSet(PopupHandle popup, Boolean enabled);
  127. void PopupTypeInSet(PopupHandle popup, Boolean typein);
  128. void PopupBounds(PopupHandle popup, Rect *bounds);
  129. void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
  130. void PopupTitle(PopupHandle popup, Str255 title);
  131. void PopupTitleSet(PopupHandle popup, const Str255 title);
  132. void PopupTitleWidthSet(PopupHandle popup, short width);
  133. void PopupTitleStyleSet(PopupHandle popup, Style style);
  134. void PopupUseWFontSet(PopupHandle popup, Boolean wfont);
  135. void PopupFixedWidthSet(PopupHandle popup, Boolean fixedwidth);
  136. void PopupJustSet(PopupHandle popup, short just);
  137.  
  138. PopupHandle PopupBegin(GrafPtr port, MenuHandle menu, const Rect *bounds,
  139.     ControlHandle ctl);
  140. void PopupEnd(PopupHandle popup);
  141.  
  142. pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
  143. void PopupCDEFAttach(ControlHandle ctl);
  144. void PopupCDEFDetach(ControlHandle ctl);
  145.