File indexing completed on 2018-03-02 18:44:53 UTC
view on githubraw file Latest commit ec6cf3b0 on 2003-08-26 20:45:25 UTC
ec6cf3b09d Ed H*0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 #ifndef THINK_C
0053 #include <ToolUtils.h>
0054 #endif
0055 #include <Balloons.h>
0056 #include "macnapp.h"
0057
0058
0059
0060 void NAmodalMenus(int begin)
0061 {
0062 short i, end;
0063 MenuHandle mh;
0064
0065
0066 HiliteMenu(0);
0067
0068
0069 for (i = mFile; (mh = NAmenuh(i)); ++i) {
0070 if (i != mEdit) {
0071 if (begin) DisableItem(mh, 0);
0072 else EnableItem(mh, 0);
0073 }
0074 }
0075
0076
0077 mh = NAmenuh(mApple);
0078 i = NAappleitems;
0079 if (NAhelpcount) {
0080 HMGetHelpMenuHandle(&mh);
0081 i = NAhelpcount + 1;
0082 }
0083 for (end = NAhelpitems + i; i <= end; ++i) {
0084 if (begin) DisableItem(mh, i);
0085 else EnableItem(mh, i);
0086 }
0087
0088 DrawMenuBar();
0089 }
0090
0091
0092
0093 void NAenableDItem(DialogPtr dialog, short item, Boolean on)
0094 {
0095 short type;
0096 Handle ctrl;
0097 short ty;
0098 Rect box;
0099
0100 GetDItem(dialog, item, &ty, &ctrl, &box);
0101 type = ty;
0102 if (on) type &= ~itemDisable;
0103 else type |= itemDisable;
0104 if (type == (editText | itemDisable)) {
0105 type = statText;
0106 } else if (type == statText) {
0107 type = editText;
0108 }
0109 SetDItem(dialog, item, type, ctrl, &box);
0110 }
0111
0112
0113
0114 void NAhiliteDItem(DialogPtr dialog, short item, short how)
0115 {
0116 Handle ctrl;
0117 short type;
0118 Rect box;
0119 PenState tmpPen;
0120
0121 GetDItem(dialog, item, &type, &ctrl, &box);
0122 if (type & ctrlItem) {
0123 HiliteControl((ControlHandle) ctrl, how);
0124 } else if (type & (statText | editText)) {
0125 GetPenState(&tmpPen);
0126 PenNormal();
0127 if (how == 255) PenPat(QD(gray));
0128 InsetRect(&box, -3, -3);
0129 FrameRect(&box);
0130 SetPenState(&tmpPen);
0131 }
0132 }
0133
0134
0135
0136 void NAvisibleDItem(DialogPtr dialog, short item, Boolean show)
0137 {
0138 if (show) ShowDItem(dialog, item);
0139 else HideDItem(dialog, item);
0140 }
0141
0142
0143
0144 void NAsetIText(DialogPtr dialog, short item, PCstr *str)
0145 {
0146 Handle texth;
0147
0148 NAgetDHandle(dialog, item, &texth);
0149 SetIText(texth, str);
0150 }
0151
0152
0153
0154 void NAgetIText(DialogPtr dialog, short item, PCstr *str)
0155 {
0156 Handle texth;
0157
0158 NAgetDHandle(dialog, item, &texth);
0159 GetIText(texth, str);
0160 SetClen(str);
0161 }
0162
0163
0164
0165 short NAradioSet(DialogPtr dialog, short firstitem, short lastitem, short setting)
0166 {
0167 short item;
0168 ControlHandle ctrl;
0169
0170 for (item = firstitem; item <= lastitem; item++) {
0171 NAgetDHandle(dialog, item, &ctrl);
0172 SetCtlValue(ctrl, item == setting ? 1 : 0);
0173 }
0174
0175 return (setting - firstitem);
0176 }
0177
0178
0179
0180 short NAradioGet(DialogPtr dialog, short firstitem, short lastitem)
0181 {
0182 short item;
0183 ControlHandle ctrl;
0184
0185 for (item = firstitem; item <= lastitem; item++) {
0186 NAgetDHandle(dialog, item, &ctrl);
0187 if (GetCtlValue(ctrl)) return (item);
0188 }
0189
0190 return (firstitem);
0191 }
0192
0193
0194
0195 short NAdialogMenu(na_win *win, WORD menu, WORD item)
0196 {
0197 MenuHandle mh = NAmenuh(mEdit);
0198 DialogPeek dpeek = (DialogPeek) win->pwin;
0199 short result = NA_NOTPROCESSED;
0200
0201 switch (menu) {
0202 case 0:
0203 if ((*dpeek->textH)->selStart != (*dpeek->textH)->selEnd) {
0204 EnableItem(mh, iCopy);
0205 EnableItem(mh, iCut);
0206 EnableItem(mh, iClear);
0207 }
0208 EnableItem(mh, iPaste);
0209 if ((*dpeek->textH)->teLength > 0) EnableItem(mh, iSelAll);
0210 break;
0211 case mEdit:
0212 switch (item) {
0213 case iCut:
0214 DlgCut(win->pwin);
0215 ZeroScrap();
0216 TEToScrap();
0217 break;
0218 case iCopy:
0219 DlgCopy(win->pwin);
0220 ZeroScrap();
0221 TEToScrap();
0222 break;
0223 case iClear:
0224 DlgDelete(win->pwin);
0225 break;
0226 case iPaste:
0227 DlgPaste(win->pwin);
0228 break;
0229 case iSelAll:
0230 SelIText(win->pwin, dpeek->editField + 1, 0, 32767);
0231 break;
0232 }
0233 result = NA_PROCESSED;
0234 break;
0235 }
0236 if (menu != 0) DisableItem(mh, iSelAll);
0237
0238 return (result);
0239 }