// frame.h // // by John D. de Boer // Type definitions typedef struct { struct window *wind; // front window when key was down UInt8 c; // character typed by user bool shift, // whether shift key was down opt; // whether option key was down } keystroke; typedef struct { struct window *wind; // window in which user clicked point point; // point, in local coordinates, of click bool right, // whether it was the "right" button that was clicked shift, // whether shift key was down cmnd, // whether command key was down opt; // whether option key was down point now; // used when tracking mouse MouseTrackingResult res; // used when tracking mouse OSStatus err; // used when tracking mouse } mouseclick; typedef void (*voidprocptr)(void); typedef void (*boolprocptr)(bool Active); typedef void (*windprocptr)(struct window *W); typedef void (*aspectprocptr)(point *Size); typedef void (*docprocptr)(FSRef *FSR); typedef bool (*comdprocptr)(struct window *W, UInt32 C); typedef bool (*keyprocptr)(keystroke *K); typedef bool (*clickprocptr)(mouseclick *M); typedef bool (*wheelprocptr)(struct window *W, short DX, short DY); typedef short (*numpgprocptr)(struct window *W, rect R); typedef void (*printprocptr)(struct window *W, short PAGE); typedef bool (*pdfsizepp)(struct window *W, rect *R); typedef struct window { WindowRef wmw; // opaque Window Manager structure bool inq; // whether the app is between beginquartz() and endquartz() CGContextRef q2d; // the drawing context for Quartz 2D, valid within drawing call-backs CGColorSpaceRef cs; // the Quartz colour space CGRect page; // the Quartz window rectangle (minus controls) ControlRef hsb, // horizontal scrollbar vsb, // vertical scrollbar **row; // tapedeck-like buttons in lower-left of window short rownum, // number of controls in **row thickness, // width of scrollbars in pixels leftspace; // space to left of horz. scrollbar in pixels bool modal, // whether the window is a moveable, modal dialog window resizable, // whether the window is resizable erase; // whether the window should be erased before drawing Rect qdpage; // drawing area, less scrollbars, in local coordinates void *proj, // a projection, if any, used in this window *appdata; // for use at the application level; not allocated or freed by frame.c voidprocptr setup; // call-back for menu setup, used when window comes to the front windprocptr adjust, // call-back for menu enabling/checking, etc. close, // call-back for closing/hiding window resize, // call-back for resizing draw, // call-back for drawing window contents action; // call-back for action of projection controls clickprocptr click, // call-back for user click in window doubclick, // call-back for double-click move; // call-back for mouse-moved events wheelprocptr wheel; // call-back for scroll-wheel events EventTime downtime; // time of last mouse-down event comdprocptr comd; // call-back for command IDs (generally menus) keyprocptr key; // call-back for keystroke with window in foreground aspectprocptr aspect; // call-back for restriction on window aspect ratio numpgprocptr numpages; // call-back for how many pages a document contains (default: 1) printprocptr print; // call-back for printing window contents pdfsizepp pdfsize; // call-back to determine full size of a PDF (default: page) windprocptr drawpdf; // call-back for drawing window contents into a full-size PDF Handle menubar; // the menu bar associated with this window PMPrintSettings settings; // printing settings passed to printcompletion(); bool printing; // whether drawing is being sent to a printer } window; // Initialisation void initframe(void); // Drawing with frame.c windows void initquartzcontext(CGContextRef Q, CGColorSpaceRef Space); //void beginquartz(window *W); //void endquartz(window *W); void redraw(window *W); void controlaction(window *W); // ? // The control manager for frame.c #define SCROLLTHICK (15) void setcontrolwidth(window *W, int WIDTH); void enablecontrol(ControlRef C, bool Enabled); void setscrollbar(ControlRef C, int VAL, int MIN, int MAX); void setscrollfrac(ControlRef C, int MIN, int MAX); void resizecontrol(ControlRef C, Rect *R); void sizevertscroll(ControlRef C, int THICK); void sizehorzscroll(ControlRef C, int THICK, int LEFTSPACE, bool Grow); void sizescrolls(window *W); window *controlswindow(ControlRef C); ControlRef newscroll(WindowRef WP, bool Vert, bool Vis); ControlRef commonbutton(window *W, int POSN, int VAR); void givescrolls(window *W); void givevertscroll(window *W); void givehorzscroll(window *W); int partincrement(int PART, int LINE, int PAGE); void movetapedeckrow(window *W); bool stilldown(mouseclick *M); // The window manager for frame.c void postwindowmenus(window *W); window *windowfromlist(WindowRef WP); window *frontmost(void); window *customwindow(const char *Title, int WIDTH, int HEIGHT, bool Grow); window *standardwindow(const char *Title); window *standarddialog(const char *Title, int WIDTH, int HEIGHT); void oldwindow(window *W); // Installation of call-back routines for window-related events void installpaint(window *W, windprocptr Draw); void installgrow(window *W, windprocptr Proc, aspectprocptr Aspect); void installclick(window *W, clickprocptr Click, windprocptr Close, windprocptr Action); void installdouble(window *W, clickprocptr Double); void installmousemove(window *W, clickprocptr Proc); void installwheel(window *W, wheelprocptr Proc); void installmenus(window *W, Handle MenuBar, voidprocptr Setup, windprocptr Adjust, comdprocptr Comd); void installkey(window *W, keyprocptr Proc); void installprint(window *W, numpgprocptr Num, printprocptr Draw); void installpict(window *W, pdfsizepp Size, windprocptr Draw); // void closewindow(window *W); void concealwindow(window *W); // needed? void revealwindow(window *W); // open? bool windowseen(window *W); void revealbehind(window *W, window *Front); void setwindowname(window *W, char *S); void stackwindow(window *W, int PLACE); void tilewindow(window *W, int PLACE, int TOTAL, bool Horz); // The menu manager for frame.c void truncatemenu(MenuRef M, int LEAVE); void adjustwindowmenu(MenuRef M, int BEFORE); window *windowchoice(UInt32 C);