home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-04 | 5.7 KB | 269 lines | [TEXT/KAHL] |
- /* Optional:
- * pascal long myWindowWDEF (int varCode,
- WindowPeek theWindow,
- int message,
- long param)
- */
-
- pascal long main (int varCode,
- WindowPeek theWindow,
- int message, long param)
- {
- typedef Rect *RPtr;
- Rect r, rclose[4], rgrow, rtitle;
- int i, j, k;
- Point p;
- GrafPtr temp;
- PenState pnState;
- RgnHandle hstructure, hcontent, frame, htitle;
- Pattern pat;
- Str255 title;
-
- GetPort (&temp);
- SetPort ((GrafPtr)theWindow);
-
- r = (*((GrafPtr)theWindow)).portRect;
- i = r.right - r.left;
- j = r.bottom - r.top;
-
- if (i > j)
- i = j;
- r.left = 0;
- r.top = 0;
- LocalToGlobal (& (r));
- SetPort (temp);
- r.bottom = r.top + i;
- r.right = r.left + i;
-
- SetRect (&rclose[0], r.left + 3, r.top + i / 2 - 6,
- r.left + 14, r.top + i / 2 + 5);
-
- SetRect (&rclose[1], r.right - 14, r.top + i / 2 -6,
- r.right - 3, r.top + i / 2 + 5);
-
- SetRect (&rclose[2], r.left + i / 2 - 6, r.top + 3,
- r.left + i / 2 + 5, r.top + 14);
-
- SetRect (&rclose[3], r.left + i / 2 - 6, r.bottom -14,
- r.left + i / 2 + 5, r.bottom -3);
-
- rgrow.right = r.left + i / 2 + ((i / 2) * 10) / 14;
- rgrow.bottom = r.top + i / 2 + ((i / 2) * 10) / 14;
- rgrow.left = rgrow.right - (9 * 141) / 100;
- rgrow.top = rgrow.bottom - (9 * 141) / 100;
- for (k = 0; k < 256; k++)
- title[k] = * (*((*theWindow).titleHandle) + k);
- title == "\p";
- j = StringWidth (&title) / 2 + 15;
- rtitle.left = r.left + i / 2 - j;
- rtitle.right = rtitle.left + j + j;
-
- if (varCode & 0x0008)
- {
- rtitle.top = r.top;
- rtitle.bottom = r.top + 16;
- }
- else
- {
- rtitle.bottom = r.bottom;
- rtitle.top = r.bottom - 16;
- }
- p.v = HiWord (param);
- p.h = LoWord (param);
- hstructure = (*theWindow).strucRgn;
- hcontent = (*theWindow).contRgn;
- switch (message)
- {
- case 0: if ((*theWindow).visible)
- {
- if (param == 0L)
- {
- GetPenState (&pnState);
- PenSize (18, 18);
- PenMode (patBic);
- FrameOval (&r);
- SetPenState (&pnState);
- if (((*theWindow).hilited) && (varCode & 0x0004))
- {
- pat[0] = 0xF8;
- pat[1] = 0x74;
- pat[2] = 0x22;
- pat[3] = 0x47;
- pat[4] = 0x8F;
- pat[5] = 0x17;
- pat[6] = 0x22;
- pat[7] = 0x71;
-
- FrameOval (&r);
- InsetRect (&r, 1, 1);
- FrameOval (&r);
- InsetRect (&r, 1, 1);
- frame = NewRgn ();
- OpenRgn ();
- FrameOval (&r);
- InsetRect (&r, 13, 13);
- FrameOval (&r);
- CloseRgn (frame);
- FillRgn (frame, &pat);
- DisposeRgn (frame);
- FrameOval (&r);
- InsetRect (&r, 1, 1);
- FrameOval (&r);
- }
- else
- {
- FrameOval (&r);
- InsetRect (&r, 3, 3);
- if ((*theWindow).hilited)
- for (i = 0; i < 6; i++)
- {
- FrameOval (&r);
- InsetRect (&r, 2, 2);
- }
- else
- InsetRect (&r, 12, 12);
- InsetRect (&r, 1, 1);FrameOval (&r);
- }
- if (((*theWindow).hilited) && ((*theWindow).goAwayFlag))
- {
- for (i = 0; i < 4; i++)
- {
- EraseRect (&rclose[i]);
- FrameRect (&rclose[i]);}
- }
- if (((*theWindow).hilited) && ((varCode & 0x0002) == 0))
- {
- EraseRect (&rgrow);
- FrameRect (&rgrow);
- }
- if (varCode & 0x0001)
- {
- EraseRect (&rtitle);
- FrameRect (&rtitle);
- if ((*theWindow).hilited)
- {
- InsetRect (&rtitle, 1, 1);
- FrameRect (&rtitle);
- InsetRect (&rtitle, -1, -1);
- MoveTo (rtitle.left + 15, rtitle.top + 13);
- DrawString (&title);
- }
- }
- }
- else
- if (param == 4L)
- {
- GetPenState (&pnState);
- PenMode (patXor);
- for (i = 0; i < 4; i++)
- if ((i == 2) &&
- (varCode & 1) &&
- (varCode & 8));
- else
- if ((i == 3) &&
- (varCode & 1) && !
- (varCode & 8));
- else
- {
- MoveTo (rclose[i].left+2, rclose[i].top+2);
- Line (6, 6);
- MoveTo (rclose[i].left+2, rclose[i].bottom-3);
- Line (6, -6);
- MoveTo (rclose[i].left+1, rclose[i].top + 5);
- Line (8, 0);
- MoveTo (rclose[i].left+5, rclose[i].top+1);
- Line (0, 8);
- InsetRect (&rclose[i], 4, 4);
- EraseRect (&rclose[i]);
- }
- SetPenState (&pnState);
- }
- }
- return (0L);
- break;
-
- case 1:
- if (PtInRgn (p, hcontent))
- return (1L);
- else
- if ((PtInRect (p, &rclose[0])) &&
- ((*theWindow).goAwayFlag) &&
- ((*theWindow).hilited))
- return (4L);
- else
- if ((PtInRect (p, &rclose[1])) &&
- ((*theWindow).goAwayFlag) &&
- ((*theWindow).hilited))
- return (4L);
- else
- if ((PtInRect (p, &rclose[2])) &&
- ((*theWindow).goAwayFlag) &&
- ((*theWindow).hilited) &&
- (! ((varCode & 1) &&
- (varCode & 8))))
- return (4L);
- else
- if ((PtInRect (p, &rclose[3])) &&
- ((*theWindow).goAwayFlag) &&
- (! ((varCode & 1) &&
- ! (varCode & 8))) &&
- ((*theWindow).hilited))
- return (4L);
- else
- if ((PtInRect (p, &rgrow)) &&
- ((varCode & 0x0002) == 0) &&
- ((*theWindow).hilited))
- return (3L);
- else
- if (PtInRgn (p, hstructure))
- return (2L);
- else
- return (0L);
- break;
-
- case 2:
- SetEmptyRgn (hstructure);
- OpenRgn ();
- FrameOval (&r);
- CloseRgn (hstructure);
- if (varCode & 0x0001)
- {
- htitle = NewRgn ();
- RectRgn (htitle, &rtitle);
- UnionRgn (hstructure, htitle,
- hstructure);
- DisposeRgn (htitle);
- }
- InsetRect (&r, 18, 18);
- SetEmptyRgn (hcontent);
- OpenRgn ();
- FrameOval (&r);
- CloseRgn (hcontent);
- break;
-
- case 3:
- return (0L);
- break;
-
- case 4:
- return (0L);
- break;
-
- case 5:
- r = * (RPtr)param;
- i = r.right - r.left;
- j = r.bottom - r.top;
- if (i > j) i = j;
- r.right = r.left + i;
- r.bottom = r.top + i;
- FrameOval (&r);
- return (0L);
- break;
-
- case 6:
- return (0L);
- break;
- }
- }
-
-