Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 3672 → Rev 3673

/branches/Version13x/Scribus/scribus/scribusdoc.cpp
2676,15 → 2676,84
return -1.0;
}
 
PageItem* ScribusDoc::convertToImageFrame(PageItem *currItem)
PageItem* ScribusDoc::convertItemTo(PageItem *currItem, PageItem::ItemType newType)
{
Q_ASSERT(currItem!=NULL);
if (currItem==NULL)
return false;
if (currItem->itemType()==PageItem::Line || newType==PageItem::Line)
return false;
 
PageItem *oldItem = Items.take(currItem->ItemNr);
PageItem *newItem = new PageItem_ImageFrame(*oldItem);
PageItem *newItem;
switch (newType)
{
case PageItem::ImageFrame:
newItem = new PageItem_ImageFrame(*oldItem);
break;
case PageItem::TextFrame:
newItem = new PageItem_TextFrame(*oldItem);
break;
//We dont allow this
//case PageItem::Line:
// newItem = new PageItem_Line(*oldItem);
// break;
case PageItem::Polygon:
newItem = new PageItem_Polygon(*oldItem);
break;
case PageItem::PolyLine:
newItem = new PageItem_PolyLine(*oldItem);
break;
case PageItem::PathText:
newItem = new PageItem_PathText(*oldItem);
break;
default:
newItem=NULL;
break;
}
Q_ASSERT(newItem!=NULL);
if (newItem==NULL)
return false;
newItem->convertTo(PageItem::ImageFrame);
newItem->Frame = true;
return false;
switch (newType)
{
case PageItem::ImageFrame:
newItem->convertTo(PageItem::ImageFrame);
newItem->Frame = true;
break;
case PageItem::TextFrame:
newItem->convertTo(PageItem::TextFrame);
newItem->Frame = true;
break;
//We dont allow this
//case PageItem::Line:
// newItem->convertTo(PageItem::Line);
// break;
case PageItem::Polygon:
newItem->convertTo(PageItem::Polygon);
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->FrameType = 3;
newItem->Clip = FlattenPath(newItem->PoLine, newItem->Segments);
newItem->ContourLine = newItem->PoLine.copy();
break;
case PageItem::PolyLine:
newItem->convertTo(PageItem::PolyLine);
newItem->ClipEdited = true;
ScApp->view->SetPolyClip(newItem, qRound(QMAX(newItem->Pwidth / 2, 1)));
ScApp->view->AdjustItemSize(newItem);
break;
case PageItem::PathText:
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->convertTo(PageItem::PathText);
break;
default:
newItem=NULL;
break;
}
Items.append(newItem);
newItem->ItemNr = Items.count()-1;
//<<At some point we HAVE to stop this!
/branches/Version13x/Scribus/scribus/scribusview.h
174,7 → 174,7
void ToView(QPainter *p);
void RefreshItem(PageItem *currItem);
bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
void MoveItemI(double newX, double newY, int ite, bool redraw = true);
void MoveItemI(PageItem* currItem, double newX, double newY, bool redraw = true);
void UpdateClip(PageItem *currItem);
void SetPolyClip(PageItem *currItem, int up);
void ConvertClip(PageItem *currItem);
188,7 → 188,7
void ResetControl();
void MoveClipPoint(PageItem *currItem, FPoint np);
bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP, bool DoUpdateClip, bool redraw);
bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
void moveGroup(double x, double y, bool fromMP = false);
void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false);
/branches/Version13x/Scribus/scribus/scribusdoc.h
375,7 → 375,7
/**
* @brief Item type conversion functions
*/
PageItem* convertToImageFrame(PageItem *);
PageItem* convertItemTo(PageItem *, PageItem::ItemType);
/**
* @brief The page number of the current page
/branches/Version13x/Scribus/scribus/scribusview.cpp
2128,9 → 2128,9
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
}
else
{
2212,9 → 2212,9
MoveSizeItem(npx, npx, currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr);
MoveItemI(currItem, (currItem->Width - currItem->OldB2)/currItem->LocalScX, 0);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr);
MoveItemI(currItem, 0, (currItem->Height - currItem->OldH2)/currItem->LocalScY);
}
else
{
2301,9 → 2301,9
MoveSizeItem(FPoint(0, npx.y()), FPoint(currItem->Width - npx.x(), npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
break;
case 4:
if (currItem->isTableItem)
2361,9 → 2361,9
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), currItem->Height - npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, (currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
break;
case 5:
if (currItem->isTableItem)
2397,7 → 2397,7
else
MoveSizeItem(FPoint(0, 0), FPoint(0, currItem->Height - npx.y()), currItem->ItemNr);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
currItem->Sizing = false;
break;
case 6:
2432,7 → 2432,7
else
MoveSizeItem(FPoint(0, 0), FPoint(currItem->Width - npx.x(), 0), currItem->ItemNr);
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
currItem->Sizing = false;
break;
case 7:
2467,9 → 2467,9
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, (currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
break;
case 8:
if (currItem->isTableItem)
2503,9 → 2503,9
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
break;
}
//TextFrame resize - Resize text with resize of frame
3152,7 → 3152,7
{
if (currItem->asImageFrame())
{
MoveItemI((newX-Mxp)/currItem->LocalScX, (newY-Myp)/currItem->LocalScY, currItem->ItemNr);
MoveItemI(currItem, (newX-Mxp)/currItem->LocalScX, (newY-Myp)/currItem->LocalScY);
Mxp = newX;
Myp = newY;
}
3516,7 → 3516,7
{
currItem = SelItem.at(0);
if ((currItem->asImageFrame()) && (m->state() & (ControlButton | AltButton)))
MoveItemI((newX-Mxp)/currItem->LocalScX, (newY-Myp)/currItem->LocalScY, currItem->ItemNr);
MoveItemI(currItem, (newX-Mxp)/currItem->LocalScX, (newY-Myp)/currItem->LocalScY);
else
{
if (!(currItem->isTableItem && currItem->isSingleSel))
5091,9 → 5091,9
return retw;
}
 
void ScribusView::MoveItemI(double newX, double newY, int ite, bool redraw)
void ScribusView::MoveItemI(PageItem* currItem, double newX, double newY, bool redraw)
{
PageItem *currItem = Doc->Items.at(ite);
//PageItem *currItem = Doc->Items.at(ite);
if ((currItem->locked()) || (!currItem->ScaleType))
return;
if (currItem->imageFlippedH())
5855,7 → 5855,7
MoveItem(np.x(), 0, currItem);
Clip.translate(-np.x(), 0);
if (!currItem->imageFlippedH())
MoveItemI(-np.x()/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -np.x()/currItem->LocalScX, 0, false);
np.setX(0);
}
if ((np.y() < 0) && (!EditContour))
5870,7 → 5870,7
MoveItem(0, np.y(), currItem);
Clip.translate(0, -np.y());
if (!currItem->imageFlippedV())
MoveItemI(0, -np.y()/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -np.y()/currItem->LocalScY, false);
np.setY(0);
}
emit ClipPo(np.x(), np.y());
6064,16 → 6064,16
if (fromMP)
{
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
}
else
{
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, (currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, false);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, false);
}
UpdateClip(currItem);
}
6495,7 → 6495,8
FPointArray Clip;
Clip = currItem->PoLine;
FPoint tp2 = getMinClipF(&Clip);
SizeItem(currItem->Width - tp2.x(), currItem->Height - tp2.y(), currItem->ItemNr, true, false, false);
//SizeItem(currItem->Width - tp2.x(), currItem->Height - tp2.y(), currItem->ItemNr, true, false, false);
SizeItem(currItem->Width - tp2.x(), currItem->Height - tp2.y(), currItem, true, false, false);
Clip.translate(-tp2.x(), -tp2.y());
if (currItem->Rot != 0)
{
6505,15 → 6506,15
else
MoveItem(tp2.x(), tp2.y(), currItem, true);
if (!currItem->imageFlippedH())
MoveItemI(-tp2.x()/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, -tp2.x()/currItem->LocalScX, 0, false);
if (!currItem->imageFlippedV())
MoveItemI(0, -tp2.y()/currItem->LocalScY, currItem->ItemNr, false);
MoveItemI(currItem, 0, -tp2.y()/currItem->LocalScY, false);
FPoint tp = getMaxClipF(&Clip);
if (currItem->imageFlippedH())
MoveItemI((currItem->Width - tp.x())/currItem->LocalScX, 0, currItem->ItemNr, false);
MoveItemI(currItem, (currItem->Width - tp.x())/currItem->LocalScX, 0, false);
if (currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - tp.y())/currItem->LocalScY, currItem->ItemNr, false);
SizeItem(tp.x(), tp.y(), currItem->ItemNr, true, false);
MoveItemI(currItem, 0, (currItem->Height - tp.y())/currItem->LocalScY, false);
SizeItem(tp.x(), tp.y(), currItem, true, false);
currItem->ClipEdited = true;
currItem->PoLine = Clip.copy();
if (currItem->asPolyLine())
8255,11 → 8256,11
 
void ScribusView::ToPicFrame()
{
//emit Amode(1);
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertToImageFrame(currItem);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::ImageFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
8270,45 → 8271,42
void ScribusView::ToPolyFrame()
{
PageItem *currItem = new PageItem_Polygon(*SelItem.at(0));
currItem->convertTo(PageItem::Polygon);
currItem->Frame = false;
currItem->ClipEdited = true;
currItem->FrameType = 3;
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
currItem->ContourLine = currItem->PoLine.copy();
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::Polygon);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), currItem->ItemNr);
EmitValues(currItem);
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToTextFrame()
{
PageItem *currItem = new PageItem_TextFrame(*SelItem.at(0));
currItem->convertTo(PageItem::TextFrame);
currItem->Frame = true;
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::TextFrame);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), currItem->ItemNr);
EmitValues(currItem);
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
void ScribusView::ToBezierFrame()
{
PageItem *currItem = new PageItem_PolyLine(*SelItem.at(0));
currItem->convertTo(PageItem::PolyLine);
currItem->ClipEdited = true;
SetPolyClip(currItem, qRound(QMAX(currItem->Pwidth / 2, 1)));
AdjustItemSize(currItem);
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
PageItem *currItem = SelItem.at(0);
Deselect(true);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PolyLine);
RefreshItem(newItem);
SelectItem(newItem);
emit HaveSel(newItem->itemType());
if (!Doc->isLoading())
emit UpdtObj(Doc->currentPage->pageNr(), currItem->ItemNr);
EmitValues(currItem);
emit UpdtObj(Doc->currentPage->pageNr(), newItem->ItemNr);
EmitValues(newItem);
emit DocChanged();
}
 
8315,6 → 8313,7
void ScribusView::Bezier2Poly()
{
PageItem *currItem = SelItem.at(0);
currItem->convertTo(PageItem::Polygon);
currItem->Frame = false;
currItem->ClipEdited = true;
8325,6 → 8324,7
currItem->PoLine.addPoint(currItem->PoLine.point(0));
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
currItem->ContourLine = currItem->PoLine.copy();
RefreshItem(currItem);
emit HaveSel(currItem->itemType());
if (!Doc->isLoading())
11398,35 → 11398,34
{
if (SelItem.count() > 1)
{
PageItem *currItem = new PageItem_PathText(*SelItem.at(0));
PageItem* oldItem=SelItem.at(0);
PageItem *bb;
if (currItem->asTextFrame())
if (oldItem->asTextFrame())
bb = SelItem.at(1);
else
{
bb = SelItem.at(0);
currItem = SelItem.at(1);
oldItem = SelItem.at(1);
}
if (!bb->asPolyLine())
return;
currItem->Frame = false;
currItem->ClipEdited = true;
currItem->convertTo(PageItem::PathText);
currItem->PoLine = bb->PoLine.copy();
currItem->Pwidth = bb->Pwidth;
currItem->setLineColor(bb->lineColor());
currItem->PLineArt = bb->PLineArt;
currItem->PLineEnd = bb->PLineEnd;
currItem->PLineJoin = bb->PLineJoin;
PageItem* currItem = new PageItem_PathText(*oldItem);
PageItem* newItem=Doc->convertItemTo(currItem, PageItem::PathText);
newItem->PoLine = bb->PoLine.copy();
newItem->Pwidth = bb->Pwidth;
newItem->setLineColor(bb->lineColor());
newItem->PLineArt = bb->PLineArt;
newItem->PLineEnd = bb->PLineEnd;
newItem->PLineJoin = bb->PLineJoin;
/* if (!Doc->loading)
emit UpdtObj(Doc->currentPage->pageNr(), b->ItemNr); */
UpdatePolyClip(currItem);
AdjustItemSize(currItem);
double dx = bb->Xpos - currItem->Xpos;
double dy = bb->Ypos - currItem->Ypos;
MoveItem(dx, dy, currItem);
currItem->Rot = bb->Rot;
currItem->FrameType = 3;
UpdatePolyClip(newItem);
AdjustItemSize(newItem);
double dx = bb->Xpos - newItem->Xpos;
double dy = bb->Ypos - newItem->Ypos;
MoveItem(dx, dy, newItem);
newItem->Rot = bb->Rot;
newItem->FrameType = 3;
Deselect(true);
SelectItemNr(bb->ItemNr);
DeleteItem();
/branches/Version13x/Scribus/scribus/scribus.cpp
1538,11 → 1538,11
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(-10, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, -10, 0, true);
else if ( buttonState & ControlButton )
view->MoveItemI(-0.1, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, -0.1, 0, true);
else
view->MoveItemI(-1, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, -1, 0, true);
}
break;
case Key_Right:
1549,11 → 1549,11
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(10, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, 10, 0, true);
else if ( buttonState & ControlButton )
view->MoveItemI(0.1, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, 0.1, 0, true);
else
view->MoveItemI(1, 0, currItem->ItemNr, true);
view->MoveItemI(currItem, 1, 0, true);
}
break;
case Key_Up: