home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Trial / Paint Shop Pro XI / Data1.cab / _3BCE9BD1C336459EA9D60262942C6EB7 < prev    next >
Encoding:
Text File  |  2006-08-04  |  15.6 KB  |  417 lines

  1. from PSPApp import *
  2.  
  3. # Copyright 2006 Corel Software Inc., all rights reserved
  4. # This file contains utility routines provided by Corel Software.
  5. # This file contains all translatable strings for the bundled script files.
  6.  
  7. ScriptData = {}
  8.  
  9. class SaveSelection:
  10.     ''' define a helper class that can save any active selection to the alpha
  11.         channel and restore it later
  12.     '''
  13.     def __init__( self, Environment, Doc ):
  14.         ''' at init time we save the environment variable provided by PSP,
  15.             and if a selection exists we save it to an alpha channel
  16.         '''
  17.         self.Env = Environment
  18.         self.SavedSelection =  '__$TempSavedSelection$__'
  19.         self.IsSaved = 0
  20.         self.SavedOnDoc = Doc
  21.         
  22.         SelResult = App.Do( self.Env, 'GetRasterSelectionRect' )
  23.         if SelResult[ 'Type' ] != App.Constants.SelectionType.None:
  24.             # if there is a selection save it to the alpha channel
  25.             App.Do( self.Env, 'SelectSaveDisk', {
  26.                 'FileName': self.SavedSelection, 
  27.                 'Overwrite': App.Constants.Boolean.true, 
  28.                 'GeneralSettings': {
  29.                     'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  30.                     'AutoActionMode': App.Constants.AutoActionMode.Match
  31.                     }
  32.                 }, Doc)
  33.             self.IsSaved = 1    # set this so we know we saved one
  34.             
  35.             if SelResult[ 'Type' ] == App.Constants.SelectionType.Floating:
  36.                 # if the selection is floating promote it to a layer
  37.                 App.Do( self.Env, 'SelectPromote', {
  38.                         'KeepSelection': App.Constants.Boolean.false, 
  39.                         'LayerName': SelectionLayer, 
  40.                         'GeneralSettings': {
  41.                             'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  42.                             'AutoActionMode': App.Constants.AutoActionMode.Match
  43.                             }
  44.                         }, Doc)
  45.             else:
  46.                 App.Do( self.Env, 'SelectNone' )
  47.            
  48.             
  49.     def RestoreSelection( self ):
  50.         ''' if we have saved a selection, restore it now.  If we promoted
  51.             a floating selection to a layer we don't restore the selection
  52.             but don't attempt to mess with the layer in any way
  53.         '''
  54.         if self.IsSaved == 1:
  55.             # load the selection back from disk - this will replace any existing selection
  56.             App.Do( self.Env, 'SelectLoadDisk', {
  57.                     'FileName': self.SavedSelection, 
  58.                     'Operation': App.Constants.SelectionOperation.Replace, 
  59.                     'UpperLeft': App.Constants.Boolean.false, 
  60.                     'ClipToCanvas': App.Constants.Boolean.false, 
  61.                     'GreyMethod': App.Constants.CreateMaskFrom.Luminance, 
  62.                     'Invert': App.Constants.Boolean.false, 
  63.                     'GeneralSettings': {
  64.                         'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  65.                         'AutoActionMode': App.Constants.AutoActionMode.Match
  66.                         }
  67.                     }, self.SavedOnDoc)
  68.  
  69.     # end class SaveSelection
  70.  
  71. def NameFromMaterial( Material, Delimiter=' ', IncludeTexture=1 ):
  72.     ''' Given a material repository, return a name that describes it.
  73.         By default the name is delimited with space, but the delimiter
  74.         parameter can be used to override it.
  75.         By default textures are included in the name, but can be omitted
  76.         by setting the IncludeTexture parameter to 0
  77.     '''
  78.     TextureName = None
  79.     TypeName = ''
  80.     if Material is None:
  81.         CoreName = Null
  82.     else:
  83.         if Material[ 'Pattern' ] and \
  84.            (Material[ 'Pattern' ][ 'Name' ] or Material[ 'Pattern' ][ 'Image' ] ):
  85.             TypeName = Pattern
  86.             if Material[ 'Pattern' ][ 'Name' ]:
  87.                 CoreName = Material[ 'Pattern'  ][ 'Name' ]
  88.             else:
  89.                 CoreName = Inline
  90.         elif Material[ 'Gradient' ] and Material[ 'Gradient' ][ 'Name' ]:
  91.             TypeName = Gradient
  92.             GradType = {}
  93.             GradType[ App.Constants.GradientType.Linear ] = Linear
  94.             GradType[ App.Constants.GradientType.Rectangular ] = Rectangular
  95.             GradType[ App.Constants.GradientType.Radial ] = Radial
  96.             GradType[ App.Constants.GradientType.Angular ] = Sunburst
  97.             
  98.             CoreName = '%s%s%s' % ( Material[ 'Gradient' ][ 'Name' ], Delimiter, 
  99.                                     GradType[ Material[ 'Gradient' ][ 'GradientType' ] ] )
  100.         elif Material[ 'Art' ]:
  101.             TypeName = Art
  102.             CoreName = '%02x%02x%02x' % Material[ 'Art' ][ 'Color' ]
  103.         else:
  104.             TypeName = Solid
  105.             CoreName = '%02x%02x%02x' % Material[ 'Color' ]
  106.  
  107.         if Material[ 'Texture' ] and Material[ 'Texture' ][ 'Name' ]:
  108.             TextureName = Material[ 'Texture' ]['Name']
  109.  
  110.     if TextureName is not None and IncludeTexture != 0:
  111.         MaterialName = '%s%s%s%s%s' % ( TypeName, Delimiter, CoreName, Delimiter, TextureName )
  112.     else:
  113.         MaterialName = '%s%s%s' % ( TypeName, Delimiter, CoreName )
  114.  
  115.     return MaterialName
  116.  
  117. def IsNullMaterial( Material ):
  118.     ' check if the passed in material is none.  Returns true if null, false if non-null'
  119.     if Material is None:    
  120.         return App.Constants.Boolean.true   # material might be entirely none
  121.  
  122.     ArtIsNone = 0
  123.     ColorIsNone = 0
  124.     GradientIsNone = 0
  125.     PatternIsNone = 0
  126.     
  127.     if Material['Color'] is None:
  128.         ColorIsNone = 1
  129.  
  130.     if Material['Gradient'] is None or Material['Gradient']['Name'] is None:
  131.         GradientIsNone = 1
  132.  
  133.     if Material['Pattern'] is None or \
  134.        (Material['Pattern']['Name'] is None and Material['Pattern']['Image'] is None):
  135.         PatternIsNone = 1
  136.  
  137.     if Material['Art'] is None:
  138.         ArtIsNone = 1
  139.  
  140.     if ColorIsNone and GradientIsNone and PatternIsNone and ArtIsNone:
  141.         return App.Constants.Boolean.true   #it works out to none
  142.     else:
  143.         return App.Constants.Boolean.false
  144.  
  145.  
  146. def IsFlatImage( Environment, Doc ):
  147.     'Determine if Doc consists of a single background layer.  True if flat, false if not'
  148.     ImageInfo = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
  149.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  150.  
  151.     if ImageInfo[ 'LayerNum' ] == 1 and LayerInfo[ 'IsBackground' ] == App.Constants.Boolean.true:
  152.         return App.Constants.Boolean.true
  153.     else:
  154.         return App.Constants.Boolean.false
  155.  
  156. def IsPaletted( Environment, Doc ):
  157.     '''Determine if the current image is paletted.  Greyscale is not counted as paletted
  158.        Returns true on paletted, false if not
  159.     '''
  160.     # these are all the paletted pixel formats
  161.     TargetFormats = [ App.Constants.PixelFormat.Index1, App.Constants.PixelFormat.Index4,
  162.                       App.Constants.PixelFormat.Index8 ]
  163.     
  164.     # are we paletted?
  165.     Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
  166.  
  167.     if Info['PixelFormat'] in TargetFormats:
  168.         return App.Constants.Boolean.true
  169.     else:
  170.         return App.Constants.Boolean.false
  171.  
  172. def IsTrueColor( Environment, Doc ):
  173.     ''' Determine if the current image is true color.  Greyscale does not count
  174.         Returns true for true color, false for all others
  175.     '''
  176.     TargetFormats = [ App.Constants.PixelFormat.BGR, App.Constants.PixelFormat.BGRA ]
  177.     
  178.     # are we true color?
  179.     Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
  180.     if Info['PixelFormat'] in TargetFormats:
  181.         return App.Constants.Boolean.true
  182.     else:
  183.         return App.Constants.Boolean.false
  184.  
  185. def IsGreyScale( Environment, Doc ):
  186.     ' Determine if the current image (not layer) is greyscale. True if it is, false otherwise'
  187.     TargetFormats = [ App.Constants.PixelFormat.Grey, App.Constants.PixelFormat.GreyA ]
  188.     
  189.     # are we true color?
  190.     Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
  191.     if Info['PixelFormat'] in TargetFormats:
  192.         return App.Constants.Boolean.true
  193.     else:
  194.         return App.Constants.Boolean.false
  195.  
  196. def LayerIsArtMedia( Environment, Doc ):
  197.     'Returns true if the current layer is a artmedia layer'
  198.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  199.     if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.ArtMedia:
  200.         return App.Constants.Boolean.true
  201.     else:
  202.         return App.Constants.Boolean.false
  203.  
  204. def LayerIsRaster( Environment, Doc ):
  205.     'Returns true if the current layer is a raster layer'
  206.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  207.     if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.Raster:
  208.         return App.Constants.Boolean.true
  209.     else:
  210.         return App.Constants.Boolean.false
  211.  
  212.  
  213. def LayerIsVector( Environment, Doc ):
  214.     'Returns true if the current layer is a vector layer'
  215.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  216.     if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.Vector:
  217.         return App.Constants.Boolean.true
  218.     else:
  219.         return App.Constants.Boolean.false
  220.  
  221. def LayerIsBackground( Environment, Doc ):
  222.     'Returns true if the current layer is the background layer'
  223.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  224.     return LayerInfo[ 'IsBackground' ]
  225.     
  226.  
  227. def GetLayerCount( Environment, Doc ):
  228.     'Returns number of layers in Doc'
  229.     ImageInfo = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
  230.     return ImageInfo[ 'LayerNum' ]    
  231.  
  232. def GetCurrentLayerName( Environment, Doc ):
  233.     'Returns the name of the current layer in Doc'
  234.     LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
  235.     return LayerInfo[ 'General' ][ 'Name' ]
  236.  
  237. def PromoteToTrueColor( Environment, Doc ):
  238.     'If the current image type is paletted, promote it to true color.  Greyscale is left alone'
  239.     if IsPaletted( Environment, Doc ):
  240.         App.Do( Environment, 'IncreaseColorsTo16Million', {}, Doc )
  241.     return
  242.  
  243. def RequireADoc( Environment ):
  244.     '''Test that we actually have a target document, and put up a message box if we dont
  245.        Returns true if we have an open doc, false otherwise
  246.     '''
  247.     if App.TargetDocument is None:
  248.         App.Do( Environment, 'MsgBox', {
  249.                 'Buttons': App.Constants.MsgButtons.OK, 
  250.                 'Icon': App.Constants.MsgIcons.Stop, 
  251.                 'Text': RequiresOpenImage, 
  252.                 })
  253.         return App.Constants.Boolean.false
  254.     else:
  255.         return App.Constants.Boolean.true
  256.  
  257. # Begin Translatable Strings
  258. # BevelSelection.PspScript:
  259. LayerName_BevelSelection = u"Beveled Selection"
  260.  
  261. # Black and white pencil.PspScript:
  262. LayerName_Blackandwhitepencil = u"Raster 2"
  263.  
  264. # Border with drop shadow.PspScript:
  265. AlphaName = u"Selection #1"
  266.  
  267. # Flag.PspScript:
  268. #AlphaName = u"Selection #1"
  269.  
  270. # Grey chart.PspScript:
  271. GradientName = u"Foreground-background"
  272.  
  273. # Sloppy edges.PspScript:
  274. #AlphaName = u"Selection #1"
  275.  
  276. # Toned greyscale.PspScript:
  277. LayerName_Tonedgreyscale = u"Color Balance 1"
  278.  
  279. # Vignette.PspScript:
  280. LayerName_Vignette = u"Raster 2"
  281.  
  282. # Photo edges.PspScript:
  283. LayerName_Photoedges = u"Raster 2"
  284.  
  285. # SimpleCaption.PspScript:
  286. ImageTooSmallMsg = u"The current image is too small to caption - it must be at least 200x200."
  287. MultipleLayersMsg = u"The current image has multiple layers.  This may lead to odd results.\nWe suggest flattening the image before continuing.  Do you wish to flatten?"
  288. CaptionPrompt = u"Enter a caption for the image.  This will be below the image and centered."
  289. CaptionTitle = u"Enter Image Caption"
  290. PromotedLayerName = u"Image"
  291. PageSurfaceLayerName = u"Page Surface"
  292. AlbumPageLayerGroup = u"Album Page"
  293. DropShadowLayerName = u"Drop shadow"
  294. CaptionTextLayerName = u"Caption Text"
  295. CaptionFontName2 = u"Tahoma" 
  296.  
  297. # VectorMergeAndCutoutSelected.PspScript:
  298. TwoOrMoreMsg = u"This script requires that two or more vector objects be selected." 
  299.  
  300. # VectorMergeSelected.PspScript:
  301. #TwoOrMoreMsg = u"This script requires that two or more vector objects be selected."
  302.  
  303. # AddPSP8FileLocations.PspScript:
  304. NoPSP8FoldersFound = u"No PSP8 folders found."
  305. FilesHaveBeenAdded = u"Files in '%s' have been added to the File Locations preferences."
  306. Brushes = u"Brushes"
  307. BumpMaps = u"Bump Maps"
  308. DeformationMaps = u"Deformation Maps"
  309. DisplacementMaps = u"Displacement Maps"
  310. EnvironmentMaps = u"Environment Maps"
  311. Gradients = u"Gradients"
  312. Masks = u"Masks"
  313. Palettes = u"Palettes"
  314. Patterns = u"Patterns"
  315. PictureFrames = u"Picture Frames"
  316. PictureTubes = u"Picture Tubes"
  317. PresetShapes = u"Preset Shapes"
  318. Presets = u"Presets"
  319. PrintTemplates = u"Print Templates"
  320. QuickGuides = u"Quick Guides"
  321. SampleImages = u"Sample Images"
  322. ScriptsRestricted = u"Scripts-Restricted"
  323. ScriptsTrusted = u"Scripts-Trusted"
  324. Selections = u"Selections"
  325. StyledLines = u"Styled Lines"
  326. Swatches = u"Swatches"
  327. Textures = u"Textures"
  328.  
  329. # AddPSP8FileLocationsALL.PspScript:
  330. #NoPSP8FoldersFound = u"No PSP8 folders found."
  331. #FilesHaveBeenAdded = u"Files in '%s' have been added to the File Locations preferences."
  332. #Brushes = u"Brushes"
  333. #BumpMaps = u"Bump Maps"
  334. #DeformationMaps = u"Deformation Maps"
  335. #DisplacementMaps = u"Displacement Maps"
  336. #EnvironmentMaps = u"Environment Maps"
  337. #Gradients = u"Gradients"
  338. #Masks = u"Masks"
  339. #Palettes = u"Palettes"
  340. #Patterns = u"Patterns"
  341. #PictureFrames = u"Picture Frames"
  342. #PictureTubes = u"Picture Tubes"
  343. #PresetShapes = u"Preset Shapes"
  344. #Presets = u"Presets"
  345. #PrintTemplates = u"Print Templates"
  346. #QuickGuides = u"Quick Guides"
  347. #SampleImages = u"Sample Images"
  348. #ScriptsRestricted = u"Scripts-Restricted"
  349. #ScriptsTrusted = u"Scripts-Trusted"
  350. #Selections = u"Selections"
  351. #StyledLines = u"Styled Lines"
  352. #Swatches = u"Swatches"
  353. #Textures = u"Textures"
  354.  
  355. # CapturePalette.PspScript:
  356. RequiresPaletted = u"This script requires a paletted image.  Would you like to reduce the color depth?"
  357. NoPaletteFound = u"Internal error:  No palette found"
  358. GroutWidthMsg = u"GroutWidth value must be between 0 and 20"
  359. ColorsPerRowMsg = u"ColorsPerRow value must be between 1 and 100"
  360. TileSizeMsg = u"TileSize must be between 2 and 50"
  361. NumColorsMsg = u"Number of colors must be between 2 and 1024"
  362. ButtonMarginMsg = u"ButtonMargin must be less than half the tilesize"
  363. ColorIs = u"Color %d is (%02X,%02X,%02X)"
  364.  
  365. # EXIFCaptioning.PspScript:
  366. NoEXIFData = u"No EXIF data found on the current image."
  367. ExposureMsg = u"f/%g aperture, %s exposure"
  368. CaptionBackground = u"Caption Background"
  369. EXIFCaption = u"EXIF Caption"
  370. EXIFText = u"EXIF Text"
  371. CaptionFontName = u"Arial"
  372.  
  373. # SplitCMYKtoLayerGroup.PspScript:
  374. Black = u"Black"
  375. BlackChannel = u"Black Channel"
  376. Yellow = u"Yellow"
  377. YellowChannel = u"Yellow Channel"
  378. Magenta = u"Magenta"
  379. MagentaChannel = u"Magenta Channel"
  380. Cyan = u"Cyan"
  381. CyanChannel = u"Cyan Channel"
  382. CMYKChannels = u"CMYK Channels"
  383.  
  384. # SplitHSLtoLayerGroup.PspScript:
  385. Lightness = u"Lightness"
  386. LightnessChannel = u"Lightness Channel"
  387. Saturation = u"Saturation"
  388. SaturationChannel = u"Saturation Channel"
  389. Hue = u"Hue"
  390. HueChannel = u"Hue Channel"
  391. HSLChannels = u"HSL Channels"
  392.  
  393. # SplitRGBtoLayerGroup.PspScript:
  394. Blue = u"Blue"
  395. BlueChannel = u"Blue Channel"
  396. Green = u"Green"
  397. GreenChannel = u"Green Channel"
  398. Red = u"Red"
  399. RedChannel = u"Red Channel"
  400. RGBChannels = u"RGB Channels"
  401.  
  402. # JascUtils.py, PSPUtils.py
  403. SelectionLayer = u"Selection promoted via script"
  404. Pattern = u"Pattern"
  405. Inline = u"Inline"
  406. Gradient = u"Gradient"
  407. Linear = u"Linear"
  408. Radial = u"Radial"
  409. Rectangular = u"Rectangular"
  410. Sunburst = u"Sunburst"
  411. Solid = u"Solid"
  412. Null = u"Null"
  413. Art = u"Art"
  414. RequiresOpenImage = u"This script requires an open image."
  415. # End Translatable Strings
  416.  
  417.