Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | var dialog; |
michael@0 | 8 | var gPrintBundle; |
michael@0 | 9 | var gPrintSettings = null; |
michael@0 | 10 | var gPrintSettingsInterface = Components.interfaces.nsIPrintSettings; |
michael@0 | 11 | var gPaperArray; |
michael@0 | 12 | var gPlexArray; |
michael@0 | 13 | var gResolutionArray; |
michael@0 | 14 | var gColorSpaceArray; |
michael@0 | 15 | var gPrefs; |
michael@0 | 16 | |
michael@0 | 17 | var default_command = "lpr"; |
michael@0 | 18 | var gPrintSetInterface = Components.interfaces.nsIPrintSettings; |
michael@0 | 19 | var doDebug = true; |
michael@0 | 20 | |
michael@0 | 21 | //--------------------------------------------------- |
michael@0 | 22 | function checkDouble(element, maxVal) |
michael@0 | 23 | { |
michael@0 | 24 | var value = element.value; |
michael@0 | 25 | if (value && value.length > 0) { |
michael@0 | 26 | value = value.replace(/[^\.|^0-9]/g,""); |
michael@0 | 27 | if (!value) { |
michael@0 | 28 | element.value = ""; |
michael@0 | 29 | } else { |
michael@0 | 30 | if (value > maxVal) { |
michael@0 | 31 | element.value = maxVal; |
michael@0 | 32 | } else { |
michael@0 | 33 | element.value = value; |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | } |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | //--------------------------------------------------- |
michael@0 | 40 | function isListOfPrinterFeaturesAvailable() |
michael@0 | 41 | { |
michael@0 | 42 | var has_printerfeatures = false; |
michael@0 | 43 | |
michael@0 | 44 | try { |
michael@0 | 45 | has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures"); |
michael@0 | 46 | } catch(ex) { |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | return has_printerfeatures; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | //--------------------------------------------------- |
michael@0 | 53 | function getDoubleStr(val, dec) |
michael@0 | 54 | { |
michael@0 | 55 | var str = val.toString(); |
michael@0 | 56 | var inx = str.indexOf("."); |
michael@0 | 57 | return str.substring(0, inx+dec+1); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | //--------------------------------------------------- |
michael@0 | 61 | function initDialog() |
michael@0 | 62 | { |
michael@0 | 63 | gPrintBundle = document.getElementById("printBundle"); |
michael@0 | 64 | |
michael@0 | 65 | dialog = new Object; |
michael@0 | 66 | |
michael@0 | 67 | dialog.paperList = document.getElementById("paperList"); |
michael@0 | 68 | dialog.paperGroup = document.getElementById("paperGroup"); |
michael@0 | 69 | |
michael@0 | 70 | dialog.plexList = document.getElementById("plexList"); |
michael@0 | 71 | dialog.plexGroup = document.getElementById("plexGroup"); |
michael@0 | 72 | |
michael@0 | 73 | dialog.resolutionList = document.getElementById("resolutionList"); |
michael@0 | 74 | dialog.resolutionGroup = document.getElementById("resolutionGroup"); |
michael@0 | 75 | |
michael@0 | 76 | dialog.jobTitleLabel = document.getElementById("jobTitleLabel"); |
michael@0 | 77 | dialog.jobTitleGroup = document.getElementById("jobTitleGroup"); |
michael@0 | 78 | dialog.jobTitleInput = document.getElementById("jobTitleInput"); |
michael@0 | 79 | |
michael@0 | 80 | dialog.cmdLabel = document.getElementById("cmdLabel"); |
michael@0 | 81 | dialog.cmdGroup = document.getElementById("cmdGroup"); |
michael@0 | 82 | dialog.cmdInput = document.getElementById("cmdInput"); |
michael@0 | 83 | |
michael@0 | 84 | dialog.colorspaceList = document.getElementById("colorspaceList"); |
michael@0 | 85 | dialog.colorspaceGroup = document.getElementById("colorspaceGroup"); |
michael@0 | 86 | |
michael@0 | 87 | dialog.colorGroup = document.getElementById("colorGroup"); |
michael@0 | 88 | dialog.colorRadioGroup = document.getElementById("colorRadioGroup"); |
michael@0 | 89 | dialog.colorRadio = document.getElementById("colorRadio"); |
michael@0 | 90 | dialog.grayRadio = document.getElementById("grayRadio"); |
michael@0 | 91 | |
michael@0 | 92 | dialog.fontsGroup = document.getElementById("fontsGroup"); |
michael@0 | 93 | dialog.downloadFonts = document.getElementById("downloadFonts"); |
michael@0 | 94 | |
michael@0 | 95 | dialog.topInput = document.getElementById("topInput"); |
michael@0 | 96 | dialog.bottomInput = document.getElementById("bottomInput"); |
michael@0 | 97 | dialog.leftInput = document.getElementById("leftInput"); |
michael@0 | 98 | dialog.rightInput = document.getElementById("rightInput"); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | //--------------------------------------------------- |
michael@0 | 102 | function round10(val) |
michael@0 | 103 | { |
michael@0 | 104 | return Math.round(val * 10) / 10; |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | |
michael@0 | 108 | //--------------------------------------------------- |
michael@0 | 109 | function paperListElement(aPaperListElement) |
michael@0 | 110 | { |
michael@0 | 111 | this.paperListElement = aPaperListElement; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | paperListElement.prototype = |
michael@0 | 115 | { |
michael@0 | 116 | clearPaperList: |
michael@0 | 117 | function () |
michael@0 | 118 | { |
michael@0 | 119 | // remove the menupopup node child of the menulist. |
michael@0 | 120 | this.paperListElement.removeChild(this.paperListElement.firstChild); |
michael@0 | 121 | }, |
michael@0 | 122 | |
michael@0 | 123 | appendPaperNames: |
michael@0 | 124 | function (aDataObject) |
michael@0 | 125 | { |
michael@0 | 126 | var popupNode = document.createElement("menupopup"); |
michael@0 | 127 | for (var i=0;i<aDataObject.length;i++) { |
michael@0 | 128 | var paperObj = aDataObject[i]; |
michael@0 | 129 | var itemNode = document.createElement("menuitem"); |
michael@0 | 130 | var label; |
michael@0 | 131 | try { |
michael@0 | 132 | label = gPrintBundle.getString(paperObj.name); |
michael@0 | 133 | } |
michael@0 | 134 | catch (e) { |
michael@0 | 135 | /* No name in string bundle ? Then build one manually (this |
michael@0 | 136 | * usually happens when gPaperArray was build by createPaperArrayFromPrinterFeatures() ...) */ |
michael@0 | 137 | if (paperObj.inches) { |
michael@0 | 138 | label = paperObj.name + " (" + round10(paperObj.width) + "x" + round10(paperObj.height) + " inch)"; |
michael@0 | 139 | } |
michael@0 | 140 | else { |
michael@0 | 141 | label = paperObj.name + " (" + paperObj.width + "x" + paperObj.height + " mm)"; |
michael@0 | 142 | } |
michael@0 | 143 | } |
michael@0 | 144 | itemNode.setAttribute("label", label); |
michael@0 | 145 | itemNode.setAttribute("value", i); |
michael@0 | 146 | popupNode.appendChild(itemNode); |
michael@0 | 147 | } |
michael@0 | 148 | this.paperListElement.appendChild(popupNode); |
michael@0 | 149 | } |
michael@0 | 150 | }; |
michael@0 | 151 | |
michael@0 | 152 | //--------------------------------------------------- |
michael@0 | 153 | function createPaperArrayFromDefaults() |
michael@0 | 154 | { |
michael@0 | 155 | var paperNames = ["letterSize", "legalSize", "exectiveSize", "a5Size", "a4Size", "a3Size", "a2Size", "a1Size", "a0Size"]; |
michael@0 | 156 | //var paperNames = ["&letterRadio.label;", "&legalRadio.label;", "&exectiveRadio.label;", "&a4Radio.label;", "&a3Radio.label;"]; |
michael@0 | 157 | var paperWidths = [ 8.5, 8.5, 7.25, 148.0, 210.0, 287.0, 420.0, 594.0, 841.0]; |
michael@0 | 158 | var paperHeights = [11.0, 14.0, 10.50, 210.0, 297.0, 420.0, 594.0, 841.0, 1189.0]; |
michael@0 | 159 | var paperInches = [true, true, true, false, false, false, false, false, false]; |
michael@0 | 160 | // this is deprecated |
michael@0 | 161 | var paperEnums = [0, 1, 2, 3, 4, 5, 6, 7, 8]; |
michael@0 | 162 | |
michael@0 | 163 | gPaperArray = new Array(); |
michael@0 | 164 | |
michael@0 | 165 | for (var i=0;i<paperNames.length;i++) { |
michael@0 | 166 | var obj = new Object(); |
michael@0 | 167 | obj.name = paperNames[i]; |
michael@0 | 168 | obj.width = paperWidths[i]; |
michael@0 | 169 | obj.height = paperHeights[i]; |
michael@0 | 170 | obj.inches = paperInches[i]; |
michael@0 | 171 | |
michael@0 | 172 | /* Calculate the width/height in millimeters */ |
michael@0 | 173 | if (paperInches[i]) { |
michael@0 | 174 | obj.width_mm = paperWidths[i] * 25.4; |
michael@0 | 175 | obj.height_mm = paperHeights[i] * 25.4; |
michael@0 | 176 | } |
michael@0 | 177 | else { |
michael@0 | 178 | obj.width_mm = paperWidths[i]; |
michael@0 | 179 | obj.height_mm = paperHeights[i]; |
michael@0 | 180 | } |
michael@0 | 181 | gPaperArray[i] = obj; |
michael@0 | 182 | } |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | //--------------------------------------------------- |
michael@0 | 186 | function createPaperArrayFromPrinterFeatures() |
michael@0 | 187 | { |
michael@0 | 188 | var printername = gPrintSettings.printerName; |
michael@0 | 189 | if (doDebug) { |
michael@0 | 190 | dump("createPaperArrayFromPrinterFeatures for " + printername + ".\n"); |
michael@0 | 191 | } |
michael@0 | 192 | |
michael@0 | 193 | gPaperArray = new Array(); |
michael@0 | 194 | |
michael@0 | 195 | var numPapers = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper.count"); |
michael@0 | 196 | |
michael@0 | 197 | if (doDebug) { |
michael@0 | 198 | dump("processing " + numPapers + " entries...\n"); |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | for (var i=0;i<numPapers;i++) { |
michael@0 | 202 | var obj = new Object(); |
michael@0 | 203 | obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".name"); |
michael@0 | 204 | obj.width_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".width_mm"); |
michael@0 | 205 | obj.height_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".height_mm"); |
michael@0 | 206 | obj.inches = gPrefs.getBoolPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".is_inch"); |
michael@0 | 207 | |
michael@0 | 208 | /* Calculate the width/height in paper's native units (either inches or millimeters) */ |
michael@0 | 209 | if (obj.inches) { |
michael@0 | 210 | obj.width = obj.width_mm / 25.4; |
michael@0 | 211 | obj.height = obj.height_mm / 25.4; |
michael@0 | 212 | } |
michael@0 | 213 | else { |
michael@0 | 214 | obj.width = obj.width_mm; |
michael@0 | 215 | obj.height = obj.height_mm; |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | gPaperArray[i] = obj; |
michael@0 | 219 | |
michael@0 | 220 | if (doDebug) { |
michael@0 | 221 | dump("paper index=" + i + ", name=" + obj.name + ", width=" + obj.width + ", height=" + obj.height + ".\n"); |
michael@0 | 222 | } |
michael@0 | 223 | } |
michael@0 | 224 | } |
michael@0 | 225 | |
michael@0 | 226 | //--------------------------------------------------- |
michael@0 | 227 | function createPaperArray() |
michael@0 | 228 | { |
michael@0 | 229 | if (isListOfPrinterFeaturesAvailable()) { |
michael@0 | 230 | createPaperArrayFromPrinterFeatures(); |
michael@0 | 231 | } |
michael@0 | 232 | else { |
michael@0 | 233 | createPaperArrayFromDefaults(); |
michael@0 | 234 | } |
michael@0 | 235 | } |
michael@0 | 236 | |
michael@0 | 237 | //--------------------------------------------------- |
michael@0 | 238 | function createPaperSizeList(selectedInx) |
michael@0 | 239 | { |
michael@0 | 240 | var selectElement = new paperListElement(dialog.paperList); |
michael@0 | 241 | selectElement.clearPaperList(); |
michael@0 | 242 | |
michael@0 | 243 | selectElement.appendPaperNames(gPaperArray); |
michael@0 | 244 | |
michael@0 | 245 | if (selectedInx > -1) { |
michael@0 | 246 | selectElement.paperListElement.selectedIndex = selectedInx; |
michael@0 | 247 | } |
michael@0 | 248 | |
michael@0 | 249 | //dialog.paperList = selectElement; |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | //--------------------------------------------------- |
michael@0 | 253 | function plexListElement(aPlexListElement) |
michael@0 | 254 | { |
michael@0 | 255 | this.plexListElement = aPlexListElement; |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | plexListElement.prototype = |
michael@0 | 259 | { |
michael@0 | 260 | clearPlexList: |
michael@0 | 261 | function () |
michael@0 | 262 | { |
michael@0 | 263 | // remove the menupopup node child of the menulist. |
michael@0 | 264 | this.plexListElement.removeChild(this.plexListElement.firstChild); |
michael@0 | 265 | }, |
michael@0 | 266 | |
michael@0 | 267 | appendPlexNames: |
michael@0 | 268 | function (aDataObject) |
michael@0 | 269 | { |
michael@0 | 270 | var popupNode = document.createElement("menupopup"); |
michael@0 | 271 | for (var i=0;i<aDataObject.length;i++) { |
michael@0 | 272 | var plexObj = aDataObject[i]; |
michael@0 | 273 | var itemNode = document.createElement("menuitem"); |
michael@0 | 274 | var label; |
michael@0 | 275 | try { |
michael@0 | 276 | label = gPrintBundle.getString(plexObj.name); |
michael@0 | 277 | } |
michael@0 | 278 | catch (e) { |
michael@0 | 279 | /* No name in string bundle ? Then build one manually (this |
michael@0 | 280 | * usually happens when gPlexArray was build by createPlexArrayFromPrinterFeatures() ...) */ |
michael@0 | 281 | label = plexObj.name; |
michael@0 | 282 | } |
michael@0 | 283 | itemNode.setAttribute("label", label); |
michael@0 | 284 | itemNode.setAttribute("value", i); |
michael@0 | 285 | popupNode.appendChild(itemNode); |
michael@0 | 286 | } |
michael@0 | 287 | this.plexListElement.appendChild(popupNode); |
michael@0 | 288 | } |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | |
michael@0 | 292 | //--------------------------------------------------- |
michael@0 | 293 | function createPlexArrayFromDefaults() |
michael@0 | 294 | { |
michael@0 | 295 | var plexNames = ["default"]; |
michael@0 | 296 | |
michael@0 | 297 | gPlexArray = new Array(); |
michael@0 | 298 | |
michael@0 | 299 | for (var i=0;i<plexNames.length;i++) { |
michael@0 | 300 | var obj = new Object(); |
michael@0 | 301 | obj.name = plexNames[i]; |
michael@0 | 302 | |
michael@0 | 303 | gPlexArray[i] = obj; |
michael@0 | 304 | } |
michael@0 | 305 | } |
michael@0 | 306 | |
michael@0 | 307 | //--------------------------------------------------- |
michael@0 | 308 | function createPlexArrayFromPrinterFeatures() |
michael@0 | 309 | { |
michael@0 | 310 | var printername = gPrintSettings.printerName; |
michael@0 | 311 | if (doDebug) { |
michael@0 | 312 | dump("createPlexArrayFromPrinterFeatures for " + printername + ".\n"); |
michael@0 | 313 | } |
michael@0 | 314 | |
michael@0 | 315 | gPlexArray = new Array(); |
michael@0 | 316 | |
michael@0 | 317 | var numPlexs = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".plex.count"); |
michael@0 | 318 | |
michael@0 | 319 | if (doDebug) { |
michael@0 | 320 | dump("processing " + numPlexs + " entries...\n"); |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | for ( var i=0 ; i < numPlexs ; i++ ) { |
michael@0 | 324 | var obj = new Object(); |
michael@0 | 325 | obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".plex." + i + ".name"); |
michael@0 | 326 | |
michael@0 | 327 | gPlexArray[i] = obj; |
michael@0 | 328 | |
michael@0 | 329 | if (doDebug) { |
michael@0 | 330 | dump("plex index=" + i + ", name='" + obj.name + "'.\n"); |
michael@0 | 331 | } |
michael@0 | 332 | } |
michael@0 | 333 | } |
michael@0 | 334 | |
michael@0 | 335 | //--------------------------------------------------- |
michael@0 | 336 | function createPlexArray() |
michael@0 | 337 | { |
michael@0 | 338 | if (isListOfPrinterFeaturesAvailable()) { |
michael@0 | 339 | createPlexArrayFromPrinterFeatures(); |
michael@0 | 340 | } |
michael@0 | 341 | else { |
michael@0 | 342 | createPlexArrayFromDefaults(); |
michael@0 | 343 | } |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | //--------------------------------------------------- |
michael@0 | 347 | function createPlexNameList(selectedInx) |
michael@0 | 348 | { |
michael@0 | 349 | var selectElement = new plexListElement(dialog.plexList); |
michael@0 | 350 | selectElement.clearPlexList(); |
michael@0 | 351 | |
michael@0 | 352 | selectElement.appendPlexNames(gPlexArray); |
michael@0 | 353 | |
michael@0 | 354 | if (selectedInx > -1) { |
michael@0 | 355 | selectElement.plexListElement.selectedIndex = selectedInx; |
michael@0 | 356 | } |
michael@0 | 357 | |
michael@0 | 358 | //dialog.plexList = selectElement; |
michael@0 | 359 | } |
michael@0 | 360 | |
michael@0 | 361 | //--------------------------------------------------- |
michael@0 | 362 | function resolutionListElement(aResolutionListElement) |
michael@0 | 363 | { |
michael@0 | 364 | this.resolutionListElement = aResolutionListElement; |
michael@0 | 365 | } |
michael@0 | 366 | |
michael@0 | 367 | resolutionListElement.prototype = |
michael@0 | 368 | { |
michael@0 | 369 | clearResolutionList: |
michael@0 | 370 | function () |
michael@0 | 371 | { |
michael@0 | 372 | // remove the menupopup node child of the menulist. |
michael@0 | 373 | this.resolutionListElement.removeChild(this.resolutionListElement.firstChild); |
michael@0 | 374 | }, |
michael@0 | 375 | |
michael@0 | 376 | appendResolutionNames: |
michael@0 | 377 | function (aDataObject) |
michael@0 | 378 | { |
michael@0 | 379 | var popupNode = document.createElement("menupopup"); |
michael@0 | 380 | for (var i=0;i<aDataObject.length;i++) { |
michael@0 | 381 | var resolutionObj = aDataObject[i]; |
michael@0 | 382 | var itemNode = document.createElement("menuitem"); |
michael@0 | 383 | var label; |
michael@0 | 384 | try { |
michael@0 | 385 | label = gPrintBundle.getString(resolutionObj.name); |
michael@0 | 386 | } |
michael@0 | 387 | catch (e) { |
michael@0 | 388 | /* No name in string bundle ? Then build one manually (this |
michael@0 | 389 | * usually happens when gResolutionArray was build by createResolutionArrayFromPrinterFeatures() ...) */ |
michael@0 | 390 | label = resolutionObj.name; |
michael@0 | 391 | } |
michael@0 | 392 | itemNode.setAttribute("label", label); |
michael@0 | 393 | itemNode.setAttribute("value", i); |
michael@0 | 394 | popupNode.appendChild(itemNode); |
michael@0 | 395 | } |
michael@0 | 396 | this.resolutionListElement.appendChild(popupNode); |
michael@0 | 397 | } |
michael@0 | 398 | }; |
michael@0 | 399 | |
michael@0 | 400 | |
michael@0 | 401 | //--------------------------------------------------- |
michael@0 | 402 | function createResolutionArrayFromDefaults() |
michael@0 | 403 | { |
michael@0 | 404 | var resolutionNames = ["default"]; |
michael@0 | 405 | |
michael@0 | 406 | gResolutionArray = new Array(); |
michael@0 | 407 | |
michael@0 | 408 | for (var i=0;i<resolutionNames.length;i++) { |
michael@0 | 409 | var obj = new Object(); |
michael@0 | 410 | obj.name = resolutionNames[i]; |
michael@0 | 411 | |
michael@0 | 412 | gResolutionArray[i] = obj; |
michael@0 | 413 | } |
michael@0 | 414 | } |
michael@0 | 415 | |
michael@0 | 416 | //--------------------------------------------------- |
michael@0 | 417 | function createResolutionArrayFromPrinterFeatures() |
michael@0 | 418 | { |
michael@0 | 419 | var printername = gPrintSettings.printerName; |
michael@0 | 420 | if (doDebug) { |
michael@0 | 421 | dump("createResolutionArrayFromPrinterFeatures for " + printername + ".\n"); |
michael@0 | 422 | } |
michael@0 | 423 | |
michael@0 | 424 | gResolutionArray = new Array(); |
michael@0 | 425 | |
michael@0 | 426 | var numResolutions = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".resolution.count"); |
michael@0 | 427 | |
michael@0 | 428 | if (doDebug) { |
michael@0 | 429 | dump("processing " + numResolutions + " entries...\n"); |
michael@0 | 430 | } |
michael@0 | 431 | |
michael@0 | 432 | for ( var i=0 ; i < numResolutions ; i++ ) { |
michael@0 | 433 | var obj = new Object(); |
michael@0 | 434 | obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".resolution." + i + ".name"); |
michael@0 | 435 | |
michael@0 | 436 | gResolutionArray[i] = obj; |
michael@0 | 437 | |
michael@0 | 438 | if (doDebug) { |
michael@0 | 439 | dump("resolution index=" + i + ", name='" + obj.name + "'.\n"); |
michael@0 | 440 | } |
michael@0 | 441 | } |
michael@0 | 442 | } |
michael@0 | 443 | |
michael@0 | 444 | //--------------------------------------------------- |
michael@0 | 445 | function createResolutionArray() |
michael@0 | 446 | { |
michael@0 | 447 | if (isListOfPrinterFeaturesAvailable()) { |
michael@0 | 448 | createResolutionArrayFromPrinterFeatures(); |
michael@0 | 449 | } |
michael@0 | 450 | else { |
michael@0 | 451 | createResolutionArrayFromDefaults(); |
michael@0 | 452 | } |
michael@0 | 453 | } |
michael@0 | 454 | |
michael@0 | 455 | //--------------------------------------------------- |
michael@0 | 456 | function createResolutionNameList(selectedInx) |
michael@0 | 457 | { |
michael@0 | 458 | var selectElement = new resolutionListElement(dialog.resolutionList); |
michael@0 | 459 | selectElement.clearResolutionList(); |
michael@0 | 460 | |
michael@0 | 461 | selectElement.appendResolutionNames(gResolutionArray); |
michael@0 | 462 | |
michael@0 | 463 | if (selectedInx > -1) { |
michael@0 | 464 | selectElement.resolutionListElement.selectedIndex = selectedInx; |
michael@0 | 465 | } |
michael@0 | 466 | |
michael@0 | 467 | //dialog.resolutionList = selectElement; |
michael@0 | 468 | } |
michael@0 | 469 | |
michael@0 | 470 | //--------------------------------------------------- |
michael@0 | 471 | function colorspaceListElement(aColorspaceListElement) |
michael@0 | 472 | { |
michael@0 | 473 | this.colorspaceListElement = aColorspaceListElement; |
michael@0 | 474 | } |
michael@0 | 475 | |
michael@0 | 476 | colorspaceListElement.prototype = |
michael@0 | 477 | { |
michael@0 | 478 | clearColorspaceList: |
michael@0 | 479 | function () |
michael@0 | 480 | { |
michael@0 | 481 | // remove the menupopup node child of the menulist. |
michael@0 | 482 | this.colorspaceListElement.removeChild(this.colorspaceListElement.firstChild); |
michael@0 | 483 | }, |
michael@0 | 484 | |
michael@0 | 485 | appendColorspaceNames: |
michael@0 | 486 | function (aDataObject) |
michael@0 | 487 | { |
michael@0 | 488 | var popupNode = document.createElement("menupopup"); |
michael@0 | 489 | for (var i=0;i<aDataObject.length;i++) { |
michael@0 | 490 | var colorspaceObj = aDataObject[i]; |
michael@0 | 491 | var itemNode = document.createElement("menuitem"); |
michael@0 | 492 | var label; |
michael@0 | 493 | try { |
michael@0 | 494 | label = gPrintBundle.getString(colorspaceObj.name); |
michael@0 | 495 | } |
michael@0 | 496 | catch (e) { |
michael@0 | 497 | /* No name in string bundle ? Then build one manually (this |
michael@0 | 498 | * usually happens when gColorspaceArray was build by createColorspaceArrayFromPrinterFeatures() ...) */ |
michael@0 | 499 | label = colorspaceObj.name; |
michael@0 | 500 | } |
michael@0 | 501 | itemNode.setAttribute("label", label); |
michael@0 | 502 | itemNode.setAttribute("value", i); |
michael@0 | 503 | popupNode.appendChild(itemNode); |
michael@0 | 504 | } |
michael@0 | 505 | this.colorspaceListElement.appendChild(popupNode); |
michael@0 | 506 | } |
michael@0 | 507 | }; |
michael@0 | 508 | |
michael@0 | 509 | |
michael@0 | 510 | //--------------------------------------------------- |
michael@0 | 511 | function createColorspaceArrayFromDefaults() |
michael@0 | 512 | { |
michael@0 | 513 | var colorspaceNames = ["default"]; |
michael@0 | 514 | |
michael@0 | 515 | gColorspaceArray = new Array(); |
michael@0 | 516 | |
michael@0 | 517 | for (var i=0;i<colorspaceNames.length;i++) { |
michael@0 | 518 | var obj = new Object(); |
michael@0 | 519 | obj.name = colorspaceNames[i]; |
michael@0 | 520 | |
michael@0 | 521 | gColorspaceArray[i] = obj; |
michael@0 | 522 | } |
michael@0 | 523 | } |
michael@0 | 524 | |
michael@0 | 525 | //--------------------------------------------------- |
michael@0 | 526 | function createColorspaceArrayFromPrinterFeatures() |
michael@0 | 527 | { |
michael@0 | 528 | var printername = gPrintSettings.printerName; |
michael@0 | 529 | if (doDebug) { |
michael@0 | 530 | dump("createColorspaceArrayFromPrinterFeatures for " + printername + ".\n"); |
michael@0 | 531 | } |
michael@0 | 532 | |
michael@0 | 533 | gColorspaceArray = new Array(); |
michael@0 | 534 | |
michael@0 | 535 | var numColorspaces = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".colorspace.count"); |
michael@0 | 536 | |
michael@0 | 537 | if (doDebug) { |
michael@0 | 538 | dump("processing " + numColorspaces + " entries...\n"); |
michael@0 | 539 | } |
michael@0 | 540 | |
michael@0 | 541 | for ( var i=0 ; i < numColorspaces ; i++ ) { |
michael@0 | 542 | var obj = new Object(); |
michael@0 | 543 | obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".colorspace." + i + ".name"); |
michael@0 | 544 | |
michael@0 | 545 | gColorspaceArray[i] = obj; |
michael@0 | 546 | |
michael@0 | 547 | if (doDebug) { |
michael@0 | 548 | dump("colorspace index=" + i + ", name='" + obj.name + "'.\n"); |
michael@0 | 549 | } |
michael@0 | 550 | } |
michael@0 | 551 | } |
michael@0 | 552 | |
michael@0 | 553 | //--------------------------------------------------- |
michael@0 | 554 | function createColorspaceArray() |
michael@0 | 555 | { |
michael@0 | 556 | if (isListOfPrinterFeaturesAvailable()) { |
michael@0 | 557 | createColorspaceArrayFromPrinterFeatures(); |
michael@0 | 558 | } |
michael@0 | 559 | else { |
michael@0 | 560 | createColorspaceArrayFromDefaults(); |
michael@0 | 561 | } |
michael@0 | 562 | } |
michael@0 | 563 | |
michael@0 | 564 | //--------------------------------------------------- |
michael@0 | 565 | function createColorspaceNameList(selectedInx) |
michael@0 | 566 | { |
michael@0 | 567 | var selectElement = new colorspaceListElement(dialog.colorspaceList); |
michael@0 | 568 | selectElement.clearColorspaceList(); |
michael@0 | 569 | |
michael@0 | 570 | selectElement.appendColorspaceNames(gColorspaceArray); |
michael@0 | 571 | |
michael@0 | 572 | if (selectedInx > -1) { |
michael@0 | 573 | selectElement.colorspaceListElement.selectedIndex = selectedInx; |
michael@0 | 574 | } |
michael@0 | 575 | |
michael@0 | 576 | //dialog.colorspaceList = selectElement; |
michael@0 | 577 | } |
michael@0 | 578 | |
michael@0 | 579 | //--------------------------------------------------- |
michael@0 | 580 | function loadDialog() |
michael@0 | 581 | { |
michael@0 | 582 | var print_paper_type = 0; |
michael@0 | 583 | var print_paper_unit = 0; |
michael@0 | 584 | var print_paper_width = 0.0; |
michael@0 | 585 | var print_paper_height = 0.0; |
michael@0 | 586 | var print_paper_name = ""; |
michael@0 | 587 | var print_plex_name = ""; |
michael@0 | 588 | var print_resolution_name = ""; |
michael@0 | 589 | var print_colorspace = ""; |
michael@0 | 590 | var print_color = true; |
michael@0 | 591 | var print_downloadfonts = true; |
michael@0 | 592 | var print_command = default_command; |
michael@0 | 593 | var print_jobtitle = ""; |
michael@0 | 594 | |
michael@0 | 595 | gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); |
michael@0 | 596 | |
michael@0 | 597 | if (gPrintSettings) { |
michael@0 | 598 | print_paper_type = gPrintSettings.paperSizeType; |
michael@0 | 599 | print_paper_unit = gPrintSettings.paperSizeUnit; |
michael@0 | 600 | print_paper_width = gPrintSettings.paperWidth; |
michael@0 | 601 | print_paper_height = gPrintSettings.paperHeight; |
michael@0 | 602 | print_paper_name = gPrintSettings.paperName; |
michael@0 | 603 | print_plex_name = gPrintSettings.plexName; |
michael@0 | 604 | print_resolution_name = gPrintSettings.resolutionName; |
michael@0 | 605 | print_colorspace = gPrintSettings.colorspace; |
michael@0 | 606 | print_color = gPrintSettings.printInColor; |
michael@0 | 607 | print_downloadfonts = gPrintSettings.downloadFonts; |
michael@0 | 608 | print_command = gPrintSettings.printCommand; |
michael@0 | 609 | print_jobtitle = gPrintSettings.title; |
michael@0 | 610 | } |
michael@0 | 611 | |
michael@0 | 612 | if (doDebug) { |
michael@0 | 613 | dump("loadDialog******************************\n"); |
michael@0 | 614 | dump("paperSizeType "+print_paper_unit+"\n"); |
michael@0 | 615 | dump("paperWidth "+print_paper_width+"\n"); |
michael@0 | 616 | dump("paperHeight "+print_paper_height+"\n"); |
michael@0 | 617 | dump("paperName "+print_paper_name+"\n"); |
michael@0 | 618 | dump("plexName "+print_plex_name+"\n"); |
michael@0 | 619 | dump("resolutionName "+print_resolution_name+"\n"); |
michael@0 | 620 | dump("colorspace "+print_colorspace+"\n"); |
michael@0 | 621 | dump("print_color "+print_color+"\n"); |
michael@0 | 622 | dump("print_downloadfonts "+print_downloadfonts+"\n"); |
michael@0 | 623 | dump("print_command "+print_command+"\n"); |
michael@0 | 624 | dump("print_jobtitle "+print_jobtitle+"\n"); |
michael@0 | 625 | } |
michael@0 | 626 | |
michael@0 | 627 | createPaperArray(); |
michael@0 | 628 | |
michael@0 | 629 | var paperSelectedInx = 0; |
michael@0 | 630 | for (var i=0;i<gPaperArray.length;i++) { |
michael@0 | 631 | if (print_paper_name == gPaperArray[i].name) { |
michael@0 | 632 | paperSelectedInx = i; |
michael@0 | 633 | break; |
michael@0 | 634 | } |
michael@0 | 635 | } |
michael@0 | 636 | |
michael@0 | 637 | if (doDebug) { |
michael@0 | 638 | if (i == gPaperArray.length) |
michael@0 | 639 | dump("loadDialog: No paper found.\n"); |
michael@0 | 640 | else |
michael@0 | 641 | dump("loadDialog: found paper '"+gPaperArray[paperSelectedInx].name+"'.\n"); |
michael@0 | 642 | } |
michael@0 | 643 | |
michael@0 | 644 | createPaperSizeList(paperSelectedInx); |
michael@0 | 645 | |
michael@0 | 646 | createPlexArray(); |
michael@0 | 647 | var plexSelectedInx = 0; |
michael@0 | 648 | for (var i=0;i<gPlexArray.length;i++) { |
michael@0 | 649 | if (print_plex_name == gPlexArray[i].name) { |
michael@0 | 650 | plexSelectedInx = i; |
michael@0 | 651 | break; |
michael@0 | 652 | } |
michael@0 | 653 | } |
michael@0 | 654 | |
michael@0 | 655 | if (doDebug) { |
michael@0 | 656 | if (i == gPlexArray.length) |
michael@0 | 657 | dump("loadDialog: No plex found.\n"); |
michael@0 | 658 | else |
michael@0 | 659 | dump("loadDialog: found plex '"+gPlexArray[plexSelectedInx].name+"'.\n"); |
michael@0 | 660 | } |
michael@0 | 661 | |
michael@0 | 662 | createResolutionArray(); |
michael@0 | 663 | var resolutionSelectedInx = 0; |
michael@0 | 664 | for (var i=0;i<gResolutionArray.length;i++) { |
michael@0 | 665 | if (print_resolution_name == gResolutionArray[i].name) { |
michael@0 | 666 | resolutionSelectedInx = i; |
michael@0 | 667 | break; |
michael@0 | 668 | } |
michael@0 | 669 | } |
michael@0 | 670 | |
michael@0 | 671 | if (doDebug) { |
michael@0 | 672 | if (i == gResolutionArray.length) |
michael@0 | 673 | dump("loadDialog: No resolution found.\n"); |
michael@0 | 674 | else |
michael@0 | 675 | dump("loadDialog: found resolution '"+gResolutionArray[resolutionSelectedInx].name+"'.\n"); |
michael@0 | 676 | } |
michael@0 | 677 | |
michael@0 | 678 | createColorspaceArray(); |
michael@0 | 679 | var colorspaceSelectedInx = 0; |
michael@0 | 680 | for (var i=0;i<gColorspaceArray.length;i++) { |
michael@0 | 681 | if (print_colorspace == gColorspaceArray[i].name) { |
michael@0 | 682 | colorspaceSelectedInx = i; |
michael@0 | 683 | break; |
michael@0 | 684 | } |
michael@0 | 685 | } |
michael@0 | 686 | |
michael@0 | 687 | if (doDebug) { |
michael@0 | 688 | if (i == gColorspaceArray.length) |
michael@0 | 689 | dump("loadDialog: No colorspace found.\n"); |
michael@0 | 690 | else |
michael@0 | 691 | dump("loadDialog: found colorspace '"+gColorspaceArray[colorspaceSelectedInx].name+"'.\n"); |
michael@0 | 692 | } |
michael@0 | 693 | |
michael@0 | 694 | createPlexNameList(plexSelectedInx); |
michael@0 | 695 | createResolutionNameList(resolutionSelectedInx); |
michael@0 | 696 | createColorspaceNameList(colorspaceSelectedInx); |
michael@0 | 697 | |
michael@0 | 698 | /* Enable/disable and/or hide/unhide widgets based in the information |
michael@0 | 699 | * whether the selected printer and/or print module supports the matching |
michael@0 | 700 | * feature or not */ |
michael@0 | 701 | if (isListOfPrinterFeaturesAvailable()) { |
michael@0 | 702 | // job title |
michael@0 | 703 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_jobtitle")) |
michael@0 | 704 | dialog.jobTitleInput.removeAttribute("disabled"); |
michael@0 | 705 | else |
michael@0 | 706 | dialog.jobTitleInput.setAttribute("disabled","true"); |
michael@0 | 707 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_jobtitle_change")) |
michael@0 | 708 | dialog.jobTitleGroup.removeAttribute("hidden"); |
michael@0 | 709 | else |
michael@0 | 710 | dialog.jobTitleGroup.setAttribute("hidden","true"); |
michael@0 | 711 | |
michael@0 | 712 | // spooler command |
michael@0 | 713 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_spoolercommand")) |
michael@0 | 714 | dialog.cmdInput.removeAttribute("disabled"); |
michael@0 | 715 | else |
michael@0 | 716 | dialog.cmdInput.setAttribute("disabled","true"); |
michael@0 | 717 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_spoolercommand_change")) |
michael@0 | 718 | dialog.cmdGroup.removeAttribute("hidden"); |
michael@0 | 719 | else |
michael@0 | 720 | dialog.cmdGroup.setAttribute("hidden","true"); |
michael@0 | 721 | |
michael@0 | 722 | // paper size |
michael@0 | 723 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_paper_size")) |
michael@0 | 724 | dialog.paperList.removeAttribute("disabled"); |
michael@0 | 725 | else |
michael@0 | 726 | dialog.paperList.setAttribute("disabled","true"); |
michael@0 | 727 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_paper_size_change")) |
michael@0 | 728 | dialog.paperGroup.removeAttribute("hidden"); |
michael@0 | 729 | else |
michael@0 | 730 | dialog.paperGroup.setAttribute("hidden","true"); |
michael@0 | 731 | |
michael@0 | 732 | // plex mode |
michael@0 | 733 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_plex")) |
michael@0 | 734 | dialog.plexList.removeAttribute("disabled"); |
michael@0 | 735 | else |
michael@0 | 736 | dialog.plexList.setAttribute("disabled","true"); |
michael@0 | 737 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_plex_change")) |
michael@0 | 738 | dialog.plexGroup.removeAttribute("hidden"); |
michael@0 | 739 | else |
michael@0 | 740 | dialog.plexGroup.setAttribute("hidden","true"); |
michael@0 | 741 | |
michael@0 | 742 | // resolution |
michael@0 | 743 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_resolution")) |
michael@0 | 744 | dialog.resolutionList.removeAttribute("disabled"); |
michael@0 | 745 | else |
michael@0 | 746 | dialog.resolutionList.setAttribute("disabled","true"); |
michael@0 | 747 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_resolution_change")) |
michael@0 | 748 | dialog.resolutionGroup.removeAttribute("hidden"); |
michael@0 | 749 | else |
michael@0 | 750 | dialog.resolutionGroup.setAttribute("hidden","true"); |
michael@0 | 751 | |
michael@0 | 752 | // color/grayscale radio |
michael@0 | 753 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_printincolor")) |
michael@0 | 754 | dialog.colorRadioGroup.removeAttribute("disabled"); |
michael@0 | 755 | else |
michael@0 | 756 | dialog.colorRadioGroup.setAttribute("disabled","true"); |
michael@0 | 757 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_printincolor_change")) |
michael@0 | 758 | dialog.colorGroup.removeAttribute("hidden"); |
michael@0 | 759 | else |
michael@0 | 760 | dialog.colorGroup.setAttribute("hidden","true"); |
michael@0 | 761 | |
michael@0 | 762 | // colorspace |
michael@0 | 763 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_colorspace")) |
michael@0 | 764 | dialog.colorspaceList.removeAttribute("disabled"); |
michael@0 | 765 | else |
michael@0 | 766 | dialog.colorspaceList.setAttribute("disabled","true"); |
michael@0 | 767 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_colorspace_change")) |
michael@0 | 768 | dialog.colorspaceGroup.removeAttribute("hidden"); |
michael@0 | 769 | else |
michael@0 | 770 | dialog.colorspaceGroup.setAttribute("hidden","true"); |
michael@0 | 771 | |
michael@0 | 772 | // font download |
michael@0 | 773 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_downloadfonts")) |
michael@0 | 774 | dialog.downloadFonts.removeAttribute("disabled"); |
michael@0 | 775 | else |
michael@0 | 776 | dialog.downloadFonts.setAttribute("disabled","true"); |
michael@0 | 777 | if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_downloadfonts_change")) |
michael@0 | 778 | dialog.fontsGroup.removeAttribute("hidden"); |
michael@0 | 779 | else |
michael@0 | 780 | dialog.fontsGroup.setAttribute("hidden","true"); |
michael@0 | 781 | } |
michael@0 | 782 | |
michael@0 | 783 | if (print_command == "") { |
michael@0 | 784 | print_command = default_command; |
michael@0 | 785 | } |
michael@0 | 786 | |
michael@0 | 787 | if (print_color) { |
michael@0 | 788 | dialog.colorRadioGroup.selectedItem = dialog.colorRadio; |
michael@0 | 789 | } else { |
michael@0 | 790 | dialog.colorRadioGroup.selectedItem = dialog.grayRadio; |
michael@0 | 791 | } |
michael@0 | 792 | |
michael@0 | 793 | dialog.downloadFonts.checked = print_downloadfonts; |
michael@0 | 794 | |
michael@0 | 795 | dialog.cmdInput.value = print_command; |
michael@0 | 796 | dialog.jobTitleInput.value = print_jobtitle; |
michael@0 | 797 | |
michael@0 | 798 | dialog.topInput.value = gPrintSettings.edgeTop.toFixed(2); |
michael@0 | 799 | dialog.bottomInput.value = gPrintSettings.edgeBottom.toFixed(2); |
michael@0 | 800 | dialog.leftInput.value = gPrintSettings.edgeLeft.toFixed(2); |
michael@0 | 801 | dialog.rightInput.value = gPrintSettings.edgeRight.toFixed(2); |
michael@0 | 802 | } |
michael@0 | 803 | |
michael@0 | 804 | //--------------------------------------------------- |
michael@0 | 805 | function onLoad() |
michael@0 | 806 | { |
michael@0 | 807 | // Init dialog. |
michael@0 | 808 | initDialog(); |
michael@0 | 809 | |
michael@0 | 810 | gPrintSettings = window.arguments[0].QueryInterface(gPrintSetInterface); |
michael@0 | 811 | paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); |
michael@0 | 812 | |
michael@0 | 813 | if (doDebug) { |
michael@0 | 814 | if (gPrintSettings == null) alert("PrintSettings is null!"); |
michael@0 | 815 | if (paramBlock == null) alert("nsIDialogParam is null!"); |
michael@0 | 816 | } |
michael@0 | 817 | |
michael@0 | 818 | // default return value is "cancel" |
michael@0 | 819 | paramBlock.SetInt(0, 0); |
michael@0 | 820 | |
michael@0 | 821 | loadDialog(); |
michael@0 | 822 | } |
michael@0 | 823 | |
michael@0 | 824 | //--------------------------------------------------- |
michael@0 | 825 | function onAccept() |
michael@0 | 826 | { |
michael@0 | 827 | var print_paper_type = gPrintSettingsInterface.kPaperSizeDefined; |
michael@0 | 828 | var print_paper_unit = gPrintSettingsInterface.kPaperSizeInches; |
michael@0 | 829 | var print_paper_width = 0.0; |
michael@0 | 830 | var print_paper_height = 0.0; |
michael@0 | 831 | var print_paper_name = ""; |
michael@0 | 832 | var print_plex_name = ""; |
michael@0 | 833 | var print_resolution_name = ""; |
michael@0 | 834 | var print_colorspace = ""; |
michael@0 | 835 | |
michael@0 | 836 | if (gPrintSettings != null) { |
michael@0 | 837 | var paperSelectedInx = dialog.paperList.selectedIndex; |
michael@0 | 838 | var plexSelectedInx = dialog.plexList.selectedIndex; |
michael@0 | 839 | var resolutionSelectedInx = dialog.resolutionList.selectedIndex; |
michael@0 | 840 | var colorspaceSelectedInx = dialog.colorspaceList.selectedIndex; |
michael@0 | 841 | if (gPaperArray[paperSelectedInx].inches) { |
michael@0 | 842 | print_paper_unit = gPrintSettingsInterface.kPaperSizeInches; |
michael@0 | 843 | } else { |
michael@0 | 844 | print_paper_unit = gPrintSettingsInterface.kPaperSizeMillimeters; |
michael@0 | 845 | } |
michael@0 | 846 | print_paper_width = gPaperArray[paperSelectedInx].width; |
michael@0 | 847 | print_paper_height = gPaperArray[paperSelectedInx].height; |
michael@0 | 848 | print_paper_name = gPaperArray[paperSelectedInx].name; |
michael@0 | 849 | print_plex_name = gPlexArray[plexSelectedInx].name; |
michael@0 | 850 | print_resolution_name = gResolutionArray[resolutionSelectedInx].name; |
michael@0 | 851 | print_colorspace = gColorspaceArray[colorspaceSelectedInx].name; |
michael@0 | 852 | |
michael@0 | 853 | gPrintSettings.paperSizeType = print_paper_type; |
michael@0 | 854 | gPrintSettings.paperSizeUnit = print_paper_unit; |
michael@0 | 855 | gPrintSettings.paperWidth = print_paper_width; |
michael@0 | 856 | gPrintSettings.paperHeight = print_paper_height; |
michael@0 | 857 | gPrintSettings.paperName = print_paper_name; |
michael@0 | 858 | gPrintSettings.plexName = print_plex_name; |
michael@0 | 859 | gPrintSettings.resolutionName = print_resolution_name; |
michael@0 | 860 | gPrintSettings.colorspace = print_colorspace; |
michael@0 | 861 | |
michael@0 | 862 | // save these out so they can be picked up by the device spec |
michael@0 | 863 | gPrintSettings.printInColor = dialog.colorRadio.selected; |
michael@0 | 864 | gPrintSettings.downloadFonts = dialog.downloadFonts.checked; |
michael@0 | 865 | gPrintSettings.printCommand = dialog.cmdInput.value; |
michael@0 | 866 | gPrintSettings.title = dialog.jobTitleInput.value; |
michael@0 | 867 | |
michael@0 | 868 | gPrintSettings.edgeTop = dialog.topInput.value; |
michael@0 | 869 | gPrintSettings.edgeBottom = dialog.bottomInput.value; |
michael@0 | 870 | gPrintSettings.edgeLeft = dialog.leftInput.value; |
michael@0 | 871 | gPrintSettings.edgeRight = dialog.rightInput.value; |
michael@0 | 872 | |
michael@0 | 873 | if (doDebug) { |
michael@0 | 874 | dump("onAccept******************************\n"); |
michael@0 | 875 | dump("paperSizeType "+print_paper_type+" (should be 1)\n"); |
michael@0 | 876 | dump("paperSizeUnit "+print_paper_unit+"\n"); |
michael@0 | 877 | dump("paperWidth "+print_paper_width+"\n"); |
michael@0 | 878 | dump("paperHeight "+print_paper_height+"\n"); |
michael@0 | 879 | dump("paperName '"+print_paper_name+"'\n"); |
michael@0 | 880 | dump("plexName '"+print_plex_name+"'\n"); |
michael@0 | 881 | dump("resolutionName '"+print_resolution_name+"'\n"); |
michael@0 | 882 | dump("colorspace '"+print_colorspace+"'\n"); |
michael@0 | 883 | |
michael@0 | 884 | dump("printInColor "+gPrintSettings.printInColor+"\n"); |
michael@0 | 885 | dump("downloadFonts "+gPrintSettings.downloadFonts+"\n"); |
michael@0 | 886 | dump("printCommand '"+gPrintSettings.printCommand+"'\n"); |
michael@0 | 887 | } |
michael@0 | 888 | } else { |
michael@0 | 889 | dump("************ onAccept gPrintSettings: "+gPrintSettings+"\n"); |
michael@0 | 890 | } |
michael@0 | 891 | |
michael@0 | 892 | if (paramBlock) { |
michael@0 | 893 | // set return value to "ok" |
michael@0 | 894 | paramBlock.SetInt(0, 1); |
michael@0 | 895 | } else { |
michael@0 | 896 | dump("*** FATAL ERROR: paramBlock missing\n"); |
michael@0 | 897 | } |
michael@0 | 898 | |
michael@0 | 899 | return true; |
michael@0 | 900 | } |