+ te = (TEHandle)(*mc->text.tbctrl)->contrlData;
+ TESetText(ctrl->text.label, strlen(ctrl->text.label), te);
+ height = TEGetHeight(1, (*te)->nLines, te);
+ }
+#endif
+ SizeControl(mc->text.tbctrl, curstate->width, height);
+ curstate->pos.v += height + 6;
+ add234(mcs->byctrl, mc);
+ mc->generic.next = mcs->panels[curstate->panelnum];
+ mcs->panels[curstate->panelnum] = mc;
+}
+
+static void macctrl_editbox(struct macctrls *mcs, WindowPtr window,
+ struct mac_layoutstate *curstate,
+ union control *ctrl)
+{
+ union macctrl *mc = snew(union macctrl);
+ Rect lbounds, bounds, butbounds;
+ static int nextmenuid = MENU_MIN;
+ int menuid;
+ MenuRef menu;
+
+ mc->generic.type = MACCTRL_EDITBOX;
+ mc->generic.ctrl = ctrl;
+ mc->generic.privdata = NULL;
+ lbounds.left = curstate->pos.h;
+ lbounds.top = curstate->pos.v;
+ if (ctrl->editbox.percentwidth == 100) {
+ if (ctrl->editbox.label != NULL) {
+ lbounds.right = lbounds.left + curstate->width;
+ lbounds.bottom = lbounds.top + 16;
+ curstate->pos.v += 18;
+ }
+ bounds.left = curstate->pos.h;
+ bounds.right = bounds.left + curstate->width;
+ } else {
+ lbounds.right = lbounds.left +
+ curstate->width * (100 - ctrl->editbox.percentwidth) / 100;
+ lbounds.bottom = lbounds.top + 22;
+ bounds.left = lbounds.right;
+ bounds.right = lbounds.left + curstate->width;
+ }
+ bounds.top = curstate->pos.v;
+ bounds.bottom = bounds.top + 22;
+
+ if (ctrl->editbox.has_list) {
+ butbounds = bounds;
+ butbounds.left = butbounds.right - 20;
+ bounds.right -= 26; /* enough for 6 px gap and a button */
+ }
+
+ if (mac_gestalts.apprvers >= 0x100) {
+ if (ctrl->editbox.label == NULL)
+ mc->editbox.tblabel = NULL;
+ else {
+ mc->editbox.tblabel = NewControl(window, &lbounds, NULL, FALSE,
+ 0, 0, 0, kControlStaticTextProc,
+ (long)mc);
+ SetControlData(mc->editbox.tblabel, kControlEntireControl,
+ kControlStaticTextTextTag,
+ strlen(ctrl->editbox.label), ctrl->editbox.label);
+ }
+ InsetRect(&bounds, 3, 3);
+ mc->editbox.tbctrl = NewControl(window, &bounds, NULL, FALSE, 0, 0, 0,
+ ctrl->editbox.password ?
+ kControlEditTextPasswordProc :
+ kControlEditTextProc, (long)mc);
+ }
+#if !TARGET_API_MAC_CARBON
+ else {
+ if (ctrl->editbox.label == NULL)
+ mc->editbox.tblabel = NULL;
+ else {
+ mc->editbox.tblabel = NewControl(window, &lbounds, NULL, FALSE,
+ 0, 0, 0, SYS7_TEXT_PROC,
+ (long)mc);
+ TESetText(ctrl->editbox.label, strlen(ctrl->editbox.label),
+ (TEHandle)(*mc->editbox.tblabel)->contrlData);
+ }
+ mc->editbox.tbctrl = NewControl(window, &bounds, NULL, FALSE, 0, 0, 0,
+ SYS7_EDITBOX_PROC, (long)mc);
+ }
+#endif
+
+ if (ctrl->editbox.has_list) {
+ while (GetMenuHandle(nextmenuid) != NULL)
+ if (++nextmenuid >= MENU_MAX) nextmenuid = MENU_MIN;
+ menuid = nextmenuid++;
+ menu = NewMenu(menuid, "\pdummy");
+ if (menu == NULL) goto nomenu;
+ mc->editbox.menu = menu;
+ mc->editbox.menuid = menuid;
+ InsertMenu(menu, kInsertHierarchicalMenu);
+ mc->editbox.nids = 0;
+ mc->editbox.ids = NULL;
+
+ mc->editbox.tbbutton = NewControl(window, &butbounds, NULL, FALSE,
+ popupTitleLeftJust, menuid, 0,
+ popupMenuProc + popupFixedWidth,
+ (long)mc);