Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!jarthur!usc!cs.utexas.edu!rutgers!ucsd!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: How to highlight buttons Message-ID: <10560@hoptoad.uucp> Date: 3 Mar 90 23:51:43 GMT References: <288@bii.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 62 In article <288@bii.UUCP> jsl@bii.UUCP (jsl) writes: >I have been trying to figure out how to highlight the default >buttons in a dialog. However I have been unsuccessful. > > GetDItem (AcquDLOG, iAcquOK, &ItemType, &ItemHandle, &ItemRect); > PenSize (3,3); > InsetRect(&ItemRect, -4, -4); > OffsetRect(&ItemRect, 50, 50); > FrameRoundRect(&ItemRect, 16, 16); What's the OffsetRect for? That is moving your rectangle 50 pixels down and to the right of where you want it to be. If the OK button is near the bottom of the dialog, then you are probably drawing the round rectangle outside the window. I do something messy, but convenient, to outline default buttons. Every dialog has an external dialog information resource that tries to describe the dialog's behavior non-procedurally as much as possible. One of the fields is an outline item id. When I see this on creating a dialog, I add a new user item to the dialog item list in memory, and bind a drawing procedure to it. It goes like this: typedef struct { ProcPtr p; Rect r; char type; char length; } AUserItem; if ((*extra)->defButton) { AUserItem user; /* add outline user item */ GetIRect(dialog, (*extra)->defButton, &user.r); InsetRect(&user.r, -4, -4); user.p = (ProcPtr)DrawRoundRect; user.type = userItem | itemDisable; user.length = 0; PtrAndHand((Ptr)&user, ((DialogPeek)dialog)->items, sizeof(AUserItem)); (**(short **)(((DialogPeek)dialog)->items))++; } pascal void DrawRoundRect(DialogPtr dialog, short item) { Rect r; PenState state; GetPenState(&state); PenSize(3, 3); GetIRect(dialog, item, &r); FrameRoundRect(&r, 16, 16); SetPenState(&state); } void GetIRect(DialogPtr dialog, short item, Rect *r) { short type; Handle h; GetDItem(dialog, item, &type, &h, r); } -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "There's a real world out there, with real people. Go out and play there for a while and give the Usenet sandbox a rest. It will lower your stress levels and make the world a happier place for us all." -- Gene Spafford