зеркало из https://github.com/github/putty.git
Convert the System 7 static text control to be a read-only version of the
editbox control. This means that it has a persistent edit record, can have its height measured and uses the system font by default, all of which are good. [originally from svn r3022]
This commit is contained in:
Родитель
f0f5932bf8
Коммит
c1c7f5eb49
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: mac_res.r,v 1.36 2003/03/29 18:31:09 ben Exp $ */
|
/* $Id: mac_res.r,v 1.37 2003/03/29 22:04:21 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2002, 2003 Ben Harris
|
* Copyright (c) 1999, 2002, 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -1122,9 +1122,6 @@ resource 'TEXT' (wLicence, "licence", purgeable) {
|
||||||
|
|
||||||
/* Custom xDEFs */
|
/* Custom xDEFs */
|
||||||
|
|
||||||
data 'CDEF' (CDEF_Text) {
|
|
||||||
$"4EF9 00000000"
|
|
||||||
};
|
|
||||||
data 'CDEF' (CDEF_EditBox) {
|
data 'CDEF' (CDEF_EditBox) {
|
||||||
$"4EF9 00000000"
|
$"4EF9 00000000"
|
||||||
};
|
};
|
||||||
|
|
134
mac/macctrls.c
134
mac/macctrls.c
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: macctrls.c,v 1.19 2003/03/29 20:16:51 ben Exp $ */
|
/* $Id: macctrls.c,v 1.20 2003/03/29 22:04:21 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003 Ben Harris
|
* Copyright (c) 2003 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -133,8 +133,6 @@ static void macctrl_button(struct macctrls *, WindowPtr,
|
||||||
static void macctrl_popup(struct macctrls *, WindowPtr,
|
static void macctrl_popup(struct macctrls *, WindowPtr,
|
||||||
struct mac_layoutstate *, union control *);
|
struct mac_layoutstate *, union control *);
|
||||||
#if !TARGET_API_MAC_CARBON
|
#if !TARGET_API_MAC_CARBON
|
||||||
static pascal SInt32 macctrl_sys7_text_cdef(SInt16, ControlRef,
|
|
||||||
ControlDefProcMessage, SInt32);
|
|
||||||
static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16, ControlRef,
|
static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16, ControlRef,
|
||||||
ControlDefProcMessage, SInt32);
|
ControlDefProcMessage, SInt32);
|
||||||
static pascal SInt32 macctrl_sys7_default_cdef(SInt16, ControlRef,
|
static pascal SInt32 macctrl_sys7_default_cdef(SInt16, ControlRef,
|
||||||
|
@ -163,8 +161,6 @@ static void macctrl_init()
|
||||||
PatchCDEF cdef;
|
PatchCDEF cdef;
|
||||||
|
|
||||||
if (inited) return;
|
if (inited) return;
|
||||||
cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Text);
|
|
||||||
(*cdef)->theUPP = NewControlDefProc(macctrl_sys7_text_cdef);
|
|
||||||
cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_EditBox);
|
cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_EditBox);
|
||||||
(*cdef)->theUPP = NewControlDefProc(macctrl_sys7_editbox_cdef);
|
(*cdef)->theUPP = NewControlDefProc(macctrl_sys7_editbox_cdef);
|
||||||
cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Default);
|
cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Default);
|
||||||
|
@ -239,7 +235,8 @@ void macctrl_layoutbox(struct controlbox *cb, WindowPtr window,
|
||||||
}
|
}
|
||||||
macctrl_layoutset(&curstate, cb->ctrlsets[i], window, mcs);
|
macctrl_layoutset(&curstate, cb->ctrlsets[i], window, mcs);
|
||||||
}
|
}
|
||||||
macctrl_switchtopanel(mcs, 14);
|
macctrl_switchtopanel(mcs, 2);
|
||||||
|
/* 14 = proxies, 20 = SSH bugs */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void macctrl_layoutset(struct mac_layoutstate *curstate,
|
static void macctrl_layoutset(struct mac_layoutstate *curstate,
|
||||||
|
@ -384,6 +381,7 @@ static void macctrl_text(struct macctrls *mcs, WindowPtr window,
|
||||||
{
|
{
|
||||||
union macctrl *mc = smalloc(sizeof *mc);
|
union macctrl *mc = smalloc(sizeof *mc);
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
|
SInt16 height;
|
||||||
|
|
||||||
fprintf(stderr, " label = %s\n", ctrl->text.label);
|
fprintf(stderr, " label = %s\n", ctrl->text.label);
|
||||||
mc->generic.type = MACCTRL_TEXT;
|
mc->generic.type = MACCTRL_TEXT;
|
||||||
|
@ -394,7 +392,6 @@ static void macctrl_text(struct macctrls *mcs, WindowPtr window,
|
||||||
bounds.top = curstate->pos.v;
|
bounds.top = curstate->pos.v;
|
||||||
bounds.bottom = bounds.top + 16;
|
bounds.bottom = bounds.top + 16;
|
||||||
if (mac_gestalts.apprvers >= 0x100) {
|
if (mac_gestalts.apprvers >= 0x100) {
|
||||||
SInt16 height;
|
|
||||||
Size olen;
|
Size olen;
|
||||||
|
|
||||||
mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0,
|
mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0,
|
||||||
|
@ -405,54 +402,26 @@ static void macctrl_text(struct macctrls *mcs, WindowPtr window,
|
||||||
GetControlData(mc->text.tbctrl, kControlEntireControl,
|
GetControlData(mc->text.tbctrl, kControlEntireControl,
|
||||||
kControlStaticTextTextHeightTag,
|
kControlStaticTextTextHeightTag,
|
||||||
sizeof(height), &height, &olen);
|
sizeof(height), &height, &olen);
|
||||||
fprintf(stderr, " height = %d\n", height);
|
|
||||||
SizeControl(mc->text.tbctrl, curstate->width, height);
|
|
||||||
curstate->pos.v += height + 6;
|
|
||||||
} else {
|
|
||||||
Str255 title;
|
|
||||||
|
|
||||||
c2pstrcpy(title, ctrl->text.label);
|
|
||||||
mc->text.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 0,
|
|
||||||
SYS7_TEXT_PROC, (long)mc);
|
|
||||||
}
|
}
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
else {
|
||||||
|
TEHandle te;
|
||||||
|
|
||||||
|
mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0,
|
||||||
|
SYS7_TEXT_PROC, (long)mc);
|
||||||
|
te = (TEHandle)(*mc->text.tbctrl)->contrlData;
|
||||||
|
TESetText(ctrl->text.label, strlen(ctrl->text.label), te);
|
||||||
|
height = TEGetHeight(1, (*te)->nLines, te);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
fprintf(stderr, " height = %d\n", height);
|
||||||
|
SizeControl(mc->text.tbctrl, curstate->width, height);
|
||||||
|
curstate->pos.v += height + 6;
|
||||||
add234(mcs->byctrl, mc);
|
add234(mcs->byctrl, mc);
|
||||||
mc->generic.next = mcs->panels[curstate->panelnum];
|
mc->generic.next = mcs->panels[curstate->panelnum];
|
||||||
mcs->panels[curstate->panelnum] = mc;
|
mcs->panels[curstate->panelnum] = mc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TARGET_API_MAC_CARBON
|
|
||||||
static pascal SInt32 macctrl_sys7_text_cdef(SInt16 variant, ControlRef control,
|
|
||||||
ControlDefProcMessage msg, SInt32 param)
|
|
||||||
{
|
|
||||||
RgnHandle rgn;
|
|
||||||
|
|
||||||
switch (msg) {
|
|
||||||
case drawCntl:
|
|
||||||
if ((*control)->contrlVis)
|
|
||||||
TETextBox((*control)->contrlTitle + 1, (*control)->contrlTitle[0],
|
|
||||||
&(*control)->contrlRect, teFlushDefault);
|
|
||||||
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
|
|
||||||
|
|
||||||
static void macctrl_editbox(struct macctrls *mcs, WindowPtr window,
|
static void macctrl_editbox(struct macctrls *mcs, WindowPtr window,
|
||||||
struct mac_layoutstate *curstate,
|
struct mac_layoutstate *curstate,
|
||||||
union control *ctrl)
|
union control *ctrl)
|
||||||
|
@ -495,15 +464,17 @@ static void macctrl_editbox(struct macctrls *mcs, WindowPtr window,
|
||||||
ctrl->editbox.password ?
|
ctrl->editbox.password ?
|
||||||
kControlEditTextPasswordProc :
|
kControlEditTextPasswordProc :
|
||||||
kControlEditTextProc, (long)mc);
|
kControlEditTextProc, (long)mc);
|
||||||
} else {
|
}
|
||||||
Str255 title;
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
else {
|
||||||
c2pstrcpy(title, ctrl->editbox.label);
|
mc->editbox.tblabel = NewControl(window, &lbounds, NULL, TRUE,
|
||||||
mc->editbox.tblabel = NewControl(window, &lbounds, title, TRUE,
|
|
||||||
0, 0, 0, SYS7_TEXT_PROC, (long)mc);
|
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, TRUE, 0, 0, 0,
|
mc->editbox.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0,
|
||||||
SYS7_EDITBOX_PROC, (long)mc);
|
SYS7_EDITBOX_PROC, (long)mc);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
curstate->pos.v += 28;
|
curstate->pos.v += 28;
|
||||||
add234(mcs->byctrl, mc);
|
add234(mcs->byctrl, mc);
|
||||||
mc->generic.next = mcs->panels[curstate->panelnum];
|
mc->generic.next = mcs->panels[curstate->panelnum];
|
||||||
|
@ -526,7 +497,8 @@ static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16 variant,
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case initCntl:
|
case initCntl:
|
||||||
rect = (*control)->contrlRect;
|
rect = (*control)->contrlRect;
|
||||||
InsetRect(&rect, 3, 3); /* 2 if it's 20 pixels high */
|
if (variant == SYS7_EDITBOX_VARIANT)
|
||||||
|
InsetRect(&rect, 3, 3); /* 2 if it's 20 pixels high */
|
||||||
te = TENew(&rect, &rect);
|
te = TENew(&rect, &rect);
|
||||||
ssfs = GetScriptVariable(smSystemScript, smScriptSysFondSize);
|
ssfs = GetScriptVariable(smSystemScript, smScriptSysFondSize);
|
||||||
(*te)->txSize = LoWord(ssfs);
|
(*te)->txSize = LoWord(ssfs);
|
||||||
|
@ -539,18 +511,23 @@ static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16 variant,
|
||||||
case drawCntl:
|
case drawCntl:
|
||||||
if ((*control)->contrlVis) {
|
if ((*control)->contrlVis) {
|
||||||
rect = (*control)->contrlRect;
|
rect = (*control)->contrlRect;
|
||||||
PenNormal();
|
if (variant == SYS7_EDITBOX_VARIANT) {
|
||||||
FrameRect(&rect);
|
PenNormal();
|
||||||
InsetRect(&rect, 3, 3);
|
FrameRect(&rect);
|
||||||
|
InsetRect(&rect, 3, 3);
|
||||||
|
}
|
||||||
|
(*(TEHandle)(*control)->contrlData)->viewRect = rect;
|
||||||
TEUpdate(&rect, (TEHandle)(*control)->contrlData);
|
TEUpdate(&rect, (TEHandle)(*control)->contrlData);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case testCntl:
|
case testCntl:
|
||||||
|
if (variant == SYS7_TEXT_VARIANT)
|
||||||
|
return kControlNoPart;
|
||||||
mouse.h = LoWord(param);
|
mouse.h = LoWord(param);
|
||||||
mouse.v = HiWord(param);
|
mouse.v = HiWord(param);
|
||||||
return
|
rect = (*control)->contrlRect;
|
||||||
PtInRect(mouse, &(*(TEHandle)(*control)->contrlData)->viewRect) ?
|
InsetRect(&rect, 3, 3);
|
||||||
kControlEditTextPart : kControlNoPart;
|
return PtInRect(mouse, &rect) ? kControlEditTextPart : kControlNoPart;
|
||||||
case calcCRgns:
|
case calcCRgns:
|
||||||
if (param & (1 << 31)) {
|
if (param & (1 << 31)) {
|
||||||
param &= ~(1 << 31);
|
param &= ~(1 << 31);
|
||||||
|
@ -598,13 +575,15 @@ static void macctrl_radio(struct macctrls *mcs, WindowPtr window,
|
||||||
SetControlData(mc->radio.tblabel, kControlEntireControl,
|
SetControlData(mc->radio.tblabel, kControlEntireControl,
|
||||||
kControlStaticTextTextTag,
|
kControlStaticTextTextTag,
|
||||||
strlen(ctrl->radio.label), ctrl->radio.label);
|
strlen(ctrl->radio.label), ctrl->radio.label);
|
||||||
} else {
|
|
||||||
Str255 title;
|
|
||||||
|
|
||||||
c2pstrcpy(title, ctrl->radio.label);
|
|
||||||
mc->editbox.tblabel = NewControl(window, &bounds, title, TRUE,
|
|
||||||
0, 0, 0, SYS7_TEXT_PROC, (long)mc);
|
|
||||||
}
|
}
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
else {
|
||||||
|
mc->radio.tblabel = NewControl(window, &bounds, NULL, TRUE,
|
||||||
|
0, 0, 0, SYS7_TEXT_PROC, (long)mc);
|
||||||
|
TESetText(ctrl->radio.label, strlen(ctrl->radio.label),
|
||||||
|
(TEHandle)(*mc->radio.tblabel)->contrlData);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
curstate->pos.v += 18;
|
curstate->pos.v += 18;
|
||||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||||
fprintf(stderr, " button = %s\n", ctrl->radio.buttons[i]);
|
fprintf(stderr, " button = %s\n", ctrl->radio.buttons[i]);
|
||||||
|
@ -817,7 +796,7 @@ void macctrl_activate(WindowPtr window, EventRecord *event)
|
||||||
TRUE);
|
TRUE);
|
||||||
state = active ? kControlNoPart : kControlInactivePart;
|
state = active ? kControlNoPart : kControlInactivePart;
|
||||||
for (i = 0; i <= mcs->curpanel; i += mcs->curpanel)
|
for (i = 0; i <= mcs->curpanel; i += mcs->curpanel)
|
||||||
for (mc = mcs->panels[i]; mc != NULL; mc = mc->generic.next)
|
for (mc = mcs->panels[i]; mc != NULL; mc = mc->generic.next) {
|
||||||
switch (mc->generic.type) {
|
switch (mc->generic.type) {
|
||||||
case MACCTRL_TEXT:
|
case MACCTRL_TEXT:
|
||||||
HiliteControl(mc->text.tbctrl, state);
|
HiliteControl(mc->text.tbctrl, state);
|
||||||
|
@ -841,6 +820,15 @@ void macctrl_activate(WindowPtr window, EventRecord *event)
|
||||||
HiliteControl(mc->popup.tbctrl, state);
|
HiliteControl(mc->popup.tbctrl, state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if !TARGET_API_MAC_CARBON
|
||||||
|
if (mcs->focus == mc) {
|
||||||
|
if (active)
|
||||||
|
macctrl_enfocus(mc);
|
||||||
|
else
|
||||||
|
macctrl_defocus(mc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
SetPort(saveport);
|
SetPort(saveport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1375,16 +1363,16 @@ void dlg_text_set(union control *ctrl, void *dlg, char const *text)
|
||||||
{
|
{
|
||||||
struct macctrls *mcs = dlg;
|
struct macctrls *mcs = dlg;
|
||||||
union macctrl *mc = findbyctrl(mcs, ctrl);
|
union macctrl *mc = findbyctrl(mcs, ctrl);
|
||||||
Str255 title;
|
|
||||||
|
|
||||||
assert(mc != NULL);
|
assert(mc != NULL);
|
||||||
if (mac_gestalts.apprvers >= 0x100)
|
if (mac_gestalts.apprvers >= 0x100)
|
||||||
SetControlData(mc->text.tbctrl, kControlEntireControl,
|
SetControlData(mc->text.tbctrl, kControlEntireControl,
|
||||||
kControlStaticTextTextTag, strlen(text), text);
|
kControlStaticTextTextTag, strlen(text), text);
|
||||||
else {
|
#if !TARGET_API_MAC_CARBON
|
||||||
c2pstrcpy(title, text);
|
else
|
||||||
SetControlTitle(mc->text.tbctrl, title);
|
TESetText(text, strlen(text),
|
||||||
}
|
(TEHandle)(*mc->text.tbctrl)->contrlData);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: macresid.h,v 1.13 2003/03/29 18:31:09 ben Exp $ */
|
/* $Id: macresid.h,v 1.14 2003/03/29 22:04:21 ben Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* macresid.h -- Mac resource IDs
|
* macresid.h -- Mac resource IDs
|
||||||
|
@ -60,9 +60,10 @@
|
||||||
#define cVScroll 128
|
#define cVScroll 128
|
||||||
|
|
||||||
/* xDEFs */
|
/* xDEFs */
|
||||||
#define CDEF_Text 128
|
|
||||||
#define SYS7_TEXT_PROC (CDEF_Text << 4)
|
|
||||||
#define CDEF_EditBox 129
|
#define CDEF_EditBox 129
|
||||||
#define SYS7_EDITBOX_PROC (CDEF_EditBox << 4)
|
#define SYS7_EDITBOX_VARIANT 0
|
||||||
|
#define SYS7_TEXT_VARIANT 1
|
||||||
|
#define SYS7_EDITBOX_PROC ((CDEF_EditBox << 4) + SYS7_EDITBOX_VARIANT)
|
||||||
|
#define SYS7_TEXT_PROC ((CDEF_EditBox << 4) + SYS7_TEXT_VARIANT)
|
||||||
#define CDEF_Default 130
|
#define CDEF_Default 130
|
||||||
#define SYS7_DEFAULT_PROC (CDEF_Default << 4)
|
#define SYS7_DEFAULT_PROC (CDEF_Default << 4)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче