Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Functions
cmdcolor.h File Reference
#include "cmdvar.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 PyDoc_STRVAR (scribus_colornames__doc__, QT_TR_NOOP("getColorNames() -> list\n\ \n\ Returns a list containing the names of all defined colors in the document.\n\ If no document is open, returns a list of the default document colors.\n\ "))
 Managing Colors.
PyObject * scribus_colornames (PyObject *)
 Returns a list with colours available in doc or in prefs.
 PyDoc_STRVAR (scribus_getcolor__doc__, QT_TR_NOOP("getColor(\"name\") -> tuple\n\ \n\ Returns a tuple (C, M, Y, K) containing the four color components of the\n\ color \"name\" from the current document. If no document is open, returns\n\ the value of the named color from the default document colors.\n\ \n\ May raise NotFoundError if the named color wasn't found.\n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_getcolor (PyObject *, PyObject *args)
 Returns a CMYK tuple of the specified color.
 PyDoc_STRVAR (scribus_getcolorasrgb__doc__, QT_TR_NOOP("getColorAsRGB(\"name\") -> tuple\n\ \n\ Returns a tuple (R,G,B) containing the three color components of the\n\ color \"name\" from the current document, converted to the RGB color\n\ space. If no document is open, returns the value of the named color\n\ from the default document colors.\n\ \n\ May raise NotFoundError if the named color wasn't found.\n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_getcolorasrgb (PyObject *, PyObject *args)
 Returns a CMYK tuple of the specified color.
 PyDoc_STRVAR (scribus_setcolor__doc__, QT_TR_NOOP("changeColor(\"name\", c, m, y, k)\n\ \n\ Changes the color \"name\" to the specified CMYK value. The color value is\n\ defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\ Color components should be in the range from 0 to 255.\n\ \n\ May raise NotFoundError if the named color wasn't found.\n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_setcolor (PyObject *, PyObject *args)
 Sets named color with C,M,Y,K params.
 PyDoc_STRVAR (scribus_newcolor__doc__, QT_TR_NOOP("defineColor(\"name\", c, m, y, k)\n\ \n\ Defines a new color \"name\". The color Value is defined via four components:\n\ c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in\n\ the range from 0 to 255.\n\ \n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_newcolor (PyObject *, PyObject *args)
 Creates new color with name, C, M, Y, K params.
 PyDoc_STRVAR (scribus_delcolor__doc__, QT_TR_NOOP("deleteColor(\"name\", \"replace\")\n\ \n\ Deletes the color \"name\". Every occurence of that color is replaced by the\n\ color \"replace\". If not specified, \"replace\" defaults to the color\n\ \"None\" - transparent.\n\ \n\ deleteColor works on the default document colors if there is no document open.\n\ In that case, \"replace\", if specified, has no effect.\n\ \n\ May raise NotFoundError if a named color wasn't found.\n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_delcolor (PyObject *, PyObject *args)
 Deletes named color.
 PyDoc_STRVAR (scribus_replcolor__doc__, QT_TR_NOOP("replaceColor(\"name\", \"replace\")\n\ \n\ Every occurence of the color \"name\" is replaced by the color \"replace\".\n\ \n\ May raise NotFoundError if a named color wasn't found.\n\ May raise ValueError if an invalid color name is specified.\n\ "))
 docstring
PyObject * scribus_replcolor (PyObject *, PyObject *args)
 Replaces color with the 2nd one.

Function Documentation

PyDoc_STRVAR ( scribus_colornames__doc__  ,
QT_TR_NOOP("getColorNames() -> list\n\\n\Returns a list containing the names of all defined colors in the document.\n\If no document is open, returns a list of the default document colors.\n\")   
)

Managing Colors.

docstring

PyDoc_STRVAR ( scribus_getcolor__doc__  ,
QT_TR_NOOP("getColor(\"name\") -> tuple\n\\n\Returns a tuple (C, M, Y, K) containing the four color components of the\n\color \"name\" from the current document. If no document is open, returns\n\the value of the named color from the default document colors.\n\\n\May raise NotFoundError if the named color wasn't found.\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyDoc_STRVAR ( scribus_getcolorasrgb__doc__  ,
QT_TR_NOOP("getColorAsRGB(\"name\") -> tuple\n\\n\Returns a tuple (R,G,B) containing the three color components of the\n\color \"name\" from the current document, converted to the RGB color\n\space. If no document is open, returns the value of the named color\n\from the default document colors.\n\\n\May raise NotFoundError if the named color wasn't found.\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyDoc_STRVAR ( scribus_setcolor__doc__  ,
QT_TR_NOOP("changeColor(\"name\", c, m, y, k)\n\\n\Changes the color \"name\" to the specified CMYK value. The color value is\n\defined via four components c = Cyan, m = Magenta, y = Yellow and k = Black.\n\Color components should be in the range from 0 to 255.\n\\n\May raise NotFoundError if the named color wasn't found.\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyDoc_STRVAR ( scribus_newcolor__doc__  ,
QT_TR_NOOP("defineColor(\"name\", c, m, y, k)\n\\n\Defines a new color \"name\". The color Value is defined via four components:\n\c = Cyan, m = Magenta, y = Yellow and k = Black. Color components should be in\n\the range from 0 to 255.\n\\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyDoc_STRVAR ( scribus_delcolor__doc__  ,
QT_TR_NOOP("deleteColor(\"name\", \"replace\")\n\\n\Deletes the color \"name\". Every occurence of that color is replaced by the\n\color \"replace\". If not specified, \"replace\" defaults to the color\n\\"None\" - transparent.\n\\n\deleteColor works on the default document colors if there is no document open.\n\In that case, \"replace\", if specified, has no effect.\n\\n\May raise NotFoundError if a named color wasn't found.\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyDoc_STRVAR ( scribus_replcolor__doc__  ,
QT_TR_NOOP("replaceColor(\"name\", \"replace\")\n\\n\Every occurence of the color \"name\" is replaced by the color \"replace\".\n\\n\May raise NotFoundError if a named color wasn't found.\n\May raise ValueError if an invalid color name is specified.\n\")   
)

docstring

PyObject* scribus_colornames ( PyObject *  )

Returns a list with colours available in doc or in prefs.

Definition at line 14 of file cmdcolor.cpp.

{
       ColorList edc;
       PyObject *l;
       int cc = 0;
       edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance()->colorSet();
       ColorList::Iterator it;
       l = PyList_New(edc.count());
       for (it = edc.begin(); it != edc.end(); ++it)
       {
              PyList_SetItem(l, cc, PyString_FromString(it.key().utf8()));
              cc++;
       }
       return l;
}

Here is the call graph for this function:

PyObject* scribus_delcolor ( PyObject *  ,
PyObject *  args 
)

Deletes named color.

Definition at line 151 of file cmdcolor.cpp.

{
       char *Name = const_cast<char*>("");
       char *Repl = const_cast<char*>(CommonStrings::None.latin1());
       if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Name, "utf-8", &Repl))
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot delete a color with an empty name.","python error"));
              return NULL;
       }
       QString col = QString::fromUtf8(Name);
       QString rep = QString::fromUtf8(Repl);
       if (ScCore->primaryMainWindow()->HaveDoc)
       {
              if (ScCore->primaryMainWindow()->doc->PageColors.contains(col) && (ScCore->primaryMainWindow()->doc->PageColors.contains(rep) || (rep == CommonStrings::None)))
                     {
                            ScCore->primaryMainWindow()->doc->PageColors.remove(col);
                            ReplaceColor(col, rep);
                     }
              else
              {
                     PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error"));
                     return NULL;
              }
       }
       else
       {
              ColorList* colorList=PrefsManager::instance()->colorSetPtr();
              if (colorList->contains(col))
                     colorList->remove(col);
              else
              {
                     PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error"));
                     return NULL;
              }
       }
//     Py_INCREF(Py_None);
//     return Py_None;
       Py_RETURN_NONE;
}

Here is the call graph for this function:

PyObject* scribus_getcolor ( PyObject *  ,
PyObject *  args 
)

Returns a CMYK tuple of the specified color.

Definition at line 30 of file cmdcolor.cpp.

{
       ColorList edc;
       char *Name = const_cast<char*>("");
       int c, m, y, k;
       if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error"));
              return NULL;
       }
       edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance()->colorSet();
       ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : NULL;
       QString col = QString::fromUtf8(Name);
       if (!edc.contains(col))
       {
              PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error"));
              return NULL;
       }
       CMYKColor cmykValues;
       ScColorEngine::getCMYKValues(edc[col], currentDoc, cmykValues);
       cmykValues.getValues(c, m, y, k);
       return Py_BuildValue("(iiii)", static_cast<long>(c), static_cast<long>(m), static_cast<long>(y), static_cast<long>(k));
}

Here is the call graph for this function:

PyObject* scribus_getcolorasrgb ( PyObject *  ,
PyObject *  args 
)

Returns a CMYK tuple of the specified color.

Definition at line 56 of file cmdcolor.cpp.

{
       ColorList edc;
       char *Name = const_cast<char*>("");
       if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot get a color with an empty name.","python error"));
              return NULL;
       }
       edc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc->PageColors : PrefsManager::instance()->colorSet();
       ScribusDoc* currentDoc = ScCore->primaryMainWindow()->HaveDoc ? ScCore->primaryMainWindow()->doc : NULL;
       QString col = QString::fromUtf8(Name);
       if (!edc.contains(col))
       {
              PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error"));
              return NULL;
       }
       QColor rgb = ScColorEngine::getRGBColor(edc[col], currentDoc);
       return Py_BuildValue("(iii)", static_cast<long>(rgb.red()), static_cast<long>(rgb.green()), static_cast<long>(rgb.blue()));
}

Here is the call graph for this function:

PyObject* scribus_newcolor ( PyObject *  ,
PyObject *  args 
)

Creates new color with name, C, M, Y, K params.

Definition at line 115 of file cmdcolor.cpp.

{
       char *Name = const_cast<char*>("");
       int c, m, y, k;
       if (!PyArg_ParseTuple(args, "esiiii", "utf-8", &Name, &c, &m, &y, &k))
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create a color with an empty name.","python error"));
              return NULL;
       }
       QString col = QString::fromUtf8(Name);
       if (ScCore->primaryMainWindow()->HaveDoc)
              {
                     if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
                            ScCore->primaryMainWindow()->doc->PageColors.insert(col, ScColor(c, m, y, k));
                     else
                            // FIXME: Given that we have a changeColour function, should we really be
                            // silently changing colours in newColour?
                            ScCore->primaryMainWindow()->doc->PageColors[col].setColor(c, m, y, k);
              }
       else
              {
                     ColorList* colorList=PrefsManager::instance()->colorSetPtr();
                     if (!colorList->contains(col))
                            colorList->insert(col, ScColor(c, m, y, k));
                     else
                            // FIXME: Given that we have a changeColour function, should we really be
                            // silently changing colours in newColour?
                            (*colorList)[col].setColor(c, m, y, k);
              }
 //    Py_INCREF(Py_None);
 //    return Py_None;
       Py_RETURN_NONE;
}

Here is the call graph for this function:

PyObject* scribus_replcolor ( PyObject *  ,
PyObject *  args 
)

Replaces color with the 2nd one.

Definition at line 193 of file cmdcolor.cpp.

{
       char *Name = const_cast<char*>("");
       char *Repl = const_cast<char*>(CommonStrings::None.latin1());
       //FIXME: this should definitely use keyword arguments
       if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Name, "utf-8", &Repl))
              return NULL;
       if(!checkHaveDocument())
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot replace a color with an empty name.","python error"));
              return NULL;
       }
       QString col = QString::fromUtf8(Name);
       QString rep = QString::fromUtf8(Repl);
       if (ScCore->primaryMainWindow()->doc->PageColors.contains(col) && (ScCore->primaryMainWindow()->doc->PageColors.contains(rep) || (rep == CommonStrings::None)))
              ReplaceColor(col, rep);
       else
       {
              PyErr_SetString(NotFoundError, QObject::tr("Color not found.","python error"));
              return NULL;
       }
//     Py_INCREF(Py_None);
//     return Py_None;
       Py_RETURN_NONE;
}

Here is the call graph for this function:

PyObject* scribus_setcolor ( PyObject *  ,
PyObject *  args 
)

Sets named color with C,M,Y,K params.

Definition at line 79 of file cmdcolor.cpp.

{
       char *Name = const_cast<char*>("");
       int c, m, y, k;
       if (!PyArg_ParseTuple(args, "esiiii", "utf-8", &Name, &c, &m, &y, &k))
              return NULL;
       if (strcmp(Name, "") == 0)
       {
              PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot change a color with an empty name.","python error"));
              return NULL;
       }
       QString col = QString::fromUtf8(Name);
       if (ScCore->primaryMainWindow()->HaveDoc)
       {
              if (!ScCore->primaryMainWindow()->doc->PageColors.contains(col))
              {
                     PyErr_SetString(NotFoundError, QObject::tr("Color not found in document.","python error"));
                     return NULL;
              }
              ScCore->primaryMainWindow()->doc->PageColors[col].setColor(c, m, y, k);
       }
       else
       {
              ColorList* colorList=PrefsManager::instance()->colorSetPtr();
              if (!colorList->contains(col))
              {
                     PyErr_SetString(NotFoundError, QObject::tr("Color not found in default colors.","python error"));
                     return NULL;
              }
              (*colorList)[col].setColor(c, m, y, k);
       }
//     Py_INCREF(Py_None);
//     return Py_None;
       Py_RETURN_NONE;
}

Here is the call graph for this function: