Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pageitem_line.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 /***************************************************************************
00008                           pageitem.cpp  -  description
00009                              -------------------
00010     begin                : Sat Apr 7 2001
00011     copyright            : (C) 2001 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include "pageitem_line.h"
00025 #include "pageitem_line.moc"
00026 #include <qpainter.h>
00027 #include <qpen.h>
00028 #include <qfont.h>
00029 #include <qregion.h>
00030 #include <qpoint.h>
00031 #include <qfileinfo.h>
00032 #include <qdrawutil.h>
00033 #include <qbitmap.h>
00034 #include <qregexp.h>
00035 #include <qmessagebox.h>
00036 #include <cmath>
00037 #include <cassert>
00038 
00039 #include "mpalette.h"
00040 #include "page.h"
00041 #include "pageitem.h"
00042 #include "prefsmanager.h"
00043 #include "scpaths.h"
00044 #include "scribus.h"
00045 #include "scribusstructs.h"
00046 #include "scribusdoc.h"
00047 #include "commonstrings.h"
00048 
00049 #include "undomanager.h"
00050 #include "undostate.h"
00051 #include "scconfig.h"
00052 
00053 #include "util.h"
00054 
00055 using namespace std;
00056 
00057 PageItem_Line::PageItem_Line(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline)
00058        : PageItem(pa, PageItem::Line, x, y, w, h, w2, fill, outline)
00059 {
00060 }
00061 
00062 void PageItem_Line::DrawObj_Item(ScPainter *p, QRect /*e*/, double /*sc*/)
00063 {
00064        if (!m_Doc->RePos)
00065        {
00066               if (m_Doc->layerOutline(LayerNr))
00067                      p->drawLine(FPoint(0, 0), FPoint(Width, 0));
00068               else
00069               {
00070                      if (NamedLStyle.isEmpty())
00071                             p->drawLine(FPoint(0, 0), FPoint(Width, 0));
00072                      else
00073                      {
00074                             multiLine ml = m_Doc->MLineStyles[NamedLStyle];
00075                             QColor tmp;
00076                             for (int it = ml.size()-1; it > -1; it--)
00077                             {
00078                                    if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
00079                                    {
00080                                           SetFarbe(&tmp, ml[it].Color, ml[it].Shade);
00081                                           p->setPen(tmp, ml[it].Width, static_cast<PenStyle>(ml[it].Dash), static_cast<PenCapStyle>(ml[it].LineEnd), static_cast<PenJoinStyle>(ml[it].LineJoin));
00082                                           p->drawLine(FPoint(0, 0), FPoint(Width, 0));
00083                                    }
00084                             }
00085                      }
00086               }
00087               if (m_startArrowIndex != 0)
00088               {
00089                      QWMatrix arrowTrans;
00090                      FPointArray arrow = (*m_Doc->arrowStyles.at(m_startArrowIndex-1)).points.copy();
00091                      arrowTrans.translate(0, 0);
00092                      arrowTrans.scale(m_lineWidth, m_lineWidth);
00093                      arrowTrans.scale(-1,1);
00094                      arrow.map(arrowTrans);
00095                      p->setupPolygon(&arrow);
00096                      if (m_Doc->layerOutline(LayerNr))
00097                             p->strokePath();
00098                      else
00099                      {
00100                             p->setBrush(p->pen());
00101                             p->setBrushOpacity(1.0 - lineTransparency());
00102                             p->setLineWidth(0);
00103                             p->setFillMode(ScPainter::Solid);
00104                             p->fillPath();
00105                      }
00106               }
00107               if (m_endArrowIndex != 0)
00108               {
00109                      QWMatrix arrowTrans;
00110                      FPointArray arrow = (*m_Doc->arrowStyles.at(m_endArrowIndex-1)).points.copy();
00111                      arrowTrans.translate(Width, 0);
00112                      arrowTrans.scale(m_lineWidth, m_lineWidth);
00113                      arrow.map(arrowTrans);
00114                      p->setupPolygon(&arrow);
00115                      if (m_Doc->layerOutline(LayerNr))
00116                             p->strokePath();
00117                      else
00118                      {
00119                             p->setBrush(p->pen());
00120                             p->setBrushOpacity(1.0 - lineTransparency());
00121                             p->setLineWidth(0);
00122                             p->setFillMode(ScPainter::Solid);
00123                             p->fillPath();
00124                      }
00125               }
00126        }
00127 }
00128