| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
#ifndef THINK_C |
| 53 |
#include <ToolUtils.h> |
| 54 |
#endif |
| 55 |
#include <Balloons.h> |
| 56 |
#include "macnapp.h" |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
void NAmodalMenus(int begin) |
| 61 |
{ |
| 62 |
short i, end; |
| 63 |
MenuHandle mh; |
| 64 |
|
| 65 |
|
| 66 |
HiliteMenu(0); |
| 67 |
|
| 68 |
|
| 69 |
for (i = mFile; (mh = NAmenuh(i)); ++i) { |
| 70 |
if (i != mEdit) { |
| 71 |
if (begin) DisableItem(mh, 0); |
| 72 |
else EnableItem(mh, 0); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
mh = NAmenuh(mApple); |
| 78 |
i = NAappleitems; |
| 79 |
if (NAhelpcount) { |
| 80 |
HMGetHelpMenuHandle(&mh); |
| 81 |
i = NAhelpcount + 1; |
| 82 |
} |
| 83 |
for (end = NAhelpitems + i; i <= end; ++i) { |
| 84 |
if (begin) DisableItem(mh, i); |
| 85 |
else EnableItem(mh, i); |
| 86 |
} |
| 87 |
|
| 88 |
DrawMenuBar(); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
void NAenableDItem(DialogPtr dialog, short item, Boolean on) |
| 94 |
{ |
| 95 |
short type; |
| 96 |
Handle ctrl; |
| 97 |
short ty; |
| 98 |
Rect box; |
| 99 |
|
| 100 |
GetDItem(dialog, item, &ty, &ctrl, &box); |
| 101 |
type = ty; |
| 102 |
if (on) type &= ~itemDisable; |
| 103 |
else type |= itemDisable; |
| 104 |
if (type == (editText | itemDisable)) { |
| 105 |
type = statText; |
| 106 |
} else if (type == statText) { |
| 107 |
type = editText; |
| 108 |
} |
| 109 |
SetDItem(dialog, item, type, ctrl, &box); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
void NAhiliteDItem(DialogPtr dialog, short item, short how) |
| 115 |
{ |
| 116 |
Handle ctrl; |
| 117 |
short type; |
| 118 |
Rect box; |
| 119 |
PenState tmpPen; |
| 120 |
|
| 121 |
GetDItem(dialog, item, &type, &ctrl, &box); |
| 122 |
if (type & ctrlItem) { |
| 123 |
HiliteControl((ControlHandle) ctrl, how); |
| 124 |
} else if (type & (statText | editText)) { |
| 125 |
GetPenState(&tmpPen); |
| 126 |
PenNormal(); |
| 127 |
if (how == 255) PenPat(QD(gray)); |
| 128 |
InsetRect(&box, -3, -3); |
| 129 |
FrameRect(&box); |
| 130 |
SetPenState(&tmpPen); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
void NAvisibleDItem(DialogPtr dialog, short item, Boolean show) |
| 137 |
{ |
| 138 |
if (show) ShowDItem(dialog, item); |
| 139 |
else HideDItem(dialog, item); |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
void NAsetIText(DialogPtr dialog, short item, PCstr *str) |
| 145 |
{ |
| 146 |
Handle texth; |
| 147 |
|
| 148 |
NAgetDHandle(dialog, item, &texth); |
| 149 |
SetIText(texth, str); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
void NAgetIText(DialogPtr dialog, short item, PCstr *str) |
| 155 |
{ |
| 156 |
Handle texth; |
| 157 |
|
| 158 |
NAgetDHandle(dialog, item, &texth); |
| 159 |
GetIText(texth, str); |
| 160 |
SetClen(str); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
short NAradioSet(DialogPtr dialog, short firstitem, short lastitem, short setting) |
| 166 |
{ |
| 167 |
short item; |
| 168 |
ControlHandle ctrl; |
| 169 |
|
| 170 |
for (item = firstitem; item <= lastitem; item++) { |
| 171 |
NAgetDHandle(dialog, item, &ctrl); |
| 172 |
SetCtlValue(ctrl, item == setting ? 1 : 0); |
| 173 |
} |
| 174 |
|
| 175 |
return (setting - firstitem); |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
short NAradioGet(DialogPtr dialog, short firstitem, short lastitem) |
| 181 |
{ |
| 182 |
short item; |
| 183 |
ControlHandle ctrl; |
| 184 |
|
| 185 |
for (item = firstitem; item <= lastitem; item++) { |
| 186 |
NAgetDHandle(dialog, item, &ctrl); |
| 187 |
if (GetCtlValue(ctrl)) return (item); |
| 188 |
} |
| 189 |
|
| 190 |
return (firstitem); |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
short NAdialogMenu(na_win *win, WORD menu, WORD item) |
| 196 |
{ |
| 197 |
MenuHandle mh = NAmenuh(mEdit); |
| 198 |
DialogPeek dpeek = (DialogPeek) win->pwin; |
| 199 |
short result = NA_NOTPROCESSED; |
| 200 |
|
| 201 |
switch (menu) { |
| 202 |
case 0: |
| 203 |
if ((*dpeek->textH)->selStart != (*dpeek->textH)->selEnd) { |
| 204 |
EnableItem(mh, iCopy); |
| 205 |
EnableItem(mh, iCut); |
| 206 |
EnableItem(mh, iClear); |
| 207 |
} |
| 208 |
EnableItem(mh, iPaste); |
| 209 |
if ((*dpeek->textH)->teLength > 0) EnableItem(mh, iSelAll); |
| 210 |
break; |
| 211 |
case mEdit: |
| 212 |
switch (item) { |
| 213 |
case iCut: |
| 214 |
DlgCut(win->pwin); |
| 215 |
ZeroScrap(); |
| 216 |
TEToScrap(); |
| 217 |
break; |
| 218 |
case iCopy: |
| 219 |
DlgCopy(win->pwin); |
| 220 |
ZeroScrap(); |
| 221 |
TEToScrap(); |
| 222 |
break; |
| 223 |
case iClear: |
| 224 |
DlgDelete(win->pwin); |
| 225 |
break; |
| 226 |
case iPaste: |
| 227 |
DlgPaste(win->pwin); |
| 228 |
break; |
| 229 |
case iSelAll: |
| 230 |
SelIText(win->pwin, dpeek->editField + 1, 0, 32767); |
| 231 |
break; |
| 232 |
} |
| 233 |
result = NA_PROCESSED; |
| 234 |
break; |
| 235 |
} |
| 236 |
if (menu != 0) DisableItem(mh, iSelAll); |
| 237 |
|
| 238 |
return (result); |
| 239 |
} |