Custom Window Procedures

A reference for routines and structures within the Window Manager.

Routine: NewWindow

Description: Creates a window specified by wndParams, adds it to the window list, and returns a pointer to the window’s new GrafPort

Tool call: $090E

APW declaration: extern pascal WindowPtr NewWindow() inline(0x090E,dispatcher);

C declaration: WindowPtr NewWindow(ParamListPtr wndParams);

Parameter structure:

typedef struct ParamList {
    Word paramLength;
    Word wFrameBits;
    Pointer wTitle;
    LongWord wRefCon;
    Rect wZoom;
    WindColorPtr wColor;
    Word wYOrigin;
    Word wXOrigin;
    Word wDataH;
    Word wDataW;
    Word wMaxH;
    Word wMaxW;
    Word wScrollVer;
    Word wScrollHor;
    Word wPageVer;
    Word wPageHor;
    LongWord wInfoRefCon;
    Word wInfoHeight;
    LongProcPtr wFrameDefProc;
    VoidProcPtr wInfoDefProc;
    VoidProcPtr wContDefProc;
    Rect wPosition;
    WindowPtr wPlane;
    WindRecPtr wStorage;
} ParamList, *ParamListPtr, **ParamListHndl;

ParamList fields

Field Description
Word paramLength Size of ParamList record in bytes, including this field.
Word wFrameBits Window attributes (see wFrame Field Bits for more details).
Pointer wTitle Pointer to window title.
LongWord wRefCon Reserved for application use.
Rect wZoom Size and position of window when zoomed. Set to 0 for screen size.
WindColorPtr wColor Pointer to window’s color table.
Word wYOrigin Content vertical origin in pixels.
Word wXOrigin Content horizontal origin in pixels.
Word wDataH Data area height in pixels.
Word wDataW Data area width in pixels.
Word wMaxH Maximum height allowed by GrowWindow.
Word wMaxW Maximum width allowed by GrowWindow.
Word wScrollVer Number of pixels to scroll vertically using scroll bar arrows.
Word wScrollHor Number of pixels to scroll horizontally using scroll bar arrows.
Word wPageVer Number of pixels to scroll vertically when using page control.
Word wPageHor Number of pixels to scroll horizontally when using page control.
LongWord wInfoRefCon Value passed to info bar draw routine.
Word wInfoHeight Height of information bar in pixels.
LongProcPtr wFrameDefProc Address of window definition procedure. See Custom Window Procedures.
VoidProcPtr wInfoDefProc Address of routine to draw info bar interior.
VoidProcPtr wContDefProc Address of routine to content region interior.
Rect wPosition Starting position and size of window.
WindowPtr wPlane Window starting plane (FFFFFFFF = foremost).
WindRecPtr wStorage Address for record (0 to allocate).

wFrame Field Bits

Bit # Name of Field Value Description
0 F_HILITED 1: Frame highlighted
0: Frame not highlighted
1 F_ZOOMED 1: Currently zoomed
0: Frame not zoomed
2 F_ALLOCATED 1: Record was allocated
0: Record was provided by application
3 F_CTRL_TIE 1: Control’s state is independent
0: Inactive window has inactive controls
4 F_INFO 1: Frame has information bar
0: Frame does not have information bar
5 F_VIS 1: Window is visible
0: Window is not visible
6 F_QCONTENT 1: Return wInContent even if window is inactive
0: Do not return wInContent if window is inactive
7 F_MOVE 1: Title bar is a drag region
0: No drag region
8 F_ZOOM 1: Zoom box on title bar
0: No zoom box (zoom box must have title bar)
9 F_FLEX 1: GrowWindow and ZoomWindow will not change the origin
0: GrowWindow and ZoomWindow will affect the origin
10 F_GROW 1: Grow box
0: No grow box (grow box must have at least one scroll bar)
11 F_BSCRL 1: Window frame horizontal scroll bar
0: No horizontal scroll bar
12 F_RSCRL 1: Window frame vertical scroll bar
0: No vertical scroll bar
13 F_ALERT 1: Alert type frame (don’t set grow box, close box, info bar, title bar, or scroll bars)
0: Standard frame
14 F_CLOSE 1: Enable close box on title bar
0: No close box (close box must have title bar)
15 F_TITLE 1: Enable title bar
0: No title bar

Using wFrameDefProc to define custom procedures

The signature for wFrameDefProc is long windowDefProc(Word varCode, GrafPortPtr grafPort, Long params);

Values for varCode parameters for custom windows

Value Name Description
0 wDraw Draw window frame
1 wHit Tell what region was in when the mouse region was pressed
2 wCalcRgns Calculate wStructRgn and wContRgn
3 wNew Do any additional window initialization
4 wDispose Take any additional disposal actions
5 wGrow Draw window’s grow image

Parameters for varCode values

Name Value Description
wDrawFrame 0 Draw region’s entire frame
wInGoAway 1 Draw go-away region
wInZoom 2 Draw zoom region
Bit 31 1: highlight, 0: unhighlighted Draw frame or region with or without highlights

Valid params values:

Value Description
0x0000 Draw entire window frame as an inactive window
0x8000 Draw entire window frame as an active window
0x0001 Draw go-away region as unhighlighted
0x8001 Draw go-away region as highlighted
0x0002 Draw zoom region as highlighted
0x8002 Draw zoom region as unhighlighted