home *** CD-ROM | disk | FTP | other *** search
- /* See the file Distribution for distribution terms.
- (c) Copyright 1994 Ari Halberstadt */
-
- #pragma once
-
- #ifndef POPUP_LIBRARY
- #define POPUP_LIBRARY
-
- #include <QDOffscreen.h>
- #include "PopupCDEF.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /* Structure of a glue handle for 68K and PowerPC. The 68K version is based on
- "Inside Macintosh: PowerPC System Software", p1-35. */
- typedef union {
- struct {
- unsigned long lea; /* lea pc+8, a0 */
- unsigned short move; /* movea.l (a0) a0 */
- unsigned short jmp; /* jmp (a0) */
- ProcPtr proc; /* destination address */
- } m68k;
- struct {
- RoutineDescriptor descriptor;
- } ppc;
- } PopupGlueUnion, *PopupGluePtr, **PopupGlueHandle;
-
- /* rectangles defining the various areas of a popup menu */
- typedef struct {
- Rect bounds; /* rectangle around all of popup */
- Rect hilite; /* hilited when a selection is being made */
- Rect title; /* contains the popup's title */
- Rect selection; /* contains the currently selected item and the triangle */
- Rect item; /* contains the currently selected item */
- Rect triangle; /* contains the triangle */
- } PopupRectanglesType;
-
- /* structure containing all the data needed by the popup menu */
- typedef struct {
-
- /* These first two fields will never be changed, other fields may change. */
- PopupPrivateType privateData; /* for compatability with Apple's CDEF */
- short version; /* version of the code that created this popup menu */
-
- /* Fields specified on creation of the popup menu. */
- GrafPtr port; /* port to draw into */
- MenuHandle menu; /* handle to menu */
- ControlHandle ctl; /* handle to control */
- Rect maxbounds; /* maximum bounding rectangle of popup */
-
- /* For patching the menu definition function. */
- Handle menuProc; /* glue to call our own MDEF */
-
- /* Information needed when drawing. */
- struct {
- GWorldPtr gworld; /* offscreen graphics world */
- GDHandle gdevice; /* graphics device to draw into */
- short gdepth; /* pixel depth of graphics device */
- RGBColor fore; /* popup port's foreground color */
- RGBColor back; /* popup port's background color */
- } draw;
-
- /* Internal state information. */
- PopupRectanglesType r; /* rectangles enclosing areas of the popup menu */
- struct {
- short current; /* currently selected item number */
- short drawSetup; /* incremented after drawing environment is setup */
- Boolean createdMenu; /* true means CDEF created menu */
- } state;
-
- /* User settable attributes of the menu. External functions
- are provided to manipulate these fields. */
- struct {
- struct {
- Handle string; /* popup's title string */
- Style style; /* style of popup's title */
- short width; /* width of title; 0 if resized dynamically */
- char just; /* text justification */
- } title;
- char mark; /* character used to mark current item */
- Boolean draw:1; /* false disables drawing and calculating */
- Boolean enabled:1; /* true if menu is enabled */
- Boolean typeIn:1; /* true shows only triangle, like a type-in menu */
- Boolean windowFont:1; /* true uses window font, not system font */
- Boolean fixedWidth:1; /* true uses fixed width for menu */
- Boolean bevel:1; /* true draws a bevel */
- } attr;
-
- } PopupType, *PopupPtr, **PopupHandle;
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- void PopupGlueInit(PopupGlueUnion *glue, ProcPtr proc, ProcInfoType info);
-
- Boolean PopupValid(PopupHandle popup);
-
- void PopupCalculate(PopupHandle popup);
- void PopupDraw(PopupHandle popup);
- short PopupSelect(PopupHandle popup);
- Boolean PopupWithin(PopupHandle popup, Point pt);
-
- short PopupVersion(PopupHandle popup);
- short PopupCurrent(PopupHandle popup);
- void PopupCurrentSet(PopupHandle popup, short current);
- void PopupDrawSet(PopupHandle popup, Boolean draw);
- void PopupEnableSet(PopupHandle popup, Boolean enabled);
- void PopupMarkSet(PopupHandle popup, char mark);
- void PopupTypeInSet(PopupHandle popup, Boolean typein);
- void PopupBevelSet(PopupHandle popup, Boolean bevel);
- void PopupBounds(PopupHandle popup, Rect *bounds);
- void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
- void PopupTitle(PopupHandle popup, Str255 title);
- void PopupTitleSet(PopupHandle popup, const Str255 title);
- void PopupTitleWidthSet(PopupHandle popup, short width);
- void PopupTitleStyleSet(PopupHandle popup, Style style);
- void PopupWindowFontSet(PopupHandle popup, Boolean wfont);
- void PopupFixedWidthSet(PopupHandle popup, Boolean fixedwidth);
- void PopupJustSet(PopupHandle popup, short just);
-
- PopupHandle PopupBegin(GrafPtr port,
- MenuHandle menu,
- const Rect *maxbounds,
- ControlHandle ctl);
- void PopupEnd(PopupHandle popup);
-
- pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
- void PopupCDEFAttach(ControlHandle ctl);
- void PopupCDEFDetach(ControlHandle ctl);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* POPUP_LIBRARY */
-