Subversion Repositories Scribus

Rev

Rev 20284 | Rev 20887 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
16546 jghali 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
 
8
#include "propertiespalette_group.h"
9
 
10
#include <QButtonGroup>
11
#include <QCheckBox>
12
#include <QCloseEvent>
13
#include <QComboBox>
14
#include <QEvent>
15
#include <QFocusEvent>
16
#include <QFrame>
17
#include <QGridLayout>
18
#include <QGroupBox>
19
#include <QHBoxLayout>
20
#include <QImage>
21
#include <QKeyEvent>
22
#include <QLabel>
23
#include <QListView>
24
#include <QTransform>
25
#include <QMenu>
26
#include <QMessageBox>
27
#include <QObject>
28
#include <QPixmap>
29
#include <QPoint>
30
#include <QPushButton>
31
#include <QRadioButton>
32
#include <QRegExp>
33
#include <QSpacerItem>
34
#include <QSpinBox>
35
#include <QStackedWidget>
36
#include <QTimer>
37
#include <QToolBox>
38
#include <QToolTip>
39
#include <QVBoxLayout>
40
#include <QValidator>
41
#include <QWidget>
42
 
17539 jghali 43
#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
16546 jghali 44
#define _USE_MATH_DEFINES
45
#endif
46
#include <cmath>
19067 craig 47
 
48
 
20185 craig 49
 
19067 craig 50
#include "appmodes.h"
16546 jghali 51
#include "commonstrings.h"
20185 craig 52
#include "iconmanager.h"
16546 jghali 53
#include "sccombobox.h"
19067 craig 54
#include "scraction.h"
16546 jghali 55
#include "scribuscore.h"
19093 craig 56
#include "scribusdoc.h"
16546 jghali 57
#include "scribusview.h"
58
#include "selection.h"
59
#include "ui/autoform.h"
60
#include "ui/nodeeditpalette.h"
16976 fschmid 61
#include "ui/propertiespalette.h"
16546 jghali 62
#include "ui/propertiespalette_utils.h"
16976 fschmid 63
#include "ui/propertiespalette_xyz.h"
16546 jghali 64
#include "ui/transparencypalette.h"
19067 craig 65
#include "undomanager.h"
66
#include "units.h"
67
#include "util.h"
68
#include "util_math.h"
16546 jghali 69
 
19067 craig 70
 
20185 craig 71
 
16546 jghali 72
PropertiesPalette_Group::PropertiesPalette_Group( QWidget* parent) : QWidget(parent)
73
{
74
        m_ScMW = 0;
75
        m_doc  = 0;
76
        m_haveDoc   = false;
77
        m_haveItem  = false;
78
        m_unitRatio = 1.0;
79
 
80
        m_tmpSelection = new Selection(this, false);
81
        m_tmpSelection->clear();
82
 
83
        setupUi(this);
17383 fschmid 84
        setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
16546 jghali 85
 
20185 craig 86
        textFlowDisabled->setIcon(IconManager::instance()->loadIcon("flow-none.png"));
87
        textFlowUsesFrameShape->setIcon(IconManager::instance()->loadIcon("flow-frame.png"));
88
        textFlowUsesBoundingBox->setIcon(IconManager::instance()->loadIcon("flow-bounding.png"));
89
        textFlowUsesContourLine->setIcon(IconManager::instance()->loadIcon("flow-contour.png"));
90
        textFlowUsesImageClipping->setIcon(IconManager::instance()->loadIcon("flow-contour.png"));
16546 jghali 91
 
92
        textFlowDisabled->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
93
        textFlowUsesFrameShape->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
94
        textFlowUsesBoundingBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
95
        textFlowUsesContourLine->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
96
        textFlowUsesImageClipping->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
97
 
98
        transPalWidget->hideSelectionButtons();
99
 
100
        languageChange();
101
 
102
        connect(textFlowBtnGroup, SIGNAL(buttonClicked(int)), this, SLOT(handleTextFlow()));
103
 
104
        connect(customShape  , SIGNAL(FormSel(int, int, qreal *)), this, SLOT(handleNewShape(int, int, qreal *)));
17388 jghali 105
        connect(editShape    , SIGNAL(clicked())                 , this, SLOT(handleShapeEdit()));
106
        connect(evenOdd      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
107
        connect(nonZero      , SIGNAL(clicked())                 , this, SLOT(handleFillRule()) );
18775 fschmid 108
        connect(clipGroups   , SIGNAL(clicked())                 , this, SLOT(handleClipping()) );
17388 jghali 109
        connect(transPalWidget , SIGNAL(editGradient())          , this, SLOT(handleGradientEdit()));
16546 jghali 110
        connect(transPalWidget , SIGNAL(NewSpecial(double, double, double, double, double, double, double, double, double, double)), this, SLOT(handleSpecialGradient(double, double, double, double, double, double, double, double )));
111
}
112
 
113
PageItem* PropertiesPalette_Group::currentItemFromSelection()
114
{
115
        PageItem *currentItem = NULL;
116
 
117
        if (m_doc)
118
        {
119
                if (m_doc->m_Selection->count() > 1)
120
                {
121
                        currentItem = m_doc->m_Selection->itemAt(0);
122
                }
123
                else if (m_doc->m_Selection->count() == 1)
124
                {
125
                        currentItem = m_doc->m_Selection->itemAt(0);
126
                }
127
        }
128
 
129
        return currentItem;
130
}
131
 
132
void PropertiesPalette_Group::setMainWindow(ScribusMainWindow *mw)
133
{
134
        m_ScMW = mw;
135
 
17388 jghali 136
        connect(this->transPalWidget, SIGNAL(gradientChanged()), this, SLOT(handleGradientChanged()));
16546 jghali 137
        connect(m_ScMW, SIGNAL(UpdateRequest(int)), this, SLOT(handleUpdateRequest(int)));
138
}
139
 
140
void PropertiesPalette_Group::setDoc(ScribusDoc *d)
141
{
142
        if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
143
                return;
144
 
145
        if (m_doc)
146
        {
147
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
148
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
149
        }
150
 
151
        disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0);
152
        disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0);
153
        disconnect(this->transPalWidget, SIGNAL(NewGradient(int)), 0, 0);
154
        disconnect(this->transPalWidget, SIGNAL(NewPattern(QString)), 0, 0);
155
        disconnect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), 0, 0);
156
 
157
        m_doc  = d;
158
        m_item = NULL;
159
        m_unitRatio   = m_doc->unitRatio();
160
        m_unitIndex   = m_doc->unitIndex();
161
 
162
        transPalWidget->setDocument(m_doc);
163
        transPalWidget->setCurrentItem(NULL);
164
 
165
        m_haveDoc  = true;
166
        m_haveItem = false;
167
 
168
        connect(this->transPalWidget, SIGNAL(NewTrans(double))   , this, SLOT(handleGroupTransparency(double)));
169
        connect(this->transPalWidget, SIGNAL(NewBlend(int))      , this, SLOT(handleGroupBlending(int)));
170
        connect(this->transPalWidget, SIGNAL(NewGradient(int))   , this, SLOT(handleGroupGradMask(int)));
171
        connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString)));
172
        connect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), this, SLOT(handleGroupPatternMaskProps(double, double, double, double, double, double, double, bool, bool)));
173
 
174
        connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
175
        connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
176
}
177
 
178
void PropertiesPalette_Group::unsetDoc()
179
{
180
        if (m_doc)
181
        {
182
                disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
183
                disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
184
        }
185
 
186
        m_haveDoc  = false;
187
        m_haveItem = false;
188
        m_doc   = NULL;
189
        m_item  = NULL;
190
 
191
        transPalWidget->setDocument(NULL);
192
        transPalWidget->setCurrentItem(NULL);
193
 
194
        setEnabled(false);
195
}
196
 
197
void PropertiesPalette_Group::unsetItem()
198
{
199
        m_haveItem = false;
200
        m_item     = NULL;
201
        transPalWidget->setCurrentItem(NULL);
202
        handleSelectionChanged();
203
}
204
 
205
void PropertiesPalette_Group::handleSelectionChanged()
206
{
207
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
208
                return;
209
 
210
        PageItem* currItem = currentItemFromSelection();
211
        if (m_doc->m_Selection->count() > 1)
212
        {
213
                bool widgetEnabled = false;
214
                if (m_haveItem && m_item)
215
                {
216
                        if ((m_item->isGroup()) && (!m_item->isSingleSel))
217
                                widgetEnabled = true;
218
                }
219
                setEnabled(widgetEnabled);
220
        }
221
        else
222
        {
223
                int itemType = currItem ? (int) currItem->itemType() : -1;
224
                m_haveItem = (itemType != -1);
225
 
226
                switch (itemType)
227
                {
228
                case -1:
229
                        setEnabled(false);
230
                        break;
231
                case PageItem::ImageFrame:
232
                case PageItem::LatexFrame:
233
                case PageItem::OSGFrame:
234
                        if (currItem->asOSGFrame())
235
                        {
236
                                setEnabled(false);
237
                        }
238
                        break;
239
                case PageItem::Arc:
240
                case PageItem::TextFrame:
241
                case PageItem::Line:
242
                case PageItem::ItemType1:
243
                case PageItem::ItemType3:
244
                case PageItem::Polygon:
245
                case PageItem::PolyLine:
246
                case PageItem::PathText:
247
                case PageItem::RegularPolygon:
248
                        setEnabled(false);
249
                        break;
250
                case PageItem::Symbol:
251
                        setEnabled(true);
252
                        break;
253
                }
254
        }
255
        if (currItem)
256
        {
257
                setCurrentItem(currItem);
258
        }
259
        updateGeometry();
18480 jghali 260
        //repaint();
16546 jghali 261
}
262
 
263
void PropertiesPalette_Group::handleUpdateRequest(int updateFlags)
264
{
265
        if (updateFlags & reqColorsUpdate)
266
                updateColorList();
267
}
268
 
269
void PropertiesPalette_Group::setCurrentItem(PageItem *item)
270
{
271
        if (!m_ScMW || m_ScMW->scriptIsRunning())
272
                return;
273
        //CB We shouldnt really need to process this if our item is the same one
274
        //maybe we do if the item has been changed by scripter.. but that should probably
275
        //set some status if so.
276
        //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
277
        //if (m_item == i)
278
        //      return;
279
 
280
        if (!m_doc)
281
                setDoc(item->doc());
282
 
283
        m_haveItem = false;
284
        m_item = item;
285
 
286
        bool   mirrorX, mirrorY;
287
        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
288
        m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
289
        m_item->patternFlip(mirrorX, mirrorY);
290
 
291
        transPalWidget->setCurrentItem(m_item);
16744 fschmid 292
        nonZero->setChecked(!m_item->fillRule);
293
        evenOdd->setChecked(m_item->fillRule);
18775 fschmid 294
        clipGroups->setChecked(m_item->groupClipping());
16546 jghali 295
 
296
        if ((m_item->isGroup()) && (!m_item->isSingleSel))
297
        {
298
                setEnabled(true);
299
                if (m_item->FrameType == 0)
300
                        customShape->setIcon(customShape->getIconPixmap(0));
301
                if (m_item->FrameType == 1)
302
                        customShape->setIcon(customShape->getIconPixmap(1));
303
                if (m_item->FrameType > 3)
304
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
305
                transPalWidget->updateFromItem();
306
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
307
                customShape->setEnabled(true);
308
                editShape->setEnabled(true);
309
                shapeGroup->setEnabled(true);
310
                textFlowDisabled->setEnabled(true);
311
                textFlowUsesFrameShape->setEnabled(true);
312
                textFlowUsesBoundingBox->setEnabled(true);
313
                textFlowUsesContourLine->setEnabled(true);
314
                textFlowUsesImageClipping->setEnabled(false);
315
        }
316
        else
317
        {
318
                setEnabled(false);
319
        }
320
 
321
        m_haveItem = true;
322
 
323
        if (m_item->asOSGFrame())
324
        {
325
                setEnabled(false);
326
        }
327
        if (m_item->asSymbolFrame())
328
        {
329
                setEnabled(true);
330
                if (m_item->FrameType == 0)
331
                        customShape->setIcon(customShape->getIconPixmap(0));
332
                if (m_item->FrameType == 1)
333
                        customShape->setIcon(customShape->getIconPixmap(1));
334
                if (m_item->FrameType > 3)
335
                        customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2));
336
                transPalWidget->updateFromItem();
337
                transPalWidget->setActPattern(m_item->patternMask(), patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, mirrorX, mirrorY);
338
                customShape->setEnabled(true);
339
                editShape->setEnabled(true);
340
                shapeGroup->setEnabled(true);
341
                textFlowDisabled->setEnabled(true);
342
                textFlowUsesFrameShape->setEnabled(true);
343
                textFlowUsesBoundingBox->setEnabled(true);
344
                textFlowUsesContourLine->setEnabled(true);
345
                textFlowUsesImageClipping->setEnabled(false);
346
        }
18795 jghali 347
        showTextFlowMode(m_item->textFlowMode());
16546 jghali 348
}
349
 
18795 jghali 350
void PropertiesPalette_Group::showTextFlowMode(PageItem::TextFlowMode mode)
16546 jghali 351
{
352
        if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem)
353
                return;
354
        if (m_item->isGroup())
355
        {
356
                if (mode == PageItem::TextFlowDisabled)
357
                        textFlowDisabled->setChecked(true);
358
                else if (mode == PageItem::TextFlowUsesFrameShape)
359
                        textFlowUsesFrameShape->setChecked(true);
360
                else if (mode == PageItem::TextFlowUsesBoundingBox)
361
                        textFlowUsesBoundingBox->setChecked(true);
362
                else if (mode == PageItem::TextFlowUsesContourLine)
363
                        textFlowUsesContourLine->setChecked(true);
364
                else if (mode == PageItem::TextFlowUsesImageClipping)
365
                        textFlowUsesImageClipping->setChecked(true);
366
                if ((m_item->asImageFrame()) && (m_item->imageClip.size() != 0))
367
                        textFlowUsesImageClipping->setEnabled(true);
368
                else
369
                        textFlowUsesImageClipping->setEnabled(false);
370
        }
371
}
372
 
373
void PropertiesPalette_Group::updateColorList()
374
{
375
        if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
376
                return;
19406 jghali 377
        transPalWidget->updateColorList();
16546 jghali 378
}
379
 
380
void PropertiesPalette_Group::updateColorSpecialGradient()
381
{
382
        if (!m_haveDoc)
383
                return;
384
        if(m_doc->m_Selection->isEmpty())
385
                return;
386
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
387
        if (currItem)
388
        {
389
                switch (m_ScMW->view->editStrokeGradient)
390
                {
391
                case 0:
392
                case 1:
393
                case 3:
394
                case 4:
395
                case 5:
396
                case 6:
397
                case 7:
398
                        break;
399
                default:
400
                        if (currItem->isGroup())
18134 jghali 401
                                transPalWidget->setSpecialGradient(currItem->GrMaskStartX, currItem->GrMaskStartY, currItem->GrMaskEndX, currItem->GrMaskEndY, currItem->GrMaskFocalX, currItem->GrMaskFocalY, currItem->GrMaskScale, currItem->GrMaskSkew);
16546 jghali 402
                }
403
        }
404
}
405
 
17388 jghali 406
void PropertiesPalette_Group::handleGradientChanged()
407
{
408
        if (m_haveDoc)
409
        {
410
                VGradient vg(transPalWidget->gradEdit->gradient());
411
                m_doc->itemSelection_SetMaskGradient(vg);
412
        }
413
}
414
 
16546 jghali 415
void PropertiesPalette_Group::handleGroupTransparency(double trans)
416
{
417
        if ((m_haveDoc) && (m_haveItem))
418
        {
419
                m_item->setFillTransparency(trans);
420
                m_item->update();
421
        }
422
}
423
 
424
void PropertiesPalette_Group::handleGroupBlending(int blend)
425
{
426
        if ((m_haveDoc) && (m_haveItem))
427
        {
428
                m_item->setFillBlendmode(blend);
429
                m_item->update();
430
        }
431
}
432
 
433
void PropertiesPalette_Group::handleGroupGradMask(int typ)
434
{
435
        if ((m_haveDoc) && (m_haveItem))
436
        {
437
                m_item->GrMask = typ;
438
                if ((typ > 0) && (typ < 7))
439
                        m_item->updateGradientVectors();
440
                m_item->update();
441
        }
442
}
443
 
444
void PropertiesPalette_Group::handleGroupPatternMask(QString pattern)
445
{
446
        if ((m_haveDoc) && (m_haveItem))
447
        {
448
                m_item->setPatternMask(pattern);
449
                m_item->update();
450
        }
451
}
452
 
453
void PropertiesPalette_Group::handleGroupPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
454
{
455
        if ((m_haveDoc) && (m_haveItem))
456
        {
457
                m_item->setMaskTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
458
                m_item->setMaskFlip(mirrorX, mirrorY);
459
                m_item->update();
460
        }
461
}
462
 
463
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points)
464
{
465
        if (!m_ScMW || m_ScMW->scriptIsRunning())
466
                return;
467
        if ((m_haveDoc) && (m_haveItem))
468
        {
469
                if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText))
470
                        return;
471
 
472
                m_doc->item_setFrameShape(m_item, frameType, count, points);
17097 fschmid 473
                m_doc->invalidateAll();
474
                m_doc->regionsChanged()->update(QRect());
16546 jghali 475
 
476
                //ScribusDoc::changed() is called in item_setFrameShape()
477
                //Hope this is enough
478
                //emit DocChanged();
479
                emit shapeChanged(frameType);
480
        }
481
}
482
 
483
void PropertiesPalette_Group::handleTextFlow()
484
{
485
        if (!m_ScMW || m_ScMW->scriptIsRunning())
486
                return;
487
        if ((m_haveDoc) && (m_haveItem))
488
        {
489
                PageItem::TextFlowMode mode = PageItem::TextFlowDisabled;
490
                if (m_item->isGroup())
491
                {
492
                        if (textFlowDisabled->isChecked())
493
                                mode = PageItem::TextFlowDisabled;
494
                        if (textFlowUsesFrameShape->isChecked())
495
                                mode = PageItem::TextFlowUsesFrameShape;
496
                        if (textFlowUsesBoundingBox->isChecked())
497
                                mode = PageItem::TextFlowUsesBoundingBox;
498
                        if (textFlowUsesContourLine->isChecked())
499
                                mode = PageItem::TextFlowUsesContourLine;
500
                        if (textFlowUsesImageClipping->isChecked())
501
                                mode = PageItem::TextFlowUsesImageClipping;
502
                }
503
                m_item->setTextFlowMode(mode);
17099 jghali 504
                m_doc->changed();
17057 fschmid 505
                m_doc->invalidateAll();
17038 fschmid 506
                m_doc->regionsChanged()->update(QRect());
16546 jghali 507
        }
508
}
509
 
510
void PropertiesPalette_Group::handleGradientEdit()
511
{
512
        if (!m_ScMW || m_ScMW->scriptIsRunning())
513
                return;
514
        if ((m_haveDoc) && (m_haveItem))
515
        {
516
                m_ScMW->view->editStrokeGradient = 2;
517
                if (transPalWidget->gradEditButton->isChecked())
518
                        m_ScMW->view->requestMode(modeEditGradientVectors);
519
                else
520
                        m_ScMW->view->requestMode(modeNormal);
521
        }
522
}
523
 
524
void PropertiesPalette_Group::handleSpecialGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk)
525
{
526
        if (!m_ScMW || m_ScMW->scriptIsRunning())
527
                return;
528
        if ((m_haveDoc) && (m_haveItem))
529
        {
530
                QRectF upRect;
531
                m_item->GrMaskStartX = x1 / m_unitRatio;
532
                m_item->GrMaskStartY = y1 / m_unitRatio;
533
                m_item->GrMaskEndX = x2 / m_unitRatio;
534
                m_item->GrMaskEndY = y2 / m_unitRatio;
535
                m_item->GrMaskFocalX = fx / m_unitRatio;
536
                m_item->GrMaskFocalY = fy / m_unitRatio;
537
                m_item->GrMaskScale = sg;
538
                m_item->GrMaskSkew = sk;
539
                if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
540
                {
541
                        m_item->GrMaskFocalX = m_item->GrMaskStartX;
542
                        m_item->GrMaskFocalY = m_item->GrMaskStartY;
543
                }
544
                m_item->update();
545
                upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
546
                double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
547
                double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
548
                QTransform m;
549
                m.translate(m_item->GrMaskStartX, m_item->GrMaskStartY);
550
                m.rotate(rotEnd);
551
                m.rotate(-90);
552
                m.rotate(m_item->GrMaskSkew);
553
                m.translate(radEnd * m_item->GrMaskScale, 0);
554
                QPointF shP = m.map(QPointF(0,0));
555
                upRect |= QRectF(shP, QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY)).normalized();
556
                upRect |= QRectF(shP, QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY)).normalized();
557
                upRect |= QRectF(shP, QPointF(0, 0)).normalized();
558
                upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
559
                upRect.translate(m_item->xPos(), m_item->yPos());
560
                m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
17099 jghali 561
                m_doc->changed();
16546 jghali 562
        }
563
}
564
 
16744 fschmid 565
void PropertiesPalette_Group::handleFillRule()
566
{
567
        if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
568
                return;
569
        m_item->fillRule = evenOdd->isChecked();
570
        m_item->update();
571
}
572
 
18775 fschmid 573
void PropertiesPalette_Group::handleClipping()
574
{
575
        if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
576
                return;
577
        m_item->setGroupClipping(clipGroups->isChecked());
578
        m_item->update();
579
}
580
 
16546 jghali 581
void PropertiesPalette_Group::handleShapeEdit()
582
{
583
        if (!m_ScMW || m_ScMW->scriptIsRunning())
584
                return;
585
        if ((m_haveDoc) && (m_haveItem))
586
        {
587
                m_tmpSelection->clear();
588
                m_tmpSelection->copy(*m_doc->m_Selection, true);
589
                m_doc->m_Selection->clear();
590
                m_doc->m_Selection->addItem(m_item);
591
                m_item->isSingleSel = true;
592
                m_item->update();
593
                m_ScMW->view->requestMode(modeEditClip);
16976 fschmid 594
                m_ScMW->scrActions["itemUngroup"]->setEnabled(false);
16546 jghali 595
                connect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
596
                emit shapeEditStarted();
597
        }
598
}
599
 
600
void PropertiesPalette_Group::handleShapeEditEnded()
601
{
602
        disconnect(m_ScMW->nodePalette, SIGNAL(paletteClosed()), this, SLOT(handleShapeEditEnded()));
603
        if ((m_haveDoc) && (m_haveItem))
604
        {
605
                if (m_tmpSelection->count() > 0)
606
                {
607
                        m_doc->m_Selection->copy(*m_tmpSelection, false);
608
                        m_doc->m_Selection->connectItemToGUI();
609
                }
610
                m_tmpSelection->clear();
16976 fschmid 611
//              m_ScMW->propertiesPalette->setCurrentItem(m_doc->m_Selection->itemAt(0));
612
//              m_ScMW->scrActions["itemGroup"]->setEnabled(true);
613
//              m_ScMW->propertiesPalette->xyzPal->doUnGroup->setEnabled(true);
16546 jghali 614
        }
615
}
616
 
617
void PropertiesPalette_Group::changeEvent(QEvent *e)
618
{
619
        if (e->type() == QEvent::LanguageChange)
620
        {
621
                languageChange();
622
                return;
623
        }
624
        QWidget::changeEvent(e);
625
}
626
 
627
 
628
void PropertiesPalette_Group::languageChange()
629
{
630
        editShape->setText( tr("&Edit..."));
631
        shapeGroup->setTitle( tr("Shape"));
632
 
633
        textFlowGroup->setTitle( tr("Text &Flow Around Frame"));
634
        textFlowDisabled->setText( tr("Disabled"));
635
        textFlowUsesFrameShape->setText( tr("Use Frame &Shape"));
636
        textFlowUsesBoundingBox->setText( tr("Use &Bounding Box"));
637
        textFlowUsesContourLine->setText( tr("&Use Contour Line"));
638
        textFlowUsesImageClipping->setText( tr("Use Image Clip Path"));
639
 
640
        textFlowDisabled->setToolTip( tr("Disable text flow from lower frames around object"));
20272 craig 641
        textFlowUsesFrameShape->setToolTip( tr("Use the frame shape for text flow of text frames below the object"));
642
        textFlowUsesBoundingBox->setToolTip(  "<qt>" + tr("Use the bounding box, which is always rectangular, instead of the frame's shape for text flow of text frames below the object") + "</qt>" );
16546 jghali 643
        textFlowUsesContourLine->setToolTip(  "<qt>" + tr("When chosen, the contour line can be edited with the Edit Shape Tool on the palette further above. When edited via the shape palette, this becomes a second separate line originally based on the frame's shape for text flow of text frames below the object.") + "</qt>" );
644
        textFlowUsesImageClipping->setToolTip(  "<qt>" + tr("Use the clipping path of the image") + "</qt>" );
20209 jghali 645
 
20284 craig 646
        evenOdd->setToolTip( "<qt>" + tr("Any path self-intersections or subpaths create holes in the fill")  + "</qt>");
20286 craig 647
        nonZero->setToolTip( "<qt>" + tr("Fill is solid unless a subpath is counter-directional")  + "</qt>");
16546 jghali 648
}
649
 
650
void PropertiesPalette_Group::unitChange()
651
{
652
        if (!m_doc)
653
                return;
654
 
655
        double oldRatio = m_unitRatio;
656
        m_unitRatio = m_doc->unitRatio();
657
        m_unitIndex = m_doc->unitIndex();
658
 
659
        transPalWidget->blockSignals(true);
660
        transPalWidget->unitChange(oldRatio, m_unitRatio, m_doc->unitIndex());
661
        transPalWidget->blockSignals(false);
16744 fschmid 662
}