901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
|
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
|
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
return false
}
return true
}
#
# NOTE: This procedure is the command handler for the submit button. It is
# used to start the package submission process. The args argument is
# not used, it is a placeholder to make this procedure a more portable
# between Tcl and Eagle. This procedure may raise script errors.
# NOTE: This procedure is an event handler. It handles the Changed event
# for a text box. It is not used when the user interface was built
# with Tk. The varName argument is the name of the scalar variable
# that must be updated with the contents of the text box. The sender
# and e arguments are provided by the framework and represent the
# control involved in the event and any extra data that may be
# necessary to process the event.
#
proc textBoxEventHandler { varName sender e } {
set $varName [$sender Text]
}
#
# NOTE: This procedure is an event handler. It handles double-clicking the
# list box in both Tk and Eagle. The varName argument is the name of
# the scalar variable that must be updated with the list of items from
# the list box -OR- the list of items from an interactive file picker
# dialog. The args argument, which is only used for Eagle, is a list
# containing two elements. The first element is the control involved
# in the event. The second element is any extra data that may be
# necessary to process the event.
#
proc listBoxEventHandler { varName args } {
if {[isEagle]} then {
set sender [lindex $args 0]
set e [lindex $args 1]
set dialog [object create -alias OpenFileDialog]
$dialog RestoreDirectory true
$dialog Multiselect true
$dialog ShowDialog
set fileNames [$dialog -create FileNames]
$sender Items.Clear
$sender Items.AddRange $fileNames
set list [object create -alias StringList $fileNames]
set $varName [$list ToString]
} else {
set $varName [tk_getOpenFile -multiple true]
}
}
#
# NOTE: This procedure is an event handler. It handles the Closed event for
# a WinForms form. It is not used when the user interface was built
# with Tk. The sender and e arguments are provided by the framework
# and represent the control involved in the event and any extra data
# that may be necessary to process the event.
#
proc handleFormClosedEvent { sender e } {
variable forever; set forever 1; # NOTE: Terminate the [vwait].
}
#
# NOTE: This procedure is an event handler. It handles the submit button in
# both Tk and Eagle. It starts the package submission process. The
# args argument is not really used, it is a placeholder to make this
# procedure more portable between Tcl and Eagle. This procedure may
# raise script errors.
#
proc submitEventHandler { args } {
variable argumentData
if {[isEagle]} then {
set sender [lindex $args 0]; # NOTE: Disposal.
set e [lindex $args 1]; # NOTE: Disposal.
}
puts stdout "SUBMIT CLICKED"
}
#
# NOTE: This procedure is the command handler for the clear button. It is
# used to clear the package submission data. The args argument is
# not used, it is a placeholder to make this procedure a more portable
# between Tcl and Eagle. This procedure may raise script errors.
# NOTE: This procedure is an event handler. It handles the clear button in
# Tk and Eagle. It is used to clear the package submission data. The
# args argument is not really used, it is a placeholder to make this
# procedure more portable between Tcl and Eagle. This procedure may
# raise script errors.
#
proc clearEventHandler { args } {
variable argumentData
if {[isEagle]} then {
set sender [lindex $args 0]; # NOTE: Disposal.
set e [lindex $args 1]; # NOTE: Disposal.
puts stdout "CLEAR CLICKED"
variable widgets
$widgets(2) Text ""
$widgets(4) Text ""
$widgets(6) Text ""
$widgets(8) Text ""
$widgets(10) Text ""
$widgets(12) Text ""
$widgets(14) Items.Clear
} else {
set argumentData(apiKey) ""
set argumentData(package) ""
set argumentData(patchLevel) ""
set argumentData(language) ""
set argumentData(version) ""
set argumentData(platform) ""
set argumentData(apiKey) ""
set argumentData(package) ""
set argumentData(patchLevel) ""
set argumentData(language) ""
set argumentData(version) ""
set argumentData(platform) ""
}
#
# NOTE: This is done for Tk because it will also clear the on-screen
# widget itself. For Eagle, this is necessary because there is
# no "listvariable" option and clearing the on-screen widget has
# no impact on the underyling list.
#
set argumentData(fileNames) [list]
}
#
# NOTE: This procedure creates the user interface for this tool using
# Eagle and WinForms. Existing argument data, if any, will be
# used to populate it. There are no arguments.
# NOTE: This procedure creates the user interface for this tool using Eagle
# and WinForms. The existing argument data, if any, will be used to
# populate it. There are no arguments.
#
proc setupWinFormsUserInterface {} {
variable argumentData
variable widgets
object load System.Windows.Forms
object load -import System.Windows.Forms
set form [object create -alias Form]
set widgets(0) $form
#
# TODO: Finish this.
#
###########################################################################
set widgets(1) [object create -alias Label]
$widgets(1) Name lblApiKey
$widgets(1) Text "API Key"
###########################################################################
set widgets(2) [object create -alias TextBox]
$widgets(2) Name txtApiKey
$widgets(2) Text $argumentData(apiKey)
$widgets(2) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(apiKey)]]]
###########################################################################
set widgets(3) [object create -alias Label]
$widgets(3) Name lblPackage
$widgets(3) Text "Package Name"
###########################################################################
set widgets(4) [object create -alias TextBox]
$widgets(4) Name txtPackage
$widgets(4) Text $argumentData(package)
$widgets(4) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(package)]]]
###########################################################################
set widgets(5) [object create -alias Label]
$widgets(5) Name lblPatchLevel
$widgets(5) Text "Package Patch Level"
###########################################################################
set widgets(6) [object create -alias TextBox]
$widgets(6) Name txtPatchLevel
$widgets(6) Text $argumentData(patchLevel)
$widgets(6) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(patchLevel)]]]
###########################################################################
set widgets(7) [object create -alias Label]
$widgets(7) Name lblLanguage
$widgets(7) Text Language
###########################################################################
set widgets(8) [object create -alias TextBox]
$widgets(8) Name txtLanguage
$widgets(8) Text $argumentData(language)
$widgets(8) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(language)]]]
###########################################################################
set widgets(9) [object create -alias Label]
$widgets(9) Name lblVersion
$widgets(9) Text Version
###########################################################################
set widgets(10) [object create -alias TextBox]
$widgets(10) Name txtVersion
$widgets(10) Text $argumentData(version)
$widgets(10) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(version)]]]
###########################################################################
set widgets(11) [object create -alias Label]
$widgets(11) Name lblPlatform
$widgets(11) Text Platform
###########################################################################
set widgets(12) [object create -alias TextBox]
$widgets(12) Name txtPlatform
$widgets(12) Text $argumentData(platform)
$widgets(12) add_TextChanged [namespace code \
[list textBoxEventHandler [appendArgs [namespace current] \
::argumentData(platform)]]]
###########################################################################
set widgets(13) [object create -alias Label]
$widgets(13) Name lblFileNames
$widgets(13) Text Files
###########################################################################
set widgets(14) [object create -alias ListBox]
$widgets(14) Name lstFileNames
$widgets(14) add_DoubleClick [namespace code \
[list listBoxEventHandler [appendArgs [namespace current] \
::argumentData(fileNames)]]]
###########################################################################
set widgets(15) [object create -alias Button]
$widgets(15) Name btnSubmit
$widgets(15) Text Submit
$widgets(15) add_Click [namespace code [list submitEventHandler]]
###########################################################################
set widgets(16) [object create -alias Button]
$widgets(16) Name btnClear
$widgets(16) Text Clear
$widgets(16) add_Click [namespace code [list clearEventHandler]]
###########################################################################
set horizontalMargin \
[expr {([$form Width] - [$form ClientSize.Width]) / 2}]
set verticalMargin \
[expr {([$form Height] - [$form ClientSize.Height]) / 2}]
###########################################################################
set top $verticalMargin
foreach name [lsort -integer [array names widgets]] {
if {$name eq "0"} then continue
$widgets($name) Width [expr {
[$form ClientSize.Width] - ($horizontalMargin * 2)
}]
$widgets($name) Left $horizontalMargin
$widgets($name) Top $top
$form Controls.Add $widgets($name)
incr top [$widgets($name) Height]
incr top $verticalMargin
}
$form add_Closed [namespace code [list handleFormClosedEvent]]
$form MaximizeBox false
$form AutoSize true
$form Show
after 0 [list nop]; # NOTE: Needed for the [vwait].
}
#
# NOTE: This procedure creates the user interface for this tool using Tcl
# and Tk. Existing argument data, if any, will be used to populate
# it. There are no arguments.
# and Tk. The existing argument data, if any, will be used to
# populate it. There are no arguments.
#
proc setupTkUserInterface {} {
variable widgets
package require Tk
catch {wm withdraw .}; set toplevel [toplevel .uploader]
set widgets(toplevel) $toplevel
###########################################################################
set widgets(label,apiKey) [label [appendArgs \
$toplevel .l_apiKey] -text "API Key"]
###########################################################################
set widgets(entry,apiKey) [entry [appendArgs \
$toplevel .e_apiKey] -textvariable [appendArgs \
[namespace current] ::argumentData(apiKey)]]
###########################################################################
set widgets(label,package) [label [appendArgs \
$toplevel .l_package] -text "Package Name"]
###########################################################################
set widgets(entry,package) [entry [appendArgs \
$toplevel .e_package] -textvariable [appendArgs \
[namespace current] ::argumentData(package)]]
###########################################################################
set widgets(label,patchLevel) [label [appendArgs \
$toplevel .l_patchLevel] -text "Package Patch Level"]
###########################################################################
set widgets(entry,patchLevel) [entry [appendArgs \
$toplevel .e_patchLevel] -textvariable [appendArgs \
[namespace current] ::argumentData(patchLevel)]]
###########################################################################
set widgets(label,language) [label [appendArgs \
$toplevel .l_language] -text Language]
###########################################################################
set widgets(entry,language) [entry [appendArgs \
$toplevel .e_language] -textvariable [appendArgs \
[namespace current] ::argumentData(language)]]
###########################################################################
set widgets(label,version) [label [appendArgs \
$toplevel .l_version] -text Version]
###########################################################################
set widgets(entry,version) [entry [appendArgs \
$toplevel .e_version] -textvariable [appendArgs \
[namespace current] ::argumentData(version)]]
###########################################################################
set widgets(label,platform) [label [appendArgs \
$toplevel .l_platform] -text Platform]
###########################################################################
set widgets(entry,platform) [entry [appendArgs \
$toplevel .e_platform] -textvariable [appendArgs \
[namespace current] ::argumentData(platform)]]
###########################################################################
set widgets(label,fileNames) [label [appendArgs \
$toplevel .l_fileNames] -text Files]
###########################################################################
set widgets(listbox,fileNames) [listbox [appendArgs \
$toplevel .li_fileNames] -listvariable [appendArgs \
[namespace current] ::argumentData(fileNames)]]
bind $widgets(listbox,fileNames) <Double-Button-1> \
[namespace code [list listBoxEventHandler [appendArgs \
[namespace current] ::argumentData(fileNames)]]]
###########################################################################
set widgets(button,submit) [button \
[appendArgs $toplevel .b_submit] -text Submit -command \
[namespace code [list submitEventHandler]]]
###########################################################################
set widgets(button,clear) [button \
[appendArgs $toplevel .b_clear] -text Clear -command \
[namespace code [list clearEventHandler]]]
###########################################################################
pack $widgets(label,apiKey) $widgets(entry,apiKey) \
$widgets(label,package) $widgets(entry,package) \
$widgets(label,patchLevel) $widgets(entry,patchLevel) \
$widgets(label,language) $widgets(entry,language) \
$widgets(label,version) $widgets(entry,version) \
$widgets(label,platform) $widgets(entry,platform) \
|