/**************************************************************************
*
* @@@BUILDINFO@@@ 86preferences-2.jsx 2.0.1.65 24-April-2007
* Copyright 2006-2007 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property of
* Adobe Systems Incorporated and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe Systems
* Incorporated and its suppliers and may be covered by U.S. and Foreign
* Patents,patents in process,and are protected by trade secret or copyright
* law. Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained from
* Adobe Systems Incorporated.
**************************************************************************/
var preferenceDialog = null;
var locales = [];
const cShortcutTitleLength = 35;
scintillaPrefs = new Object;
// This object contains all color icons under the name of the color.
var colorIcons = null;
///////////////////////////////////////////////////////////////////////////////
//
// scintilla prefs
//
scintillaPrefs.init = function()
{
if( this.xml == undefined )
{
this.xml = new XML( "" );
this.xml.languages = languages.copy();
this.xml.defaults = new XML( "" );
this.xml.defaults.languages = languages.copy();
}
}
// Load the file scintilla.xml during app startup.
scintillaPrefs.reset = function()
{
var loaded = false;
if( !this.backup )
{
var f = new File( app.prefsFolder + "/scintilla.xml" );
if( f.exists && f.open ("r") )
{
f.encoding = "UTF-8";
this.xml = new XML( f.read() );
this.backup = this.xml;
f.close();
loaded = (this.xml.languages.length() > 0);
}
}
else
{
this.xml = this.backup;
loaded = true;
}
// copy from the current languages...
if( !loaded )
this.init();
return loaded;
}
// Load the file scintilla.xml during app startup.
scintillaPrefs.load = function()
{
var loaded = this.reset();
if( loaded )
languages = this.xml.languages.copy();
return loaded;
}
// Create the parent folder if not yet present.
scintillaPrefs.createFolder = function()
{
var fld = new Folder (app.prefsFolder);
if (!fld.exists)
fld.create();
return fld;
}
// Save the file scintilla.xml during app shutdown.
scintillaPrefs.save = function()
{
// create the prefs file
var fld = this.createFolder();
var f = new File (fld + "/scintilla.xml");
if (f.open ("w"))
{
f.encoding = "UTF-8";
f.write ( this.xml.toXMLString() );
if (!f.close())
f.remove();
}
}
///////////////////////////////////////////////////////////////////////////////
//
// preference dialog
//
function PreferenceDialog()
{
//
// Initialize the color icons for the Fonts and Colors prefs if we don't have them yet
//
if (!colorIcons)
{
colorIcons = {};
for (var i in colors)
colorIcons [i] = ScriptUI.newImage ("#" + i);
}
/////////////////////////////////////////////////////////////////////////
//
// Create scintilla prefs if the user launched without prefs (see "shift" in startup.jsx).
//
scintillaPrefs.init();
/////////////////////////////////////////////////////////////////////////
//
// The preferences dialog resource
//
var prefsDlgResSpec =
"prefdialog { \
text : '$$$/ESToolkit/PreferencesDlg/Title=ExtendScript Toolkit 2 Preferences', \
orientation : 'column', \
alignment : ['fill','fill'], \
alignChildren : ['fill','fill'], \
listAndPanels : Group \
{ \
orientation : 'row', \
selector : ListBox \
{ \
preferredSize : [155,145], \
alignment : ['left','fill'], \
margins : [15,20,15,15] \
helpTip:'$$$/ESToolkit/PreferencesDlg/htSelector=Select the preferences to change' \
}, \
prefs : Group \
{ \
orientation : 'column', \
alignment : ['fill','fill'], \
alignChildren : ['fill','fill'], \
panes : Group \
{ \
minimumSize : [380, 380], \
maximumSize : [380, 380], \
alignment : ['left','top'], \
orientation : 'stack', \
}, \
divider : Panel \
{ \
orientation : 'row', \
preferredSize : [10,1], \
maximumSize : [1000,1], \
alignment : ['fill','bottom'],\
} \
} \
}, \
btns : Group { \
orientation : 'row', \
alignment : ['right','bottom'], \
defBtn : Button \
{ \
text : '$$$/ESToolkit/PreferencesDlg/DefaultBtn=Default' }, \
space : Group \
{ \
minimumSize : [30,1], \
preferedSize : [30,1] \
}, \
okBtn : Button \
{ \
text : '$$$/CT/ExtendScript/UI/OK=OK', \
properties : { \
name :'ok' \
} \
}, \
cancelBtn : Button \
{ \
text : '$$$/CT/ExtendScript/UI/Cancel=Cancel', \
properties : { \
name : 'cancel' \
} \
} \
} \
} \
}";
this.prefsDlg = new Window (prefsDlgResSpec);
this.prefsDlg.currentPane = null;
// Each Prefs object needs the following methods:
// prefsObj.create (parentPane) - create the pane and return the Pane object.
// pane.preProcess() - preprocess the pane just before being shown.
// pane.layoutDone() - informs the pane that the initial layout is done (optional)
// pane.postProcess() - do any work just before the pane is being hidden.
// pane.store() - store the preferences. Return true if the Next Time dialog is needed.
// pane.toDefault() - set back to default values
// pane.cancelled() - Prefs dialog has been cancelled
var parentPane = this.prefsDlg.listAndPanels.prefs.panes;
// Initialize the 'selector' list that chooses which preference pane to show
this.initSelectorList( this.prefsDlg.listAndPanels.selector, parentPane,
[
[ "$$$/ESToolkit/PreferencesDlg/StartupTitle=Startup", generalPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/textTitle=Documents", documentPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/fontTitle=Font and Colors", fontPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/debuggerTitle=Debugging", debugPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/helpTitle=Help", helpPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/favoritesTitle=Favorites", favoritesPrefs ],
[ "$$$/ESToolkit/PreferencesDlg/shortcutTitle=Keyboard Shortcuts", shortcutPrefs ]
] );
with( this.prefsDlg.btns )
{
// Dialog window is 2 levels in hierarchy up from the buttons
okBtn.onClick = function ()
{
// Make sure to post-process the current pane
if( this.window.currentPane )
this.window.currentPane.postProcess();
// pwollek 02/09/07 should happen on shutdwon
// Save the scintilla prefs...
//scintillaPrefs.save();
languages = scintillaPrefs.xml.languages.copy();
if( documents.length > 0 )
{
for( var i=0; i 0)
text1 = text1.substr (0, i);
var width = list.graphics.measureString (text1)[0];
var maxWidth = tab - list.ellipsisWidth - 5 * list.smallSpaceWidth;
var halfSpace = 0.5 * list.smallSpaceWidth;
if (width > (maxWidth + halfSpace))
{
// Need to shrink
while (width > maxWidth)
{
text1 = text1.substr (0, text1.length-1);
width = list.graphics.measureString (text1)[0];
}
// append Unicode ellipsis string
text1 += list.ellipsis;
width = list.graphics.measureString (text1)[0];
}
// First, approach with spaces
var oldWidth = width;
while (width < tab)
{
text1 += " ";
width += list.spaceWidth;
}
// Then, fine adjust
width = list.graphics.measureString (text1)[0];
if (width > tab && width > (oldWidth + halfSpace))
{
// print (tab + " " + list.graphics.measureString (text1)[0] + " Fixing " + text1);
text1 = text1.substr (0, text1.length-1);
width = list.graphics.measureString (text1)[0];
}
while (width < (tab - halfSpace))
{
text1 += list.smallSpace;
width = list.graphics.measureString (text1)[0];
}
// print (tab + " " + list.graphics.measureString (text1)[0] + " " + text1);
this.text = text1 + text2;
}