Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scripter2_scribus_pageitem.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "cmdvar.h"
00008 
00009 
00010 
00011 #include "scribus.h"
00012 #include "scribusdoc.h"
00013 #include "pageitem.h"
00014 
00015 using boost::python::list;
00016 using boost::python::throw_error_already_set;
00017 
00018 PageItem & findItemByName(QPtrList<PageItem> & items, const QString name)
00019 {
00020        for (
00021               QPtrList<PageItem>::iterator it(items.begin()) ;
00022               it != items.end() ;
00023               ++it)
00024        {
00025               if ( (*it)->itemName() == name)
00026                      return *(*it);
00027        }
00028        PyErr_SetString(PyExc_KeyError, "Item not found");
00029        throw_error_already_set();
00030 }
00031 
00032 PageItem & getItem(const QString name)
00033 {
00034        return findItemByName(ScCore->primaryMainWindow()->doc->DocItems, name);
00035 }
00036 
00037 list getItemNames()
00038 {
00039        list l;
00040        QPtrList<PageItem>& items( ScCore->primaryMainWindow()->doc->DocItems );
00041        for (
00042               QPtrList<PageItem>::iterator it(items.begin()) ;
00043               it != items.end() ;
00044               ++it)
00045        {
00046               l.append((*it)->itemName());
00047        }
00048        return l;
00049 }
00050 
00051 void export_PageItem()
00052 {
00053        using namespace boost::python;
00054 
00055        def("getItemNames", getItemNames);
00056        def("getItem", getItem, return_internal_reference<>());
00057 
00058        {
00059               scope p = class_<PageItem,boost::noncopyable>(
00060                             "PageItem",
00061                             "A Scribus canvas object",
00062                             no_init)
00063                      .def("clearContents", &PageItem::clearContents)
00064                      .def("AdjustPictScale", &PageItem::AdjustPictScale)
00065                      //TODO Needs: ObjAttrVector, Problem: pointer return
00066                      //.def("getObjectAttributes", &PageItem::getObjectAttributes,
00067                      //TODO Needs: ObjectAttribute
00068                      .def("getObjectAttribute", &PageItem::getObjectAttribute)
00069                      .def("setObjectAttributes", &PageItem::setObjectAttributes)
00070                      .def("SetFrameShape", &PageItem::SetFrameShape)
00071                      .def("SetRectFrame", &PageItem::SetRectFrame)
00072                      .def("SetOvalFrame", &PageItem::SetOvalFrame)
00073                      .def("SetFrameRound", &PageItem::SetFrameRound)
00074                      .def("SetPolyClip", &PageItem::SetPolyClip)
00075                      .def("getBoundingRect", &PageItem::getBoundingRect)
00076                      .def("pointWithinItem", &PageItem::pointWithinItem)
00077                      //.def("SetZeichAttr", &PageItem::SetZeichAttr) // WTF?
00078                      .def("SetFarbe", &PageItem::SetFarbe)
00079                      .def_readwrite("AspectRatio", &PageItem::AspectRatio)
00080                      .def_readwrite("AutoName", &PageItem::AutoName)  
00081                      .def_readwrite("BottomLine", &PageItem::BottomLine)
00082                      .def_readwrite("ChangedMasterItem", &PageItem::ChangedMasterItem)
00083                      .def_readwrite("ClipEdited", &PageItem::ClipEdited)
00084                      .def_readwrite("Dirty", &PageItem::Dirty)
00085                      .def_readwrite("fillRule", &PageItem::fillRule)
00086                      .def_readwrite("Frame", &PageItem::Frame)
00087                      .def_readwrite("FrameOnly", &PageItem::FrameOnly)
00088                      .def_readwrite("HasSel", &PageItem::HasSel)
00089                      .def_readwrite("isAutoText", &PageItem::isAutoText)
00090                      .def_readwrite("isBookmark", &PageItem::isBookmark)
00091                      .def_readwrite("isEmbedded", &PageItem::isEmbedded)
00092                      .def_readwrite("isRaster", &PageItem::isRaster)
00093                      .def_readwrite("isSingleSel", &PageItem::isSingleSel)
00094                      .def_readwrite("isTableItem", &PageItem::isTableItem)
00095                      .def_readwrite("LeftLine", &PageItem::LeftLine)
00096                      .def_readwrite("PicArt", &PageItem::PicArt)
00097                      .def_readwrite("PicAvail", &PageItem::PicAvail)
00098                      .def_readwrite("PoShow", &PageItem::PoShow)
00099                      .def_readwrite("Redrawn", &PageItem::Redrawn)
00100                      .def_readwrite("RightLine", &PageItem::RightLine)
00101                      .def_readwrite("ScaleType", &PageItem::ScaleType)
00102                      .def_readwrite("Sizing", &PageItem::Sizing)
00103                      .def_readwrite("Tinput", &PageItem::Tinput)
00104                      .def_readwrite("toPixmap", &PageItem::toPixmap)
00105                      .def_readwrite("TopLine", &PageItem::TopLine)
00106                      .def_readwrite("UseEmbedded", &PageItem::UseEmbedded)
00107                      .def_readwrite("BaseOffs", &PageItem::BaseOffs)
00108                      .def_readwrite("BBoxH", &PageItem::BBoxH)
00109                      .def_readwrite("BBoxX", &PageItem::BBoxX)
00110                      .def_readwrite("BoundingH", &PageItem::BoundingH)
00111                      .def_readwrite("BoundingW", &PageItem::BoundingW)
00112                      .def_readwrite("BoundingX", &PageItem::BoundingX)
00113                      .def_readwrite("BoundingY", &PageItem::BoundingY)
00114                      .def_readwrite("ColGap", &PageItem::ColGap)
00115                      .def_readwrite("CurX", &PageItem::CurX)
00116                      .def_readwrite("CurY", &PageItem::CurY)
00117                      .def_readwrite("DashOffset", &PageItem::DashOffset)
00118                      .def_readwrite("gHeight", &PageItem::gHeight)
00119                      .def_readwrite("GrEndX", &PageItem::GrEndX)
00120                      .def_readwrite("GrEndY", &PageItem::GrEndY)
00121                      .def_readwrite("GrStartX", &PageItem::GrStartX)
00122                      .def_readwrite("GrStartY", &PageItem::GrStartY)
00123                      .def_readwrite("gWidth", &PageItem::gWidth)
00124                      .def_readwrite("gXpos", &PageItem::gXpos)
00125                      .def_readwrite("gYpos", &PageItem::gYpos)
00126                      .def_readwrite("LineSp", &PageItem::LineSp)
00127                      .def_readwrite("OldB", &PageItem::OldB)
00128                      .def_readwrite("OldB2", &PageItem::OldB2)
00129                      .def_readwrite("OldH", &PageItem::OldH)
00130                      .def_readwrite("OldH2", &PageItem::OldH2)
00131                      .def_readwrite("OldPwidth", &PageItem::OldPwidth)
00132                      .def_readwrite("Pwidth", &PageItem::Pwidth)
00133                      .def_readwrite("ContourLine", &PageItem::ContourLine)
00134                      .def_readwrite("imageClip", &PageItem::imageClip)
00135                      .def_readwrite("PoLine", &PageItem::PoLine)
00136                      .def_readwrite("BottomLinkID", &PageItem::BottomLinkID)
00137                      .def_readwrite("Cols", &PageItem::Cols)
00138                      .def_readwrite("CPos", &PageItem::CPos)
00139                      .def_readwrite("ExtraV", &PageItem::ExtraV)
00140                      .def_readwrite("FrameType", &PageItem::FrameType)
00141                      .def_readwrite("GrType", &PageItem::GrType)
00142                      .def_readwrite("IRender", &PageItem::IRender)
00143                      .def_readwrite("LayerNr", &PageItem::LayerNr)
00144                      .def_readwrite("LeftLinkID", &PageItem::LeftLinkID)
00145                      .def_readwrite("LineSpMode", &PageItem::LineSpMode)
00146                      .def_readwrite("NextIt", &PageItem::NextIt)
00147                      .def_readwrite("NextPg", &PageItem::NextPg)
00148                      .def_readwrite("oldOwnPage", &PageItem::oldOwnPage)
00149                      .def_readwrite("OrigH", &PageItem::OrigH)
00150                      .def_readwrite("OrigW", &PageItem::OrigW)
00151                      .def_readwrite("OwnPage", &PageItem::OwnPage)
00152                      .def_readwrite("RightLinkID", &PageItem::RightLinkID)
00153                      .def_readwrite("ShTxtFill", &PageItem::ShTxtFill)
00154                      .def_readwrite("ShTxtStroke", &PageItem::ShTxtStroke)
00155                      .def_readwrite("textAlignment", &PageItem::textAlignment)
00156                      .def_readwrite("TopLinkID", &PageItem::TopLinkID)
00157                      .def_readwrite("TxtBase", &PageItem::TxtBase)
00158                      .def_readwrite("TxtOutline", &PageItem::TxtOutline)
00159                      .def_readwrite("TxtScale", &PageItem::TxtScale)
00160                      .def_readwrite("TxtScaleV", &PageItem::TxtScaleV)
00161                      .def_readwrite("TxtShadowX", &PageItem::TxtShadowX)
00162                      .def_readwrite("TxtShadowY", &PageItem::TxtShadowY)
00163                      .def_readwrite("TxtStrikePos", &PageItem::TxtStrikePos)
00164                      .def_readwrite("TxtStrikeWidth", &PageItem::TxtStrikeWidth)
00165                      .def_readwrite("TxTStyle", &PageItem::TxTStyle)
00166                      .def_readwrite("TxtUnderPos", &PageItem::TxtUnderPos)
00167                      .def_readwrite("TxtUnderWidth", &PageItem::TxtUnderWidth)
00168                      .def_readwrite("*BackBox", &PageItem::BackBox)
00169                      .def_readwrite("BottomLink", &PageItem::BottomLink)
00170                      .def_readwrite("LeftLink", &PageItem::LeftLink)
00171                      .def_readwrite("*NextBox", &PageItem::NextBox)
00172                      .def_readwrite("RightLink", &PageItem::RightLink)
00173                      .def_readwrite("TopLink", &PageItem::TopLink)
00174                      .def_readwrite("PLineEnd", &PageItem::PLineEnd)
00175                      .def_readwrite("PLineJoin", &PageItem::PLineJoin)
00176                      .def_readwrite("PLineArt", &PageItem::PLineArt)
00177                      .def_readwrite("Clip", &PageItem::Clip)
00178                      .def_readwrite("itemText", &PageItem::itemText)
00179                      .def_readwrite("EmProfile", &PageItem::EmProfile)
00180                      .def_readwrite("IProfile", &PageItem::IProfile)
00181                      .def_readwrite("Language", &PageItem::Language)
00182                      .def_readwrite("NamedLStyle", &PageItem::NamedLStyle)
00183                      .def_readwrite("OnMasterPage", &PageItem::OnMasterPage)
00184                      .def_readwrite("Pfile", &PageItem::Pfile)
00185                      .def_readwrite("Pfile2", &PageItem::Pfile2)
00186                      .def_readwrite("Pfile3", &PageItem::Pfile3)
00187                      .def_readwrite("TxtFill", &PageItem::TxtFill)
00188                      .def_readwrite("TxtStroke", &PageItem::TxtStroke)
00189                      .def_readwrite("DashValues", &PageItem::DashValues)
00190                      .def_readwrite("effectsInUse", &PageItem::effectsInUse)
00191                      .def_readwrite("TabValues", &PageItem::TabValues)
00192                      .def_readwrite("Segments", &PageItem::Segments)
00193                      .def_readwrite("Groups", &PageItem::Groups)
00194                      .def_readwrite("pixm", &PageItem::pixm)
00195                      .def_readwrite("ItemNr", &PageItem::ItemNr)
00196                      .def_readwrite("MaxChars", &PageItem::MaxChars)
00197                      .def_readwrite("fill_gradient", &PageItem::fill_gradient)
00198                      .add_property("xPos", &PageItem::xPos, &PageItem::setXPos)
00199                      .add_property("yPos", &PageItem::yPos, &PageItem::setYPos)
00200                      .def("moveBy", &PageItem::moveBy)
00201                      .add_property("width", &PageItem::width, &PageItem::setWidth)
00202                      .add_property("height", &PageItem::height, &PageItem::setHeight)
00203                      .def("resizeBy", &PageItem::resizeBy)
00204                      // TODO: Weird error
00205                      //.def("rotation", &PageItem::rotation)
00206                      .def("setRotation", &PageItem::setRotation)
00207                      .def("rotateBy", &PageItem::rotateBy)
00208                      .add_property("selected", &PageItem::isSelected, &PageItem::setSelected)
00209                      .add_property("imageXscale", &PageItem::imageXScale, &PageItem::setImageXScale)
00210                      .add_property("imageYscale", &PageItem::imageYScale, &PageItem::setImageYScale)
00211                      .add_property("imageXOffset", &PageItem::imageXOffset, &PageItem::setImageXOffset)
00212                      .add_property("imageYOffset", &PageItem::imageYOffset, &PageItem::setImageYOffset)
00213                      .def("moveImageXYOffsetBy", &PageItem::moveImageXYOffsetBy)
00214                      .add_property("reversed", &PageItem::reversed, &PageItem::setReversed)
00215                      // TODO: Weird error
00216                      //.def("cornerRadius", &PageItem::cornerRadius)
00217                      .def("setCornerRadius", &PageItem::setCornerRadius)
00218                      .add_property("textToFrameDistLeft", &PageItem::textToFrameDistLeft, &PageItem::setTextToFrameDistLeft)
00219                      .add_property("textToFrameDistRight", &PageItem::textToFrameDistRight, &PageItem::setTextToFrameDistRight)
00220                      .add_property("textToFrameDistTop", &PageItem::textToFrameDistTop, &PageItem::setTextToFrameDistTop)
00221                      .add_property("textToFrameDistBottom", &PageItem::textToFrameDistBottom, &PageItem::setTextToFrameDistBottom)
00222                      .def("setTextToFrameDist", &PageItem::setTextToFrameDist)
00223                      .add_property("itemName", &PageItem::itemName, &PageItem::setItemName)
00224                      .add_property("fillColor", &PageItem::fillColor, &PageItem::setFillColor)
00225                      .add_property("fillShade", &PageItem::fillShade, &PageItem::setFillShade)
00226                      .add_property("fillTransparency", &PageItem::fillTransparency, &PageItem::setFillTransparency)
00227                      .add_property("lineColor", &PageItem::lineColor, &PageItem::setLineColor)
00228                      .add_property("lineShade", &PageItem::lineShade, &PageItem::setLineShade)
00229                      .add_property("lineTransparency", &PageItem::lineTransparency, &PageItem::setLineTransparency)
00230                      .add_property("setLineQColor", &PageItem::setLineQColor, &PageItem::setFillQColor)
00231                      .def("lineStyle", &PageItem::lineStyle)
00232                      // TODO: weird error
00233                      //.def("setLineStyle", &PageItem::setLineStyle)
00234                      // TODO: weird error
00235                      //.def("lineWidth", &PageItem::lineWidth)
00236                      .def("setLineWidth", &PageItem::setLineWidth)
00237                      .add_property("lineEnd", &PageItem::lineEnd, &PageItem::setLineEnd)
00238                      .add_property("lineJoin", &PageItem::lineJoin, &PageItem::setLineJoin)
00239                      .add_property("customLineStyle", &PageItem::customLineStyle, &PageItem::setCustomLineStyle)
00240                      .add_property("startArrowIndex", &PageItem::startArrowIndex, &PageItem::setStartArrowIndex)
00241                      .add_property("endArrowIndex", &PageItem::endArrowIndex, &PageItem::setEndArrowIndex)
00242                      .add_property("imageFlippedH", &PageItem::imageFlippedH, &PageItem::setImageFlippedH)
00243                      .def("flipImageH", &PageItem::flipImageH)
00244                      .add_property("imageFlippedV", &PageItem::imageFlippedV, &PageItem::setImageFlippedV)
00245                      .def("flipImageV", &PageItem::flipImageV)
00246                      .def("setImageScalingMode", &PageItem::setImageScalingMode)
00247                      .def("toggleLock", &PageItem::toggleLock)
00248                      .add_property("locked", &PageItem::locked, &PageItem::setLocked)
00249                      .def("toggleSizeLock", &PageItem::toggleSizeLock)
00250                      .add_property("sizeLocked", &PageItem::sizeLocked, &PageItem::setSizeLocked)
00251                      .add_property("font", &PageItem::font,  &PageItem::setFont)
00252                      .add_property("fontSize", &PageItem::fontSize, &PageItem::setFontSize)
00253                      .add_property("fontHeight", &PageItem::fontHeight, &PageItem::setFontHeight)
00254                      .add_property("fontWidth", &PageItem::fontWidth, &PageItem::setFontWidth)
00255                      .add_property("fontFillColor", &PageItem::fontFillColor, &PageItem::setFontFillColor)
00256                      .add_property("fontFillShade", &PageItem::fontFillShade, &PageItem::setFontFillShade)
00257                      .add_property("fontStrokeColor", &PageItem::fontStrokeColor, &PageItem::setFontStrokeColor)
00258                      .add_property("fontStrokeShade", &PageItem::fontStrokeShade, &PageItem::setFontStrokeShade)
00259                      .add_property("fontEffects", &PageItem::fontEffects, &PageItem::setFontEffects)
00260                      .add_property("kerning", &PageItem::kerning, &PageItem::setKerning)
00261                      // TODO: weird error
00262                      //.def("lineSpacing", &PageItem::lineSpacing)
00263                      .def("setLineSpacing", &PageItem::setLineSpacing)
00264                      .add_property("language", &PageItem::language, &PageItem::setLanguage)
00265                      .add_property("textFlowMode", &PageItem::textFlowMode, &PageItem::setTextFlowMode)
00266                      .def("itemType", &PageItem::itemType)
00267                      .def("convertTo", &PageItem::convertTo)
00268                      .def("setLayer", &PageItem::setLayer)
00269                      .add_property("printable", &PageItem::printable, &PageItem::setPrintable)
00270                      .def("loadImage", &PageItem::loadImage)
00271                      .add_property("isAnnotation", &PageItem::isAnnotation, &PageItem::setIsAnnotation)
00272                      .def("annotation", &PageItem::annotation, return_internal_reference<>());
00273 
00274               enum_<PageItem::ItemType>("ItemType")
00275                      .value("ImageFrame", PageItem::ImageFrame)
00276                      .value("ImageFrame", PageItem::ImageFrame)
00277                      .value("TextFrame", PageItem::TextFrame)
00278                      .value("Line", PageItem::Line)
00279                      .value("Polygon", PageItem::Polygon)
00280                      .value("PolyLine", PageItem::PolyLine)
00281                      .value("PathText", PageItem::PathText)
00282                      .export_values();
00283 
00284               enum_<PageItem::ItemFrameType>("ItemFrameType")
00285                      .value("Unspecified", PageItem::Unspecified)
00286                      .value("Rectangle", PageItem::Rectangle)
00287                      .value("Ellipse", PageItem::Ellipse)
00288                      .value("Round", PageItem::Round)
00289                      .value("Other", PageItem::Other)
00290                      .export_values();
00291 
00292               class_<PageItem::TabRecord>("TabRecord")
00293                      .def_readwrite("tabPosition", &PageItem::TabRecord::tabPosition)
00294                      .def_readwrite("tabType", &PageItem::TabRecord::tabType)
00295                      .add_property("tabFillChar", make_getter(&PageItem::TabRecord::tabFillChar, return_value_policy<return_by_value>()),
00296                                                                        make_setter(&PageItem::TabRecord::tabFillChar, return_value_policy<return_by_value>()));
00297 
00298        } // end scope p
00299 }
00300 
00301