+#if !TARGET_API_MAC_CARBON
+static pascal SInt32 macctrl_sys7_listbox_cdef(SInt16 variant,
+ ControlRef control,
+ ControlDefProcMessage msg,
+ SInt32 param)
+{
+ RgnHandle rgn;
+ Rect rect;
+ ListHandle list;
+ long ssfs;
+ Point mouse;
+ ListBounds bounds;
+ Point csize;
+ short savefont;
+ short savesize;
+ GrafPtr curport;
+
+ switch (msg) {
+ case initCntl:
+ rect = (*control)->contrlRect;
+ InsetRect(&rect, 4, 4);
+ rect.right -= 15; /* scroll bar */
+ bounds.top = bounds.bottom = bounds.left = 0;
+ bounds.right = 1;
+ csize.h = csize.v = 0;
+ GetPort(&curport);
+ savefont = curport->txFont;
+ savesize = curport->txSize;
+ ssfs = GetScriptVariable(smSystemScript, smScriptSysFondSize);
+ TextFont(HiWord(ssfs));
+ TextSize(LoWord(ssfs));
+ list = LNew(&rect, &bounds, csize, 0, (*control)->contrlOwner,
+ TRUE, FALSE, FALSE, TRUE);
+ SetControlReference((*list)->vScroll, (long)list);
+ (*control)->contrlData = (Handle)list;
+ TextFont(savefont);
+ TextSize(savesize);
+ return noErr;
+ case dispCntl:
+ /*
+ * If the dialogue box is being destroyed, the scroll bar
+ * might have gone already. In our situation, this is the
+ * only time we destroy a control, so NULL out the scroll bar
+ * handle to prevent LDispose trying to free it.
+ */
+ list = (ListHandle)(*control)->contrlData;
+ (*list)->vScroll = NULL;
+ LDispose(list);
+ return 0;
+ case drawCntl:
+ if ((*control)->contrlVis) {
+ rect = (*control)->contrlRect;
+ /* XXX input focus highlighting? */
+ InsetRect(&rect, 3, 3);
+ PenNormal();
+ FrameRect(&rect);
+ list = (ListHandle)(*control)->contrlData;
+ LActivate((*control)->contrlHilite != kControlInactivePart, list);
+ GetPort(&curport);
+ LUpdate(curport->visRgn, list);
+ }
+ return 0;
+ case testCntl:
+ mouse.h = LoWord(param);
+ mouse.v = HiWord(param);
+ rect = (*control)->contrlRect;
+ InsetRect(&rect, 4, 4);
+ /*
+ * We deliberately exclude the scrollbar so that LClick() can see it.
+ */
+ rect.right -= 15;
+ return PtInRect(mouse, &rect) ? kControlListBoxPart : kControlNoPart;
+ case calcCRgns:
+ if (param & (1 << 31)) {
+ param &= ~(1 << 31);
+ goto calcthumbrgn;
+ }
+ /* FALLTHROUGH */
+ case calcCntlRgn:
+ rgn = (RgnHandle)param;
+ RectRgn(rgn, &(*control)->contrlRect);
+ return 0;
+ case calcThumbRgn:
+ calcthumbrgn:
+ rgn = (RgnHandle)param;
+ SetEmptyRgn(rgn);
+ return 0;
+ }
+
+ return 0;
+}
+#endif
+
+#if !TARGET_API_MAC_CARBON
+static pascal SInt32 macctrl_sys7_groupbox_cdef(SInt16 variant,
+ ControlRef control,
+ ControlDefProcMessage msg,
+ SInt32 param)
+{
+ RgnHandle rgn;
+ Rect rect;
+ PenState savestate;
+
+ switch (msg) {
+ case drawCntl:
+ if ((*control)->contrlVis) {
+ rect = (*control)->contrlRect;
+ GetPenState(&savestate);
+ PenNormal();
+ PenSize(3, 3);
+ PenPat(&qd.gray);
+ FrameRect(&rect);
+ SetPenState(&savestate);
+ }
+ return 0;
+ case calcCRgns:
+ if (param & (1 << 31)) {
+ param &= ~(1 << 31);
+ goto calcthumbrgn;
+ }
+ /* FALLTHROUGH */
+ case calcCntlRgn:
+ rgn = (RgnHandle)param;
+ RectRgn(rgn, &(*control)->contrlRect);
+ return 0;
+ case calcThumbRgn:
+ calcthumbrgn:
+ rgn = (RgnHandle)param;
+ SetEmptyRgn(rgn);
+ return 0;
+ }
+ return 0;
+}
+#endif