962 !DialogBox class methodsFor:'common dialogs'! |
962 !DialogBox class methodsFor:'common dialogs'! |
963 |
963 |
964 information:aString |
964 information:aString |
965 "launch a Dialog to tell user something" |
965 "launch a Dialog to tell user something" |
966 |
966 |
967 (InfoBox title:aString) showAtPointer |
967 (InfoBox title:aString) showAtPointer; destroy |
968 |
968 |
969 " |
969 " |
970 Dialog information:'help' |
970 Dialog information:'help' |
971 " |
971 " |
|
972 |
|
973 "Modified: 29.5.1996 / 15:23:03 / cg" |
972 ! |
974 ! |
973 |
975 |
974 warn:aString |
976 warn:aString |
975 "launch a Dialog to warn user" |
977 "launch a Dialog to warn user" |
976 |
978 |
977 (WarningBox title:aString) showAtPointer |
979 (WarningBox title:aString) showAtPointer; destroy |
978 |
980 |
979 " |
981 " |
980 Dialog warn:'some warning message' |
982 Dialog warn:'some warning message' |
981 |
983 |
982 Dialog warn:('some text with italic emphasis' asText |
984 Dialog warn:('some text with italic emphasis' asText |
988 Dialog warn:('some text with color emphasis' asText |
990 Dialog warn:('some text with color emphasis' asText |
989 emphasizeFrom:6 to:10 with:(#color->Color blue); |
991 emphasizeFrom:6 to:10 with:(#color->Color blue); |
990 emphasizeFrom:16 to:20 with:(#color->Color red)) |
992 emphasizeFrom:16 to:20 with:(#color->Color red)) |
991 " |
993 " |
992 |
994 |
993 "Modified: 12.5.1996 / 16:11:48 / cg" |
995 "Modified: 29.5.1996 / 15:23:14 / cg" |
994 ! ! |
996 ! ! |
995 |
997 |
996 !DialogBox class methodsFor:'confirmation dialogs'! |
998 !DialogBox class methodsFor:'confirmation dialogs'! |
997 |
999 |
998 confirm:aString |
1000 confirm:aString |
1034 |box answer| |
1036 |box answer| |
1035 |
1037 |
1036 box := YesNoBox title:aString. |
1038 box := YesNoBox title:aString. |
1037 box yesAction:[answer := true] noAction:[answer := false]. |
1039 box yesAction:[answer := true] noAction:[answer := false]. |
1038 what == false ifTrue:[ |
1040 what == false ifTrue:[ |
1039 box okButton isReturnButton:false. |
1041 box okButton isReturnButton:false. |
1040 box acceptReturnAsOK:false. |
1042 box acceptReturnAsOK:false. |
1041 box noButton beReturnButton. |
1043 box noButton beReturnButton. |
1042 ]. |
1044 ]. |
1043 box showAtPointer. |
1045 box showAtPointer. |
1044 box yesAction:nil noAction:nil. |
1046 box yesAction:nil noAction:nil. |
|
1047 box destroy. |
1045 ^ answer |
1048 ^ answer |
1046 |
1049 |
1047 " |
1050 " |
1048 Dialog confirm:'really ?' initialAnswer:false |
1051 Dialog confirm:'really ?' initialAnswer:false |
1049 |
1052 |
1050 Transcript showCR:( |
1053 Transcript showCR:( |
1051 Dialog confirm:'are you certain ?' initialAnswer:false |
1054 Dialog confirm:'are you certain ?' initialAnswer:false |
1052 ) |
1055 ) |
1053 |
1056 |
1054 Transcript showCR:( |
1057 Transcript showCR:( |
1055 Dialog confirm:'are you certain ?' initialAnswer:true |
1058 Dialog confirm:'are you certain ?' initialAnswer:true |
1056 ) |
1059 ) |
1057 " |
1060 " |
1058 |
1061 |
1059 "Modified: 27.1.1996 / 14:24:39 / cg" |
1062 "Modified: 29.5.1996 / 15:23:42 / cg" |
1060 ! |
1063 ! |
1061 |
1064 |
1062 confirm:aString title:title yesLabel:yesText noLabel:noText |
1065 confirm:aString title:title yesLabel:yesText noLabel:noText |
1063 "launch a Dialog, which allows user to enter yes or no. |
1066 "launch a Dialog, which allows user to enter yes or no. |
1064 return true for yes, false for no. |
1067 return true for yes, false for no. |
1088 yesLabel:'oh well' |
1092 yesLabel:'oh well' |
1089 noLabel:'nope' |
1093 noLabel:'nope' |
1090 " |
1094 " |
1091 |
1095 |
1092 "Created: 21.2.1996 / 01:10:14 / cg" |
1096 "Created: 21.2.1996 / 01:10:14 / cg" |
1093 "Modified: 8.3.1996 / 21:15:56 / cg" |
1097 "Modified: 29.5.1996 / 15:23:59 / cg" |
1094 ! |
1098 ! |
1095 |
1099 |
1096 confirm:aString yesLabel:yesText noLabel:noText |
1100 confirm:aString yesLabel:yesText noLabel:noText |
1097 "launch a Dialog, which allows user to enter yes or no. |
1101 "launch a Dialog, which allows user to enter yes or no. |
1098 return true for yes, false for no. |
1102 return true for yes, false for no. |
1114 |
1118 |
1115 |box answer| |
1119 |box answer| |
1116 |
1120 |
1117 box := OptionBox title:aString numberOfOptions:3. |
1121 box := OptionBox title:aString numberOfOptions:3. |
1118 box buttonTitles:(self classResources array: |
1122 box buttonTitles:(self classResources array: |
1119 #('cancel' |
1123 #('cancel' |
1120 'no' |
1124 'no' |
1121 'yes') |
1125 'yes') |
1122 ) |
1126 ) |
1123 actions:(Array with:[answer := nil] |
1127 actions:(Array with:[answer := nil] |
1124 with:[answer := false] |
1128 with:[answer := false] |
1125 with:[answer := true] |
1129 with:[answer := true] |
1126 ). |
1130 ). |
1127 box showAtPointer. |
1131 box showAtPointer. |
1128 box actions:nil. |
1132 box actions:nil. |
|
1133 box destroy. |
1129 ^ answer |
1134 ^ answer |
1130 |
1135 |
1131 " |
1136 " |
1132 Dialog confirmWithCancel:'really ?' |
1137 Dialog confirmWithCancel:'really ?' |
1133 |
1138 |
1134 Transcript showCR:( |
1139 Transcript showCR:( |
1135 Dialog confirmWithCancel:'really ?' |
1140 Dialog confirmWithCancel:'really ?' |
1136 ) |
1141 ) |
1137 " |
1142 " |
1138 |
1143 |
1139 "Modified: 27.1.1996 / 14:25:49 / cg" |
1144 "Modified: 29.5.1996 / 15:24:06 / cg" |
1140 ! ! |
1145 ! ! |
1141 |
1146 |
1142 !DialogBox class methodsFor:'defaults'! |
1147 !DialogBox class methodsFor:'defaults'! |
1143 |
1148 |
1144 defaultLabel |
1149 defaultLabel |
1207 |
1212 |
1208 fileBox := FileSelectionBox |
1213 fileBox := FileSelectionBox |
1209 title:title |
1214 title:title |
1210 okText:'ok' |
1215 okText:'ok' |
1211 abortText:'cancel' |
1216 abortText:'cancel' |
1212 action:[:fileName | ^ fileName]. |
1217 action:[:fileName | fileBox destroy. ^ fileName]. |
1213 |
1218 |
1214 fileBox initialText:aFileName. |
1219 fileBox initialText:aFileName. |
1215 fileBox selectingDirectory:true. |
1220 fileBox selectingDirectory:true. |
1216 fileBox showAtPointer. |
1221 fileBox showAtPointer. |
|
1222 fileBox destroy. |
1217 ^ failBlock value |
1223 ^ failBlock value |
1218 |
1224 |
1219 " |
1225 " |
1220 Dialog |
1226 Dialog |
1221 requestDirectoryName:'which directory ?' |
1227 requestDirectoryName:'which directory ?' |
1222 default:'/etc' |
1228 default:'/etc' |
1223 ifFail:'none' |
1229 ifFail:'none' |
1224 " |
1230 " |
1225 |
1231 |
1226 "Created: 19.4.1996 / 14:31:04 / cg" |
1232 "Created: 19.4.1996 / 14:31:04 / cg" |
1227 "Modified: 19.4.1996 / 14:31:26 / cg" |
1233 "Modified: 29.5.1996 / 15:24:30 / cg" |
1228 ! |
1234 ! |
1229 |
1235 |
1230 requestFileName |
1236 requestFileName |
1231 "launch a Dialog, which allows the user to enter a filename. |
1237 "launch a Dialog, which allows the user to enter a filename. |
1232 Return the pathname string consisting of the full pathname of the filename, |
1238 Return the pathname string consisting of the full pathname of the filename, |
1335 "launch a Dialog, which allows user to enter a filename. |
1341 "launch a Dialog, which allows user to enter a filename. |
1336 The files presented initially are those in aDirectoryPath, or the |
1342 The files presented initially are those in aDirectoryPath, or the |
1337 current directory (if a nil path is given). |
1343 current directory (if a nil path is given). |
1338 The box will show okText in its okButton, abortText in the abortButton. |
1344 The box will show okText in its okButton, abortText in the abortButton. |
1339 The matchPattern is set to pattern initially. |
1345 The matchPattern is set to pattern initially. |
1340 Return the string or nil if cancel was pressed." |
1346 Return the string, or nil if cancel was pressed." |
1341 |
1347 |
1342 |box| |
1348 |box| |
1343 |
1349 |
1344 box := FileSelectionBox |
1350 box := FileSelectionBox |
1345 title:titleString |
1351 title:titleString |
1346 okText:okText |
1352 okText:okText |
1347 abortText:abortText |
1353 abortText:abortText |
1348 action:[:fileName | ^fileName]. |
1354 action:[:fileName | box destroy. ^ fileName]. |
1349 |
1355 |
1350 aDirectoryPath notNil ifTrue:[box directory:aDirectoryPath]. |
1356 aDirectoryPath notNil ifTrue:[box directory:aDirectoryPath]. |
1351 box pattern:pattern. |
1357 box pattern:pattern. |
1352 box initialText:defaultName. |
1358 box initialText:defaultName. |
1353 box showAtPointer. |
1359 box showAtPointer. |
1354 box action:nil. |
1360 box action:nil. |
|
1361 box destroy. |
1355 ^ nil |
1362 ^ nil |
1356 |
1363 |
1357 " |
1364 " |
1358 Dialog |
1365 Dialog |
1359 requestFileName:'enter a fileName:' |
1366 requestFileName:'enter a fileName:' |
1360 default:'' |
1367 default:'' |
1361 ok:'yeah' |
1368 ok:'yeah' |
1362 abort:'oh, no' |
1369 abort:'oh, no' |
1363 pattern:'rc*' |
1370 pattern:'rc*' |
1364 fromDirectory:'/etc' |
1371 fromDirectory:'/etc' |
1365 " |
1372 " |
1366 |
1373 |
1367 "Modified: 19.4.1996 / 14:07:32 / cg" |
1374 "Modified: 29.5.1996 / 15:25:40 / cg" |
1368 ! |
1375 ! |
1369 |
1376 |
1370 requestFileName:titleString default:defaultName version:versionSymbol |
1377 requestFileName:titleString default:defaultName version:versionSymbol |
1371 "launch a Dialog, which allows user to enter a filename. |
1378 "launch a Dialog, which allows user to enter a filename. |
1372 The box will not allow pressing 'ok' without an entered string. |
1379 The box will not allow pressing 'ok' without an entered string. |
1510 version:#mustBeNew |
1518 version:#mustBeNew |
1511 ifFail:['none'] |
1519 ifFail:['none'] |
1512 fromDirectory:'/etc' |
1520 fromDirectory:'/etc' |
1513 " |
1521 " |
1514 |
1522 |
1515 "Modified: 19.4.1996 / 14:25:15 / cg" |
1523 "Modified: 29.5.1996 / 15:25:57 / cg" |
1516 ! |
1524 ! |
1517 |
1525 |
1518 requestFileName:titleString ifFail:cancelBlock |
1526 requestFileName:titleString ifFail:cancelBlock |
1519 "launch a Dialog, which allows user to enter a filename. |
1527 "launch a Dialog, which allows user to enter a filename. |
1520 Return the pathname string consisting of the full pathname of the filename, |
1528 Return the pathname string consisting of the full pathname of the filename, |
1734 |
1742 |
1735 |box| |
1743 |box| |
1736 |
1744 |
1737 box := EnterBox title:aString. |
1745 box := EnterBox title:aString. |
1738 box initialText:initial. |
1746 box initialText:initial. |
1739 box abortAction:[:val | ^ cancelValue value]. |
1747 box abortAction:[:val | box destroy. ^ cancelValue value]. |
1740 okLabel notNil ifTrue:[ |
1748 okLabel notNil ifTrue:[ |
1741 box okText:okLabel. |
1749 box okText:okLabel. |
1742 ]. |
1750 ]. |
1743 cancelLabel notNil ifTrue:[ |
1751 cancelLabel notNil ifTrue:[ |
1744 box abortText:cancelLabel |
1752 box abortText:cancelLabel |
1745 ]. |
1753 ]. |
1746 resultAction isNil ifTrue:[ |
1754 resultAction isNil ifTrue:[ |
1747 box action:[:val | ^ val] |
1755 box action:[:val | box destroy. ^ val] |
1748 ] ifFalse:[ |
1756 ] ifFalse:[ |
1749 box action:[:val | ^ resultAction value:val] |
1757 box action:[:val | box destroy. ^ resultAction value:val] |
1750 ]. |
1758 ]. |
1751 titleString notNil ifTrue:[ |
1759 titleString notNil ifTrue:[ |
1752 box label:titleString |
1760 box label:titleString |
1753 ]. |
1761 ]. |
1754 |
1762 |
1803 title:'foo' |
1812 title:'foo' |
1804 onCancel:#foo |
1813 onCancel:#foo |
1805 " |
1814 " |
1806 |
1815 |
1807 "Created: 29.5.1996 / 14:35:04 / cg" |
1816 "Created: 29.5.1996 / 14:35:04 / cg" |
1808 "Modified: 29.5.1996 / 14:37:13 / cg" |
1817 "Modified: 29.5.1996 / 15:26:34 / cg" |
1809 ! |
1818 ! |
1810 |
1819 |
1811 request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial onCancel:cancelValue |
1820 request:aString displayAt:aPoint centered:centered action:resultAction initialAnswer:initial onCancel:cancelValue |
1812 "launch a Dialog, which allows user to enter a string. |
1821 "launch a Dialog, which allows user to enter a string. |
1813 If aPoint is nonNil, the box is shown there, optionally centered. |
1822 If aPoint is nonNil, the box is shown there, optionally centered. |
2140 |
2149 |
2141 listView notNil ifTrue:[box stickAtBottomWithVariableHeight:listView]. |
2150 listView notNil ifTrue:[box stickAtBottomWithVariableHeight:listView]. |
2142 panel notNil ifTrue:[box stickAtBottomWithFixHeight:panel]. |
2151 panel notNil ifTrue:[box stickAtBottomWithFixHeight:panel]. |
2143 |
2152 |
2144 box showAtPointer. |
2153 box showAtPointer. |
|
2154 box destroy. |
2145 box accepted ifTrue:[ |
2155 box accepted ifTrue:[ |
2146 (answer := listView selection) notNil ifTrue:[ |
2156 (answer := listView selection) notNil ifTrue:[ |
2147 ^ listValues at:answer |
2157 ^ listValues at:answer |
2148 ] |
2158 ] |
2149 ]. |
2159 ]. |
2274 |
2284 |
2275 |box answer idx| |
2285 |box answer idx| |
2276 |
2286 |
2277 box := OptionBox title:aString numberOfOptions:buttonLabels size. |
2287 box := OptionBox title:aString numberOfOptions:buttonLabels size. |
2278 box buttonTitles:(self classResources array:buttonLabels) |
2288 box buttonTitles:(self classResources array:buttonLabels) |
2279 actions:(values collect:[:val | [answer := val]]). |
2289 actions:(values collect:[:val | [answer := val]]). |
2280 answer := default. |
2290 answer := default. |
2281 box buttons last isReturnButton:false. |
2291 box buttons last isReturnButton:false. |
2282 idx := values indexOf:default. |
2292 idx := values indexOf:default. |
2283 idx ~~ 0 ifTrue:[box defaultButtonIndex:idx]. |
2293 idx ~~ 0 ifTrue:[box defaultButtonIndex:idx]. |
2284 box showAtPointer. |
2294 box showAtPointer. |
|
2295 box destroy. |
2285 box actions:nil. |
2296 box actions:nil. |
2286 ^ answer |
2297 ^ answer |
2287 |
2298 |
2288 "no good style (default button is not the rightmost one) |
2299 "no good style (default button is not the rightmost one) |
2289 |
2300 |
2290 Dialog |
2301 Dialog |
2291 choose:'choose any' |
2302 choose:'choose any' |
2292 labels:#('one' 'two' 'three' 'four') |
2303 labels:#('one' 'two' 'three' 'four') |
2293 values:#(1 2 3 4) |
2304 values:#(1 2 3 4) |
2294 default:2 |
2305 default:2 |
2295 |
2306 |
2296 Dialog |
2307 Dialog |
2297 choose:'choose any' |
2308 choose:'choose any' |
2298 labels:#('cancel' 'foo' 'bar' 'baz') |
2309 labels:#('cancel' 'foo' 'bar' 'baz') |
2299 values:#(nil foo bar baz) |
2310 values:#(nil foo bar baz) |
2300 default:#baz |
2311 default:#baz |
2301 |
2312 |
2302 Dialog |
2313 Dialog |
2303 choose:'choose any' |
2314 choose:'choose any' |
2304 labels:#('one' 'two' 'three' 'four') |
2315 labels:#('one' 'two' 'three' 'four') |
2305 values:#(1 2 3 4) |
2316 values:#(1 2 3 4) |
2306 default:nil |
2317 default:nil |
2307 " |
2318 " |
2308 |
2319 |
2309 "Modified: 27.1.1996 / 13:48:17 / cg" |
2320 "Modified: 29.5.1996 / 15:27:32 / cg" |
2310 ! ! |
2321 ! ! |
2311 |
2322 |
2312 !DialogBox methodsFor:'accessing'! |
2323 !DialogBox methodsFor:'accessing'! |
2313 |
2324 |
2314 abortText:aString |
2325 abortText:aString |