PaletteObjectManager Class Reference

The PaletteObjectManager JavaScript global object. Provides access to palette list (PaletteList) and palette (Palette) objects. More...

Public Slots

Load palette lists.
PaletteListgetPaletteListByElementId (int id)
 Load the element palette list specified by the element ID 'id' and return the corresponding PaletteList object. More...
 
PaletteListgetScenePaletteList ()
 Load the scene palette list and return the corresponding PaletteList object. More...
 
For loaded palette lists.
int getNumPaletteLists ()
 Return the number of loaded palette lists. More...
 
PaletteListgetPaletteListByIndex (int index)
 Returns a PaletteList object for the loaded palette list at position 'index'. More...
 
PaletteListgetPaletteListById (String id)
 Return a PaletteList object for the loaded palette list with the specified list ID. More...
 
Palettes.
PalettegetPalette (String id)
 Returns a Palette object for the loaded palette with the specified palette ID. More...
 
bool removePaletteReferencesAndDeleteOnDisk (String id)
 

Detailed Description

The PaletteObjectManager JavaScript global object. Provides access to palette list (PaletteList) and palette (Palette) objects.

function isScenePaletteList(paletteList)
{
// Palette list with an element id of -1 are scene palette lists.
return paletteList.elementId == -1;
}
function getMyPalette()
{
// Find the first element palette list that owns a palette named "MyPalette"
var numPaletteLists = PaletteObjectManager.getNumPaletteLists();
for(var i=0; i < numPaletteLists; ++i)
{
if(isScenePaletteList(paletteList))
continue;
for(var j=0; j < paletteList.numPalettes; ++j)
{
var palette = paletteList.getPaletteByIndex(j);
if(palette.getName() == "MyPalette")
return palette;
}
}
}

Member Function Documentation

◆ getNumPaletteLists

int PaletteObjectManager::getNumPaletteLists ( )
slot

Return the number of loaded palette lists.

Returns
The number of loaded palette lists.

◆ getPalette

Palette* PaletteObjectManager::getPalette ( String  id)
slot

Returns a Palette object for the loaded palette with the specified palette ID.

Parameters
idID of palette to retrieve

◆ getPaletteListByElementId

PaletteList* PaletteObjectManager::getPaletteListByElementId ( int  id)
slot

Load the element palette list specified by the element ID 'id' and return the corresponding PaletteList object.

If the palette list isn't already loaded, the method will load the palette list from the disk.

Parameters
idelement ID
Returns
The element palette list of the element which has the given ID.

◆ getPaletteListById

PaletteList* PaletteObjectManager::getPaletteListById ( String  id)
slot

Return a PaletteList object for the loaded palette list with the specified list ID.

Parameters
idID of palette list to retrieve

◆ getPaletteListByIndex

PaletteList* PaletteObjectManager::getPaletteListByIndex ( int  index)
slot

Returns a PaletteList object for the loaded palette list at position 'index'.

Parameters
indexindex of palette list to retrieve

◆ getScenePaletteList

PaletteList* PaletteObjectManager::getScenePaletteList ( )
slot

Load the scene palette list and return the corresponding PaletteList object.

If the palette list isn't already loaded, the method will load the palette list from the disk.

Returns
The scene palette list of the scene.

◆ removePaletteReferencesAndDeleteOnDisk

bool PaletteObjectManager::removePaletteReferencesAndDeleteOnDisk ( String  id)
slot

Remove a palette from the scene and all elements, and schedule the file for deletion on next save. The method needs to acquire the locks for the palette and each palette list, and throws a JavaScript exception if it can't get ownership. Returns true on success. Deleting the palette on disk may affect any drawing which link to the palette, even in other projects.