Ignore:
Timestamp:
16-08-10 10:02:40 (21 months ago)
Author:
lvels
Message:

added attribute defaulttemplate, the defaulttemplate will be selected when the Print component becomes visible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • flamingo/trunk/fmc/classes/gui/Print.as

    r536 r573  
    4141* @hierarchy child node of Flamingo or a container component.  
    4242* @attr scales (optional) default: "500000,250000,100000,50000,20000,10000,5000,2000" comma seperated scale list. 
     43* @attr defaulttemplate (optional) no default id of the defaultTemplate (is shown in the combobox when print window becomes visible). 
    4344* @example 
    4445        <fmc:Window id="printWindow" top="60" left="60" width="585" height="680" visible="false" skin="g" 
    4546        canresize="true" canclose="true"> 
    4647        <string id="title" en="Print Settings and Preview" nl="Printinstellingen en printvoorbeeld"/> 
    47         <fmc:Print id="print" width="100%" height="100%" visible="false"  borderwidth="0" listento="map"> 
     48        <fmc:Print id="print" width="100%" height="100%" visible="false"  borderwidth="0" listento="map" defaulttemplate="printTemplate1"> 
    4849                        <string id="previewSize" en="Preview at Original Size" nl="Printvoorbeeld op ware grootte"/> 
    4950            <string id="toPrinter" en="Send to Printer" nl="Afdrukken"/> 
     
    99100    private var availPreviewWidth:Number = 0; 
    100101        private var availPreviewHeight:Number = 0; 
    101      
    102     function init():Void { 
     102        private var defaultTemplate : String = null; 
     103 
     104        function init():Void { 
    103105        map = _global.flamingo.getComponent(listento[0]); 
    104106        var componentIDs:Array = getComponents(); 
     
    133135        addCheckBox(); 
    134136        addPrintButton(); 
    135  
    136         templateComboBox.selectedIndex = 0; 
    137  
    138  
    139     } 
     137                resetTemplateComboBox();   
     138        } 
     139         
     140        private function resetTemplateComboBox(){ 
     141                templateComboBox.selectedIndex = 0; 
     142                setCurrentPrintTemplate(null); 
     143                if(defaultTemplate != null){ 
     144                        var templates:Array = templateComboBox.getDataProvider(); 
     145                        for (var j:Number = 0; j < templates.length; j++) { 
     146                    if(templates[j].data == _global.flamingo.getComponent(defaultTemplate)){ 
     147                                templateComboBox.selectedIndex = j; 
     148                                setCurrentPrintTemplate(templates[j].data);      
     149                    } 
     150                        } 
     151                } 
     152                 
     153        } 
    140154         
    141155        function setAttribute(name:String, value:String):Void { 
     
    143157                        scales=value.split(","); 
    144158                } 
     159                else if(name.toLowerCase()=="defaulttemplate"){ 
     160                        defaultTemplate=value; 
     161                } 
     162                 
    145163        } 
    146164         
     
    148166                super.setVisible(vis); 
    149167                if(printTemplates.length>1){ 
    150                         setCurrentPrintTemplate(null); 
    151                         templateComboBox.selectedIndex = 0; 
     168                        resetTemplateComboBox(); 
    152169                } else {         
    153170                                currentPrintTemplate.setVisible(vis); 
     
    165182     
    166183    private function addTemplateSelector():Void { 
    167                 var comboBoxContainer:MovieClip = createEmptyMovieClip("mTemplateComboBoxContainer", 9); 
     184                var comboBoxContainer:MovieClip = createEmptyMovieClip("mBoxContainer", 9); 
    168185        var initObject:Object = new Object(); 
    169186            initObject["_width"] = 200; 
Note: See TracChangeset for help on using the changeset viewer.