~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/plugins/scriptplugin/cmdsetprop.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2007-08-11 17:41:51 UTC
  • mfrom: (0.1.1 upstream) (4.1.2 feisty)
  • Revision ID: james.westby@ubuntu.com-20070811174151-tmkgjvjuc0mtk8ul
Tags: 1.3.4.dfsg+svn20071115-1
* Upstream svn update (Closes: #447480, #448949).
* debian/NEWS: Added a note for users wanting stable Scribus to switch to
  the "scribus" package (Closes: #427638).
* debian/watch: Updated the watch regex to properly track sourceforge
  releases for this branch (Closes: #449700).

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
*/
7
7
#include "cmdsetprop.h"
8
8
#include "cmdutil.h"
 
9
#include "scribuscore.h"
9
10
 
10
11
PyObject *scribus_setgradfill(PyObject* /* self */, PyObject* args)
11
12
{
29
30
        currItem->SetFarbe(&tmp, c2, shade2);
30
31
        currItem->fill_gradient.addStop(tmp, 1.0, 0.5, 1.0, c2, shade2);
31
32
        currItem->GrType = typ;
32
 
        //ScMW->view->updateGradientVectors(currItem);
 
33
        switch (currItem->GrType)
 
34
        {
 
35
                case 0:
 
36
                case 1:
 
37
                        currItem->GrStartX = 0;
 
38
                        currItem->GrStartY = currItem->height() / 2.0;
 
39
                        currItem->GrEndX = currItem->width();
 
40
                        currItem->GrEndY = currItem->height() / 2.0;
 
41
                        break;
 
42
                case 2:
 
43
                        currItem->GrStartX = currItem->width() / 2.0;
 
44
                        currItem->GrStartY = 0;
 
45
                        currItem->GrEndX = currItem->width() / 2.0;
 
46
                        currItem->GrEndY = currItem->height();
 
47
                        break;
 
48
                case 3:
 
49
                        currItem->GrStartX = 0;
 
50
                        currItem->GrStartY = 0;
 
51
                        currItem->GrEndX = currItem->width();
 
52
                        currItem->GrEndY = currItem->height();
 
53
                        break;
 
54
                case 4:
 
55
                        currItem->GrStartX = 0;
 
56
                        currItem->GrStartY = currItem->height();
 
57
                        currItem->GrEndX = currItem->width();
 
58
                        currItem->GrEndY = 0;
 
59
                        break;
 
60
                case 5:
 
61
                        currItem->GrStartX = currItem->width() / 2.0;
 
62
                        currItem->GrStartY = currItem->height() / 2.0;
 
63
                        if (currItem->width() >= currItem->height())
 
64
                        {
 
65
                                currItem->GrEndX = currItem->width();
 
66
                                currItem->GrEndY = currItem->height() / 2.0;
 
67
                        }
 
68
                        else
 
69
                        {
 
70
                                currItem->GrEndX = currItem->width() / 2.0;
 
71
                                currItem->GrEndY = currItem->height();
 
72
                        }
 
73
                        break;
 
74
                default:
 
75
                        break;
 
76
        }
 
77
        //ScCore->primaryMainWindow()->view->updateGradientVectors(currItem);
33
78
        currItem->updateGradientVectors();
34
 
        ScMW->view->RefreshItem(currItem);
35
 
        Py_INCREF(Py_None);
36
 
        return Py_None;
 
79
        ScCore->primaryMainWindow()->view->RefreshItem(currItem);
 
80
//      Py_INCREF(Py_None);
 
81
//      return Py_None;
 
82
        Py_RETURN_NONE;
37
83
}
38
84
 
39
85
PyObject *scribus_setfillcolor(PyObject* /* self */, PyObject* args)
48
94
        if (i == NULL)
49
95
                return NULL;
50
96
        i->setFillColor(QString::fromUtf8(Color));
51
 
        Py_INCREF(Py_None);
52
 
        return Py_None;
 
97
 //     Py_INCREF(Py_None);
 
98
 //     return Py_None;
 
99
        Py_RETURN_NONE;
 
100
}
 
101
 
 
102
PyObject *scribus_setfilltrans(PyObject* /* self */, PyObject* args)
 
103
{
 
104
        char *Name = const_cast<char*>("");
 
105
        double w;
 
106
        if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
 
107
                return NULL;
 
108
        if(!checkHaveDocument())
 
109
                return NULL;
 
110
        if ((w < 0.0) || (w > 1.0))
 
111
        {
 
112
                PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error"));
 
113
                return NULL;
 
114
        }
 
115
        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
 
116
        if (i == NULL)
 
117
                return NULL;
 
118
        i->setFillTransparency(1.0 - w);
 
119
 //     Py_INCREF(Py_None);
 
120
//      return Py_None;
 
121
        Py_RETURN_NONE;
 
122
}
 
123
 
 
124
PyObject *scribus_setfillblend(PyObject* /* self */, PyObject* args)
 
125
{
 
126
        char *Name = const_cast<char*>("");
 
127
        int w;
 
128
        if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
 
129
                return NULL;
 
130
        if(!checkHaveDocument())
 
131
                return NULL;
 
132
        if ((w < 0) || (w > 15))
 
133
        {
 
134
                PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error"));
 
135
                return NULL;
 
136
        }
 
137
        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
 
138
        if (i == NULL)
 
139
                return NULL;
 
140
        i->setFillBlendmode(w);
 
141
 //     Py_INCREF(Py_None);
 
142
 //     return Py_None;
 
143
        Py_RETURN_NONE;
53
144
}
54
145
 
55
146
PyObject *scribus_setlinecolor(PyObject* /* self */, PyObject* args)
64
155
        if (it == NULL)
65
156
                return NULL;
66
157
        it->setLineColor(QString::fromUtf8(Color));
67
 
        Py_INCREF(Py_None);
68
 
        return Py_None;
 
158
//      Py_INCREF(Py_None);
 
159
//      return Py_None;
 
160
        Py_RETURN_NONE;
 
161
}
 
162
 
 
163
PyObject *scribus_setlinetrans(PyObject* /* self */, PyObject* args)
 
164
{
 
165
        char *Name = const_cast<char*>("");
 
166
        double w;
 
167
        if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
 
168
                return NULL;
 
169
        if(!checkHaveDocument())
 
170
                return NULL;
 
171
        if ((w < 0.0) || (w > 1.0))
 
172
        {
 
173
                PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error"));
 
174
                return NULL;
 
175
        }
 
176
        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
 
177
        if (i == NULL)
 
178
                return NULL;
 
179
        i->setLineTransparency(1.0 - w);
 
180
 //     Py_INCREF(Py_None);
 
181
 //     return Py_None;
 
182
        Py_RETURN_NONE;
 
183
}
 
184
 
 
185
PyObject *scribus_setlineblend(PyObject* /* self */, PyObject* args)
 
186
{
 
187
        char *Name = const_cast<char*>("");
 
188
        int w;
 
189
        if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
 
190
                return NULL;
 
191
        if(!checkHaveDocument())
 
192
                return NULL;
 
193
        if ((w < 0) || (w > 15))
 
194
        {
 
195
                PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error"));
 
196
                return NULL;
 
197
        }
 
198
        PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
 
199
        if (i == NULL)
 
200
                return NULL;
 
201
        i->setLineBlendmode(w);
 
202
 //     Py_INCREF(Py_None);
 
203
//      return Py_None;
 
204
        Py_RETURN_NONE;
69
205
}
70
206
 
71
207
PyObject *scribus_setlinewidth(PyObject* /* self */, PyObject* args)
85
221
        if (i == NULL)
86
222
                return NULL;
87
223
        i->setLineWidth(w);
88
 
        Py_INCREF(Py_None);
89
 
        return Py_None;
 
224
//      Py_INCREF(Py_None);
 
225
//      return Py_None;
 
226
        Py_RETURN_NONE;
90
227
}
91
228
 
92
229
PyObject *scribus_setlineshade(PyObject* /* self */, PyObject* args)
106
243
        if (it == NULL)
107
244
                return NULL;
108
245
        it->setLineShade(w);
109
 
        Py_INCREF(Py_None);
110
 
        return Py_None;
 
246
 //     Py_INCREF(Py_None);
 
247
//      return Py_None;
 
248
        Py_RETURN_NONE;
111
249
}
112
250
 
113
251
PyObject *scribus_setfillshade(PyObject* /* self */, PyObject* args)
127
265
        if (i == NULL)
128
266
                return NULL;
129
267
        i->setFillShade(w);
130
 
        Py_INCREF(Py_None);
131
 
        return Py_None;
 
268
 //     Py_INCREF(Py_None);
 
269
//      return Py_None;
 
270
        Py_RETURN_NONE;
132
271
}
133
272
 
134
273
PyObject *scribus_setlinejoin(PyObject* /* self */, PyObject* args)
143
282
        if (i == NULL)
144
283
                return NULL;
145
284
        i->PLineJoin = Qt::PenJoinStyle(w);
146
 
        Py_INCREF(Py_None);
147
 
        return Py_None;
 
285
 //     Py_INCREF(Py_None);
 
286
 //     return Py_None;
 
287
        Py_RETURN_NONE;
148
288
}
149
289
 
150
290
PyObject *scribus_setlineend(PyObject* /* self */, PyObject* args)
159
299
        if (i == NULL)
160
300
                return NULL;
161
301
        i->PLineEnd = Qt::PenCapStyle(w);
162
 
        Py_INCREF(Py_None);
163
 
        return Py_None;
 
302
//      Py_INCREF(Py_None);
 
303
//      return Py_None;
 
304
        Py_RETURN_NONE;
164
305
}
165
306
 
166
307
PyObject *scribus_setlinestyle(PyObject* /* self */, PyObject* args)
175
316
        if (i == NULL)
176
317
                return NULL;
177
318
        i->PLineArt = Qt::PenStyle(w);
178
 
        Py_INCREF(Py_None);
179
 
        return Py_None;
 
319
 //     Py_INCREF(Py_None);
 
320
//      return Py_None;
 
321
        Py_RETURN_NONE;
180
322
}
181
323
 
182
324
PyObject *scribus_setcornerrad(PyObject* /* self */, PyObject* args)
198
340
        // apply rounding
199
341
        currItem->setCornerRadius(w);
200
342
        currItem->SetFrameRound();
201
 
        ScMW->doc->setRedrawBounding(currItem);
202
 
        ScMW->view->SetFrameRounded();
203
 
        Py_INCREF(Py_None);
204
 
        return Py_None;
 
343
        ScCore->primaryMainWindow()->doc->setRedrawBounding(currItem);
 
344
        ScCore->primaryMainWindow()->view->SetFrameRounded();
 
345
 //     Py_INCREF(Py_None);
 
346
//      return Py_None;
 
347
        Py_RETURN_NONE;
205
348
}
206
349
 
207
350
PyObject *scribus_setmultiline(PyObject* /* self */, PyObject* args)
215
358
        PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
216
359
        if (currItem == NULL)
217
360
                return NULL;
218
 
        if (!ScMW->doc->MLineStyles.contains(QString::fromUtf8(Style)))
 
361
        if (!ScCore->primaryMainWindow()->doc->MLineStyles.contains(QString::fromUtf8(Style)))
219
362
        {
220
363
                PyErr_SetString(NotFoundError, QObject::tr("Line style not found.","python error"));
221
364
                return NULL;
222
365
        }
223
366
        currItem->NamedLStyle = QString::fromUtf8(Style);
224
 
        Py_INCREF(Py_None);
225
 
        return Py_None;
 
367
 //     Py_INCREF(Py_None);
 
368
//      return Py_None;
 
369
        Py_RETURN_NONE;
 
370
}
 
371
 
 
372
/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
 
373
with header files structure untouched (docstrings are kept near declarations)
 
374
PV */
 
375
void cmdsetpropdocwarnings()
 
376
{
 
377
    QStringList s;
 
378
    s << scribus_setgradfill__doc__ << scribus_setfillcolor__doc__ << scribus_setfilltrans__doc__  << scribus_setfillblend__doc__  <<  scribus_setlinecolor__doc__  <<  scribus_setlinetrans__doc__  << scribus_setlineblend__doc__  <<  scribus_setlinewidth__doc__  <<  scribus_setlineshade__doc__  << scribus_setlinejoin__doc__  <<  scribus_setlineend__doc__  <<  scribus_setlinestyle__doc__  << scribus_setfillshade__doc__  <<  scribus_setcornerrad__doc__  <<  scribus_setmultiline__doc__;
226
379
}