Rev 2318 | Rev 2352 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
102 | Franz | 1 | /*************************************************************************** |
2 | story.cpp - description |
||
3 | ------------------- |
||
4 | begin : Tue Nov 11 2003 |
||
5 | copyright : (C) 2003 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
1789 | fschmid | 17 | #include "scfonts.h" |
102 | Franz | 18 | #include "story.h" |
19 | #include "story.moc" |
||
20 | #include <qtooltip.h> |
||
21 | #include <qpixmap.h> |
||
22 | #include <qcombobox.h> |
||
103 | Franz | 23 | #include <qmessagebox.h> |
124 | Franz | 24 | #include <qregexp.h> |
351 | Franz | 25 | #include <qhbox.h> |
357 | Franz | 26 | #include <qcolordialog.h> |
27 | #include <qfontdialog.h> |
||
374 | Franz | 28 | #include <qcursor.h> |
2233 | fschmid | 29 | #include <qtextcodec.h> |
102 | Franz | 30 | #include "serializer.h" |
162 | Franz | 31 | #include "customfdialog.h" |
189 | Franz | 32 | #include "search.h" |
253 | Franz | 33 | #include "scribus.h" |
415 | Franz | 34 | #include "prefscontext.h" |
35 | #include "prefsfile.h" |
||
1202 | fschmid | 36 | #include "charselect.h" |
1549 | subik | 37 | #include "pluginmanager.h" |
189 | Franz | 38 | |
415 | Franz | 39 | extern PrefsFile* prefsFile; |
102 | Franz | 40 | extern QPixmap loadIcon(QString nam); |
415 | Franz | 41 | extern ScribusApp* ScApp; |
102 | Franz | 42 | |
371 | Franz | 43 | SideBar::SideBar(QWidget *pa) : QLabel(pa) |
44 | { |
||
45 | setEraseColor(QColor(255,255,255)); |
||
46 | offs = 0; |
||
47 | editor = 0; |
||
372 | Franz | 48 | noUpdt = true; |
373 | Franz | 49 | inRep = false; |
50 | setMinimumWidth(fontMetrics().width( tr("No Style") )+30); |
||
371 | Franz | 51 | } |
52 | |||
374 | Franz | 53 | void SideBar::mouseReleaseEvent(QMouseEvent *m) |
54 | { |
||
55 | CurrentPar = editor->paragraphAt(QPoint(2, m->y()+offs)); |
||
56 | pmen = new QPopupMenu(); |
||
57 | Spalette* Spal = new Spalette(this); |
||
716 | cbradney | 58 | Spal->setFormats(editor->doc); |
374 | Franz | 59 | if ((CurrentPar < static_cast<int>(editor->StyledText.count())) && (editor->StyledText.count() != 0)) |
60 | { |
||
61 | if (editor->StyledText.at(CurrentPar)->count() > 0) |
||
62 | Spal->setFormat(editor->StyledText.at(CurrentPar)->at(0)->cab); |
||
63 | else |
||
64 | Spal->setFormat(0); |
||
65 | } |
||
66 | else |
||
67 | Spal->setFormat(0); |
||
716 | cbradney | 68 | connect(Spal, SIGNAL(newStyle(int)), this, SLOT(setPStyle(int))); |
374 | Franz | 69 | pmen->insertItem(Spal); |
1893 | subik | 70 | pmen->insertItem(tr("Edit Styles..."), this, SLOT(editStyles())); |
374 | Franz | 71 | pmen->exec(QCursor::pos()); |
72 | delete pmen; |
||
73 | } |
||
74 | |||
1893 | subik | 75 | void SideBar::editStyles() |
76 | { |
||
77 | emit sigEditStyles(); |
||
78 | } |
||
79 | |||
374 | Franz | 80 | void SideBar::setPStyle(int s) |
81 | { |
||
82 | emit ChangeStyle(CurrentPar, s); |
||
83 | pmen->activateItemAt(0); |
||
84 | } |
||
85 | |||
371 | Franz | 86 | void SideBar::paintEvent(QPaintEvent *e) |
87 | { |
||
373 | Franz | 88 | inRep = true; |
371 | Franz | 89 | QLabel::paintEvent(e); |
90 | QPainter p; |
||
91 | p.begin(this); |
||
372 | Franz | 92 | if ((editor != 0) && (noUpdt)) |
371 | Franz | 93 | { |
1065 | cbradney | 94 | int st = editor->currentParaStyle; |
371 | Franz | 95 | for (int pa = 0; pa < editor->paragraphs(); ++pa) |
96 | { |
||
97 | QRect re = editor->paragraphRect(pa); |
||
373 | Franz | 98 | if (!re.isValid()) |
99 | break; |
||
371 | Franz | 100 | re.setWidth(width()-5); |
101 | re.moveBy(5, 0); |
||
373 | Franz | 102 | if (((re.y()+re.height())-offs < height()) && ((re.y()+re.height())-offs > 0)) |
371 | Franz | 103 | p.drawLine(0, (re.y()+re.height())-offs, width()-1, (re.y()+re.height())-offs); |
373 | Franz | 104 | if ((re.y()-offs < height()) && (re.y()-offs > 0)) |
371 | Franz | 105 | { |
372 | Franz | 106 | re.setY(re.y()-offs); |
371 | Franz | 107 | if ((pa < static_cast<int>(editor->StyledText.count())) && (editor->StyledText.count() != 0)) |
108 | { |
||
109 | if (editor->StyledText.at(pa)->count() > 0) |
||
110 | { |
||
111 | st = editor->StyledText.at(pa)->at(0)->cab; |
||
112 | if (st < 5) |
||
373 | Franz | 113 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, tr("No Style")); |
371 | Franz | 114 | else |
1065 | cbradney | 115 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, editor->doc->docParagraphStyles[st].Vname); |
371 | Franz | 116 | } |
117 | else |
||
118 | { |
||
373 | Franz | 119 | st = editor->ParagStyles[pa]; |
371 | Franz | 120 | if (st < 5) |
373 | Franz | 121 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, tr("No Style")); |
371 | Franz | 122 | else |
1065 | cbradney | 123 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, editor->doc->docParagraphStyles[st].Vname); |
371 | Franz | 124 | } |
125 | } |
||
126 | else |
||
127 | { |
||
1065 | cbradney | 128 | st = editor->currentParaStyle; |
371 | Franz | 129 | if (st < 5) |
373 | Franz | 130 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, tr("No Style")); |
371 | Franz | 131 | else |
1065 | cbradney | 132 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, editor->doc->docParagraphStyles[st].Vname); |
371 | Franz | 133 | } |
134 | } |
||
135 | } |
||
136 | } |
||
137 | p.end(); |
||
373 | Franz | 138 | inRep = false; |
371 | Franz | 139 | } |
140 | |||
795 | fschmid | 141 | void SideBar::doMove(int, int y) |
371 | Franz | 142 | { |
143 | offs = y; |
||
373 | Franz | 144 | if (!inRep) |
145 | update(); |
||
371 | Franz | 146 | } |
147 | |||
148 | void SideBar::doRepaint() |
||
149 | { |
||
373 | Franz | 150 | if (!inRep) |
151 | update(); |
||
371 | Franz | 152 | } |
153 | |||
372 | Franz | 154 | void SideBar::setRepaint(bool r) |
155 | { |
||
156 | noUpdt = r; |
||
157 | } |
||
158 | |||
351 | Franz | 159 | SEditor::SEditor(QWidget* parent, ScribusDoc *docc) : QTextEdit(parent) |
102 | Franz | 160 | { |
351 | Franz | 161 | doc = docc; |
353 | Franz | 162 | wasMod = false; |
385 | Franz | 163 | StoredSel = false; |
351 | Franz | 164 | StyledText.clear(); |
165 | StyledText.setAutoDelete(true); |
||
373 | Franz | 166 | ParagStyles.clear(); |
362 | Franz | 167 | cBuffer.setAutoDelete(true); |
168 | cBuffer.clear(); |
||
113 | Franz | 169 | setUndoRedoEnabled(true); |
351 | Franz | 170 | setUndoDepth(0); |
171 | setTextFormat(Qt::PlainText); |
||
355 | Franz | 172 | viewport()->setAcceptDrops(false); |
376 | Franz | 173 | ClipData = 0; |
867 | fschmid | 174 | UniCinp = false; |
376 | Franz | 175 | connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
399 | Franz | 176 | connect(QApplication::clipboard(), SIGNAL(selectionChanged()), this, SLOT(SelClipChange())); |
102 | Franz | 177 | } |
178 | |||
2233 | fschmid | 179 | void SEditor::imEndEvent(QIMEvent *e) |
180 | { |
||
181 | QString uc = e->text(); |
||
182 | if ((uc != "") && ((*doc->AllFonts)[CurrFont]->CharWidth.contains(uc[0].unicode()))) |
||
183 | { |
||
184 | insChars(e->text()); |
||
185 | QTextEdit::imEndEvent(e); |
||
186 | emit SideBarUp(true); |
||
187 | emit SideBarUpdate(); |
||
188 | } |
||
189 | } |
||
190 | |||
351 | Franz | 191 | void SEditor::keyPressEvent(QKeyEvent *k) |
113 | Franz | 192 | { |
372 | Franz | 193 | emit SideBarUp(false); |
351 | Franz | 194 | int p, i; |
195 | getCursorPosition(&p, &i); |
||
196 | int KeyMod; |
||
197 | switch (k->state()) |
||
198 | { |
||
199 | case ShiftButton: |
||
200 | KeyMod = 0x00200000; |
||
201 | break; |
||
202 | case AltButton: |
||
203 | KeyMod = 0x00800000; |
||
204 | break; |
||
205 | case ControlButton: |
||
206 | KeyMod = 0x00400000; |
||
207 | break; |
||
208 | default: |
||
209 | KeyMod = 0; |
||
210 | break; |
||
211 | } |
||
926 | fschmid | 212 | QString uc = k->text(); |
2319 | cbradney | 213 | |
214 | if ((k->key() + KeyMod) == ScApp->scrActions["specialPageNumber"]->accel()) |
||
351 | Franz | 215 | { |
2319 | cbradney | 216 | insChars(QString(QChar(ScApp->scrActions["specialPageNumber"]->actionInt()))); |
351 | Franz | 217 | insert("#"); |
372 | Franz | 218 | emit SideBarUp(true); |
351 | Franz | 219 | return; |
220 | } |
||
2319 | cbradney | 221 | if ((k->key() + KeyMod) == ScApp->scrActions["specialNonBreakingSpace"]->accel()) |
2318 | fschmid | 222 | { |
2319 | cbradney | 223 | insChars(QString(QChar(ScApp->scrActions["specialNonBreakingSpace"]->actionInt()))); |
2318 | fschmid | 224 | insert("_"); |
225 | emit SideBarUp(true); |
||
226 | return; |
||
227 | } |
||
2319 | cbradney | 228 | |
351 | Franz | 229 | switch (k->state()) |
230 | { |
||
231 | case ControlButton: |
||
232 | case ControlButton|ShiftButton: |
||
233 | case ControlButton|Keypad: |
||
234 | case ControlButton|ShiftButton|Keypad: |
||
1866 | fschmid | 235 | switch (k->key()) |
236 | { |
||
237 | case Key_Delete: |
||
238 | moveCursor(QTextEdit::MoveWordForward, true); |
||
239 | deleteSel(); |
||
240 | break; |
||
241 | case Key_Backspace: |
||
242 | moveCursor(QTextEdit::MoveWordBackward, true); |
||
243 | deleteSel(); |
||
244 | break; |
||
245 | case Key_K: |
||
246 | moveCursor(QTextEdit::MoveLineEnd, true); |
||
247 | deleteSel(); |
||
248 | break; |
||
249 | case Key_D: |
||
250 | moveCursor(QTextEdit::MoveForward, true); |
||
251 | deleteSel(); |
||
252 | break; |
||
253 | case Key_H: |
||
254 | moveCursor(QTextEdit::MoveBackward, true); |
||
255 | deleteSel(); |
||
256 | break; |
||
257 | case Key_X: |
||
258 | case Key_Y: |
||
259 | case Key_Z: |
||
260 | case Key_V: |
||
261 | emit SideBarUp(true); |
||
262 | return; |
||
263 | break; |
||
264 | case Key_C: |
||
265 | copyStyledText(); |
||
266 | break; |
||
267 | } |
||
351 | Franz | 268 | break; |
269 | case NoButton: |
||
270 | case Keypad: |
||
271 | case ShiftButton: |
||
272 | if (UniCinp) |
||
273 | { |
||
274 | int conv = 0; |
||
275 | bool ok = false; |
||
276 | UniCinS += k->text(); |
||
277 | conv = UniCinS.toInt(&ok, 16); |
||
278 | if (!ok) |
||
279 | { |
||
280 | UniCinp = false; |
||
281 | UniCinC = 0; |
||
282 | UniCinS = ""; |
||
283 | return; |
||
284 | } |
||
285 | UniCinC++; |
||
286 | if (UniCinC == 4) |
||
287 | { |
||
288 | UniCinp = false; |
||
289 | UniCinC = 0; |
||
290 | UniCinS = ""; |
||
291 | if (ok) |
||
292 | { |
||
293 | if (conv < 31) |
||
294 | conv = 32; |
||
295 | insChars(QString(QChar(conv))); |
||
296 | insert(QString(QChar(conv))); |
||
372 | Franz | 297 | emit SideBarUp(true); |
351 | Franz | 298 | return; |
299 | } |
||
300 | } |
||
301 | else |
||
372 | Franz | 302 | { |
303 | emit SideBarUp(true); |
||
351 | Franz | 304 | return; |
372 | Franz | 305 | } |
351 | Franz | 306 | } |
353 | Franz | 307 | wasMod = false; |
351 | Franz | 308 | switch (k->key()) |
309 | { |
||
1945 | craig | 310 | case Key_Escape: |
311 | k->ignore(); |
||
312 | break; |
||
353 | Franz | 313 | case Key_Shift: |
314 | case Key_Control: |
||
315 | case Key_Alt: |
||
316 | wasMod = true; |
||
317 | break; |
||
351 | Franz | 318 | case Key_F12: |
319 | UniCinp = true; |
||
320 | UniCinC = 0; |
||
321 | UniCinS = ""; |
||
322 | return; |
||
323 | break; |
||
324 | case Key_Delete: |
||
325 | if (!hasSelectedText()) |
||
326 | { |
||
327 | ChList *chars = StyledText.at(p); |
||
328 | if (i < static_cast<int>(chars->count())) |
||
329 | chars->remove(i); |
||
330 | else |
||
331 | { |
||
332 | if (p < static_cast<int>(StyledText.count()-1)) |
||
333 | { |
||
334 | struct PtiSmall *hg; |
||
335 | ChList *chars2 = StyledText.at(p+1); |
||
336 | int a = static_cast<int>(chars2->count()); |
||
337 | if (a > 0) |
||
338 | { |
||
339 | int ca; |
||
340 | if (chars->count() > 0) |
||
341 | ca = chars->at(0)->cab; |
||
342 | else |
||
1065 | cbradney | 343 | ca = currentParaStyle; |
351 | Franz | 344 | for (int s = 0; s < a; ++s) |
345 | { |
||
346 | hg = chars2->take(0); |
||
347 | hg->cab = ca; |
||
348 | chars->append(hg); |
||
349 | } |
||
350 | } |
||
351 | StyledText.remove(p+1); |
||
373 | Franz | 352 | ParagStyles.remove(ParagStyles.at(p+1)); |
351 | Franz | 353 | } |
354 | } |
||
355 | } |
||
356 | else |
||
357 | deleteSel(); |
||
358 | break; |
||
359 | case Key_Backspace: |
||
360 | if (!hasSelectedText()) |
||
361 | { |
||
353 | Franz | 362 | if (p >= static_cast<int>(StyledText.count())) |
363 | break; |
||
351 | Franz | 364 | ChList *chars = StyledText.at(p); |
365 | if (i > 0) |
||
366 | chars->remove(i-1); |
||
367 | else |
||
368 | { |
||
369 | if (p > 0) |
||
370 | { |
||
371 | struct PtiSmall *hg; |
||
372 | ChList *chars2 = StyledText.at(p-1); |
||
373 | int a = static_cast<int>(chars->count()); |
||
374 | if (a > 0) |
||
375 | { |
||
376 | int ca; |
||
377 | if (chars2->count() > 0) |
||
378 | ca = chars2->at(0)->cab; |
||
379 | else |
||
380 | ca = chars->at(0)->cab; |
||
381 | for (int s = 0; s < a; ++s) |
||
382 | { |
||
383 | hg = chars->take(0); |
||
384 | hg->cab = ca; |
||
385 | chars2->append(hg); |
||
386 | } |
||
387 | } |
||
388 | StyledText.remove(p); |
||
373 | Franz | 389 | ParagStyles.remove(ParagStyles.at(p)); |
351 | Franz | 390 | } |
391 | } |
||
392 | } |
||
393 | else |
||
394 | deleteSel(); |
||
395 | break; |
||
396 | case Key_Return: |
||
397 | case Key_Enter: |
||
398 | { |
||
399 | if (hasSelectedText()) |
||
400 | deleteSel(); |
||
401 | ChList *chars; |
||
402 | chars = new ChList; |
||
403 | chars->setAutoDelete(true); |
||
404 | chars->clear(); |
||
405 | if (StyledText.count() != 0) |
||
406 | { |
||
353 | Franz | 407 | if (p >= static_cast<int>(StyledText.count())) |
373 | Franz | 408 | { |
353 | Franz | 409 | StyledText.append(chars); |
1065 | cbradney | 410 | ParagStyles.append(currentParaStyle); |
373 | Franz | 411 | } |
353 | Franz | 412 | else |
413 | { |
||
351 | Franz | 414 | ChList *chars2 = StyledText.at(p); |
415 | int a = static_cast<int>(chars2->count()); |
||
416 | for (int s = i; s < a; ++s) |
||
417 | { |
||
418 | chars->append(chars2->take(i)); |
||
419 | } |
||
420 | StyledText.insert(p+1, chars); |
||
1065 | cbradney | 421 | ParagStyles.insert(ParagStyles.at(p+1), currentParaStyle); |
353 | Franz | 422 | } |
351 | Franz | 423 | } |
424 | else |
||
373 | Franz | 425 | { |
351 | Franz | 426 | StyledText.append(chars); |
1065 | cbradney | 427 | ParagStyles.append(currentParaStyle); |
373 | Franz | 428 | } |
351 | Franz | 429 | } |
430 | break; |
||
431 | case Key_Left: |
||
432 | case Key_Right: |
||
433 | case Key_Prior: |
||
434 | case Key_Next: |
||
435 | case Key_Up: |
||
436 | case Key_Down: |
||
437 | case Key_Home: |
||
438 | case Key_End: |
||
439 | break; |
||
440 | default: |
||
926 | fschmid | 441 | if ((k->text() != "") && ((*doc->AllFonts)[CurrFont]->CharWidth.contains(uc[0].unicode()))) |
442 | { |
||
351 | Franz | 443 | insChars(k->text()); |
926 | fschmid | 444 | QTextEdit::keyPressEvent(k); |
445 | emit SideBarUp(true); |
||
446 | emit SideBarUpdate(); |
||
447 | } |
||
972 | fschmid | 448 | return; |
351 | Franz | 449 | break; |
450 | } |
||
451 | break; |
||
452 | default: |
||
453 | break; |
||
454 | } |
||
455 | QTextEdit::keyPressEvent(k); |
||
372 | Franz | 456 | emit SideBarUp(true); |
457 | emit SideBarUpdate(); |
||
113 | Franz | 458 | } |
459 | |||
385 | Franz | 460 | void SEditor::focusOutEvent(QFocusEvent *e) |
461 | { |
||
462 | if (hasSelectedText()) |
||
463 | { |
||
464 | getSelection(&SelParaStart, &SelCharStart, &SelParaEnd, &SelCharEnd); |
||
465 | StoredSel = true; |
||
466 | } |
||
467 | else |
||
468 | StoredSel = false; |
||
469 | QTextEdit::focusOutEvent(e); |
||
470 | } |
||
471 | |||
351 | Franz | 472 | void SEditor::insChars(QString t) |
102 | Franz | 473 | { |
376 | Franz | 474 | int p, i, p2, ccab; |
351 | Franz | 475 | if (hasSelectedText()) |
476 | deleteSel(); |
||
357 | Franz | 477 | getCursorPosition(&p, &i); |
351 | Franz | 478 | ChList *chars; |
376 | Franz | 479 | p2 = p; |
351 | Franz | 480 | if ((p >= static_cast<int>(StyledText.count())) || (StyledText.count() == 0)) |
253 | Franz | 481 | { |
351 | Franz | 482 | chars = new ChList; |
483 | chars->setAutoDelete(true); |
||
484 | chars->clear(); |
||
376 | Franz | 485 | p2 = static_cast<int>(StyledText.count()); |
382 | Franz | 486 | StyledText.append(chars); |
1065 | cbradney | 487 | ParagStyles.append(currentParaStyle); |
351 | Franz | 488 | } |
489 | else |
||
490 | chars = StyledText.at(p); |
||
376 | Franz | 491 | if (chars->count() != 0) |
492 | ccab = chars->at(0)->cab; |
||
493 | else |
||
1065 | cbradney | 494 | ccab = currentParaStyle; |
351 | Franz | 495 | for (uint a = 0; a < t.length(); ++a) |
496 | { |
||
376 | Franz | 497 | if (t[a] == QChar(13)) |
498 | { |
||
499 | ChList *chars2; |
||
500 | chars2 = new ChList; |
||
501 | chars2->setAutoDelete(true); |
||
502 | chars2->clear(); |
||
503 | if (p2 >= static_cast<int>(StyledText.count())) |
||
504 | { |
||
505 | StyledText.append(chars2); |
||
506 | ParagStyles.append(ccab); |
||
507 | } |
||
508 | else |
||
509 | { |
||
510 | int a = static_cast<int>(chars->count()); |
||
511 | for (int s = i; s < a; ++s) |
||
512 | { |
||
513 | chars2->append(chars->take(i)); |
||
514 | } |
||
515 | StyledText.insert(p2+1, chars2); |
||
516 | ParagStyles.insert(ParagStyles.at(p2+1), ccab); |
||
517 | } |
||
518 | p2++; |
||
519 | chars = StyledText.at(p2); |
||
520 | i = 0; |
||
521 | } |
||
522 | else |
||
523 | { |
||
524 | struct PtiSmall *hg; |
||
525 | hg = new PtiSmall; |
||
526 | hg->ch = t[a]; |
||
527 | hg->ccolor = CurrTextFill; |
||
528 | hg->cshade = CurrTextFillSh; |
||
529 | hg->cstroke = CurrTextStroke; |
||
530 | hg->cshade2 = CurrTextStrokeSh; |
||
531 | hg->cfont = CurrFont; |
||
532 | hg->csize = CurrFontSize; |
||
533 | hg->cstyle = CurrentStyle; |
||
534 | hg->cab = ccab; |
||
535 | hg->cextra = CurrTextKern; |
||
536 | hg->cscale = CurrTextScale; |
||
2230 | fschmid | 537 | hg->cscalev = CurrTextScaleV; |
2234 | fschmid | 538 | hg->cbase = CurrTextBase; |
2247 | fschmid | 539 | hg->cshadowx = CurrTextShadowX; |
540 | hg->cshadowy = CurrTextShadowY; |
||
2257 | fschmid | 541 | hg->coutline = CurrTextOutline; |
2262 | fschmid | 542 | hg->cunderpos = CurrTextUnderPos; |
543 | hg->cunderwidth =CurrTextUnderWidth; |
||
2272 | fschmid | 544 | hg->cstrikepos = CurrTextStrikePos; |
545 | hg->cstrikewidth =CurrTextStrikeWidth; |
||
376 | Franz | 546 | chars->insert(i, hg); |
547 | i++; |
||
548 | } |
||
351 | Franz | 549 | } |
550 | } |
||
551 | |||
362 | Franz | 552 | void SEditor::insStyledText() |
553 | { |
||
554 | if (cBuffer.count() == 0) |
||
555 | return; |
||
556 | int p, i, p2, ccab; |
||
557 | if (hasSelectedText()) |
||
558 | deleteSel(); |
||
559 | getCursorPosition(&p, &i); |
||
560 | ChList *chars; |
||
561 | p2 = p; |
||
562 | if ((p >= static_cast<int>(StyledText.count())) || (StyledText.count() == 0)) |
||
563 | { |
||
564 | chars = new ChList; |
||
565 | chars->setAutoDelete(true); |
||
566 | chars->clear(); |
||
567 | p2 = static_cast<int>(StyledText.count()); |
||
382 | Franz | 568 | StyledText.append(chars); |
1065 | cbradney | 569 | ParagStyles.append(currentParaStyle); |
362 | Franz | 570 | } |
571 | else |
||
572 | chars = StyledText.at(p); |
||
573 | if (chars->count() != 0) |
||
574 | ccab = chars->at(0)->cab; |
||
575 | else |
||
1065 | cbradney | 576 | ccab = currentParaStyle; |
362 | Franz | 577 | for (uint a = 0; a < cBuffer.count()-1; ++a) |
578 | { |
||
579 | struct PtiSmall *hg; |
||
580 | if (cBuffer.at(a)->ch == QChar(13)) |
||
581 | { |
||
582 | ChList *chars2; |
||
583 | chars2 = new ChList; |
||
584 | chars2->setAutoDelete(true); |
||
585 | chars2->clear(); |
||
586 | if (p2 >= static_cast<int>(StyledText.count())) |
||
373 | Franz | 587 | { |
362 | Franz | 588 | StyledText.append(chars2); |
373 | Franz | 589 | ParagStyles.append(ccab); |
590 | } |
||
362 | Franz | 591 | else |
592 | { |
||
593 | int a = static_cast<int>(chars->count()); |
||
594 | for (int s = i; s < a; ++s) |
||
595 | { |
||
596 | chars2->append(chars->take(i)); |
||
597 | } |
||
598 | StyledText.insert(p2+1, chars2); |
||
373 | Franz | 599 | ParagStyles.insert(ParagStyles.at(p2+1), ccab); |
362 | Franz | 600 | } |
601 | p2++; |
||
602 | chars = StyledText.at(p2); |
||
603 | i = 0; |
||
604 | } |
||
605 | else |
||
606 | { |
||
607 | hg = new PtiSmall; |
||
608 | hg->ch = cBuffer.at(a)->ch; |
||
609 | hg->ccolor = cBuffer.at(a)->ccolor; |
||
610 | hg->cshade = cBuffer.at(a)->cshade; |
||
611 | hg->cstroke = cBuffer.at(a)->cstroke; |
||
612 | hg->cshade2 = cBuffer.at(a)->cshade2; |
||
613 | hg->cfont = cBuffer.at(a)->cfont; |
||
614 | hg->csize = cBuffer.at(a)->csize; |
||
615 | hg->cstyle = cBuffer.at(a)->cstyle; |
||
616 | hg->cab = ccab; |
||
617 | hg->cextra = cBuffer.at(a)->cextra; |
||
618 | hg->cscale = cBuffer.at(a)->cscale; |
||
2230 | fschmid | 619 | hg->cscalev = cBuffer.at(a)->cscalev; |
2234 | fschmid | 620 | hg->cbase = cBuffer.at(a)->cbase; |
2247 | fschmid | 621 | hg->cshadowx = cBuffer.at(a)->cshadowx; |
622 | hg->cshadowy = cBuffer.at(a)->cshadowy; |
||
2257 | fschmid | 623 | hg->coutline = cBuffer.at(a)->coutline; |
2262 | fschmid | 624 | hg->cunderpos = cBuffer.at(a)->cunderpos; |
625 | hg->cunderwidth = cBuffer.at(a)->cunderwidth; |
||
2272 | fschmid | 626 | hg->cstrikepos = cBuffer.at(a)->cstrikepos; |
627 | hg->cstrikewidth = cBuffer.at(a)->cstrikewidth; |
||
362 | Franz | 628 | chars->insert(i, hg); |
629 | i++; |
||
630 | } |
||
631 | } |
||
632 | } |
||
633 | |||
634 | void SEditor::copyStyledText() |
||
635 | { |
||
636 | int PStart, PEnd, SelStart, SelEnd, start, end; |
||
637 | ChList *chars; |
||
638 | struct PtiSmall *hg; |
||
639 | cBuffer.clear(); |
||
640 | getSelection(&PStart, &SelStart, &PEnd, &SelEnd); |
||
641 | for (int pa = PStart; pa < PEnd+1; ++pa) |
||
642 | { |
||
643 | chars = StyledText.at(pa); |
||
644 | if (pa == PStart) |
||
645 | start = SelStart; |
||
646 | else |
||
647 | start = 0; |
||
648 | if (pa == PEnd) |
||
649 | end = SelEnd; |
||
650 | else |
||
651 | end = chars->count(); |
||
652 | for (int ca = start; ca < end; ++ca) |
||
653 | { |
||
654 | hg = new PtiSmall; |
||
655 | hg->ch = chars->at(ca)->ch; |
||
656 | hg->cfont = chars->at(ca)->cfont; |
||
657 | hg->csize = chars->at(ca)->csize; |
||
658 | hg->ccolor = chars->at(ca)->ccolor; |
||
659 | hg->cshade = chars->at(ca)->cshade; |
||
660 | hg->cstroke = chars->at(ca)->cstroke; |
||
661 | hg->cshade2 = chars->at(ca)->cshade2; |
||
662 | hg->cscale = chars->at(ca)->cscale; |
||
2230 | fschmid | 663 | hg->cscalev = chars->at(ca)->cscalev; |
362 | Franz | 664 | hg->cstyle = chars->at(ca)->cstyle; |
665 | hg->cab = chars->at(ca)->cab; |
||
666 | hg->cextra = chars->at(ca)->cextra; |
||
2234 | fschmid | 667 | hg->cbase = chars->at(ca)->cbase; |
2247 | fschmid | 668 | hg->cshadowx = chars->at(ca)->cshadowx; |
669 | hg->cshadowy = chars->at(ca)->cshadowy; |
||
2257 | fschmid | 670 | hg->coutline = chars->at(ca)->coutline; |
2262 | fschmid | 671 | hg->cunderpos = chars->at(ca)->cunderpos; |
672 | hg->cunderwidth = chars->at(ca)->cunderwidth; |
||
2272 | fschmid | 673 | hg->cstrikepos = chars->at(ca)->cstrikepos; |
674 | hg->cstrikewidth = chars->at(ca)->cstrikewidth; |
||
362 | Franz | 675 | cBuffer.append(hg); |
676 | } |
||
677 | hg = new PtiSmall; |
||
678 | hg->ch = QChar(13); |
||
679 | hg->cfont = ""; |
||
680 | hg->csize = 1; |
||
681 | hg->ccolor = ""; |
||
682 | hg->cshade = 1; |
||
683 | hg->cstroke = ""; |
||
684 | hg->cshade2 = 1; |
||
2242 | fschmid | 685 | hg->cscale = 10; |
686 | hg->cscalev = 10; |
||
362 | Franz | 687 | hg->cstyle = 0; |
688 | hg->cab = 0; |
||
689 | hg->cextra = 0; |
||
2234 | fschmid | 690 | hg->cbase = 0; |
2247 | fschmid | 691 | hg->cshadowx = 50; |
692 | hg->cshadowy = -50; |
||
2257 | fschmid | 693 | hg->coutline = 10; |
2262 | fschmid | 694 | hg->cunderpos = -1; |
695 | hg->cunderwidth = -1; |
||
2272 | fschmid | 696 | hg->cstrikepos = -1; |
697 | hg->cstrikewidth = -1; |
||
362 | Franz | 698 | cBuffer.append(hg); |
699 | } |
||
700 | } |
||
701 | |||
1957 | cbradney | 702 | void SEditor::saveItemText(PageItem *currItem) |
351 | Franz | 703 | { |
704 | ChList *chars; |
||
1957 | cbradney | 705 | currItem->CPos = 0; |
706 | currItem->itemText.clear(); |
||
351 | Franz | 707 | uint c = 0; |
708 | for (uint p = 0; p < StyledText.count(); ++p) |
||
709 | { |
||
710 | if (p != 0) |
||
253 | Franz | 711 | { |
351 | Franz | 712 | c = StyledText.at(p-1)->count()-1; |
1065 | cbradney | 713 | struct ScText *hg; |
714 | hg = new ScText; |
||
351 | Franz | 715 | hg->ch = QChar(13); |
392 | Franz | 716 | chars = StyledText.at(p-1); |
351 | Franz | 717 | if (chars->count() != 0) |
253 | Franz | 718 | { |
1789 | fschmid | 719 | hg->cfont = (*doc->AllFonts)[chars->at(c)->cfont]; |
351 | Franz | 720 | hg->csize = chars->at(c)->csize; |
721 | hg->ccolor = chars->at(c)->ccolor; |
||
722 | hg->cshade = chars->at(c)->cshade; |
||
723 | hg->cstroke = chars->at(c)->cstroke; |
||
724 | hg->cshade2 = chars->at(c)->cshade2; |
||
725 | hg->cscale = chars->at(c)->cscale; |
||
2230 | fschmid | 726 | hg->cscalev = chars->at(c)->cscalev; |
351 | Franz | 727 | hg->cstyle = chars->at(c)->cstyle; |
728 | hg->cextra = chars->at(c)->cextra; |
||
2234 | fschmid | 729 | hg->cbase = chars->at(c)->cbase; |
2247 | fschmid | 730 | hg->cshadowx = chars->at(c)->cshadowx; |
731 | hg->cshadowy = chars->at(c)->cshadowy; |
||
2257 | fschmid | 732 | hg->coutline = chars->at(c)->coutline; |
2262 | fschmid | 733 | hg->cunderpos = chars->at(c)->cunderpos; |
734 | hg->cunderwidth = chars->at(c)->cunderwidth; |
||
2272 | fschmid | 735 | hg->cstrikepos = chars->at(c)->cstrikepos; |
736 | hg->cstrikewidth = chars->at(c)->cstrikewidth; |
||
253 | Franz | 737 | } |
351 | Franz | 738 | else |
739 | { |
||
740 | hg->ccolor = CurrTextFill; |
||
741 | hg->cshade = CurrTextFillSh; |
||
742 | hg->cstroke = CurrTextStroke; |
||
743 | hg->cshade2 = CurrTextStrokeSh; |
||
1789 | fschmid | 744 | hg->cfont = (*doc->AllFonts)[CurrFont]; |
351 | Franz | 745 | hg->csize = CurrFontSize; |
746 | hg->cstyle = CurrentStyle; |
||
747 | hg->cextra = CurrTextKern; |
||
748 | hg->cscale = CurrTextScale; |
||
2230 | fschmid | 749 | hg->cscalev = CurrTextScaleV; |
2234 | fschmid | 750 | hg->cbase = CurrTextBase; |
2247 | fschmid | 751 | hg->cshadowx = CurrTextShadowX; |
752 | hg->cshadowy = CurrTextShadowY; |
||
2257 | fschmid | 753 | hg->coutline = CurrTextOutline; |
2262 | fschmid | 754 | hg->cunderpos = CurrTextUnderPos; |
755 | hg->cunderwidth = CurrTextUnderWidth; |
||
2272 | fschmid | 756 | hg->cstrikepos = CurrTextStrikePos; |
757 | hg->cstrikewidth = CurrTextStrikeWidth; |
||
1065 | cbradney | 758 | if (doc->docParagraphStyles[ParagStyles[p-1]].Font != "") |
351 | Franz | 759 | { |
1789 | fschmid | 760 | hg->cfont = (*doc->AllFonts)[doc->docParagraphStyles[ParagStyles[p-1]].Font]; |
1065 | cbradney | 761 | hg->csize = doc->docParagraphStyles[ParagStyles[p-1]].FontSize; |
351 | Franz | 762 | } |
763 | } |
||
392 | Franz | 764 | hg->cab = ParagStyles[p-1]; |
351 | Franz | 765 | hg->cselect = false; |
766 | hg->xp = 0; |
||
767 | hg->yp = 0; |
||
768 | hg->PRot = 0; |
||
769 | hg->PtransX = 0; |
||
770 | hg->PtransY = 0; |
||
1957 | cbradney | 771 | currItem->itemText.append(hg); |
253 | Franz | 772 | } |
351 | Franz | 773 | chars = StyledText.at(p); |
774 | for (uint c = 0; c < chars->count(); ++c) |
||
775 | { |
||
1065 | cbradney | 776 | struct ScText *hg; |
777 | hg = new ScText; |
||
351 | Franz | 778 | hg->ch = chars->at(c)->ch; |
1789 | fschmid | 779 | hg->cfont = (*doc->AllFonts)[chars->at(c)->cfont]; |
351 | Franz | 780 | hg->csize = chars->at(c)->csize; |
781 | hg->ccolor = chars->at(c)->ccolor; |
||
782 | hg->cshade = chars->at(c)->cshade; |
||
783 | hg->cstroke = chars->at(c)->cstroke; |
||
784 | hg->cshade2 = chars->at(c)->cshade2; |
||
785 | hg->cscale = chars->at(c)->cscale; |
||
2230 | fschmid | 786 | hg->cscalev = chars->at(c)->cscalev; |
351 | Franz | 787 | hg->cstyle = chars->at(c)->cstyle; |
788 | hg->cab = chars->at(c)->cab; |
||
789 | hg->cextra = chars->at(c)->cextra; |
||
2234 | fschmid | 790 | hg->cbase = chars->at(c)->cbase; |
2247 | fschmid | 791 | hg->cshadowx = chars->at(c)->cshadowx; |
792 | hg->cshadowy = chars->at(c)->cshadowy; |
||
2257 | fschmid | 793 | hg->coutline = chars->at(c)->coutline; |
2262 | fschmid | 794 | hg->cunderpos = chars->at(c)->cunderpos; |
795 | hg->cunderwidth = chars->at(c)->cunderwidth; |
||
2272 | fschmid | 796 | hg->cstrikepos = chars->at(c)->cstrikepos; |
797 | hg->cstrikewidth = chars->at(c)->cstrikewidth; |
||
351 | Franz | 798 | hg->cselect = false; |
799 | hg->xp = 0; |
||
800 | hg->yp = 0; |
||
801 | hg->PRot = 0; |
||
802 | hg->PtransX = 0; |
||
803 | hg->PtransY = 0; |
||
1957 | cbradney | 804 | currItem->itemText.append(hg); |
351 | Franz | 805 | } |
253 | Franz | 806 | } |
351 | Franz | 807 | } |
808 | |||
809 | void SEditor::setAlign(int style) |
||
810 | { |
||
811 | int align = 0; |
||
812 | if (style > 4) |
||
1065 | cbradney | 813 | align = doc->docParagraphStyles[style].textAlignment; |
351 | Franz | 814 | else |
815 | align = style; |
||
816 | switch (align) |
||
167 | Franz | 817 | { |
351 | Franz | 818 | case 0: |
819 | setAlignment(Qt::AlignLeft); |
||
820 | break; |
||
821 | case 1: |
||
822 | setAlignment(Qt::AlignCenter); |
||
823 | break; |
||
824 | case 2: |
||
825 | setAlignment(Qt::AlignRight); |
||
826 | break; |
||
827 | case 3: |
||
828 | case 4: |
||
829 | setAlignment(Qt::AlignJustify); |
||
830 | break; |
||
831 | default: |
||
832 | break; |
||
167 | Franz | 833 | } |
351 | Franz | 834 | } |
835 | |||
1957 | cbradney | 836 | void SEditor::loadItemText(PageItem *currItem) |
351 | Franz | 837 | { |
1915 | fschmid | 838 | setUpdatesEnabled(false); |
351 | Franz | 839 | struct PtiSmall *hg; |
840 | QString Text = ""; |
||
841 | QString Ccol = ""; |
||
795 | fschmid | 842 | int Csha = 100; |
843 | int Csty = 0; |
||
351 | Franz | 844 | int Ali = 0; |
1957 | cbradney | 845 | PageItem *nextItem = currItem; |
351 | Franz | 846 | StyledText.clear(); |
373 | Franz | 847 | ParagStyles.clear(); |
351 | Franz | 848 | ChList *chars; |
849 | chars = new ChList; |
||
850 | chars->setAutoDelete(true); |
||
851 | chars->clear(); |
||
1957 | cbradney | 852 | while (nextItem != 0) |
167 | Franz | 853 | { |
1957 | cbradney | 854 | if (nextItem->BackBox != 0) |
855 | nextItem = nextItem->BackBox; |
||
351 | Franz | 856 | else |
857 | break; |
||
167 | Franz | 858 | } |
1957 | cbradney | 859 | if (nextItem != 0) |
253 | Franz | 860 | { |
1957 | cbradney | 861 | if (nextItem->itemText.count() != 0) |
351 | Franz | 862 | { |
1957 | cbradney | 863 | Ccol = nextItem->itemText.at(0)->ccolor; |
864 | Csha = nextItem->itemText.at(0)->cshade; |
||
865 | Csty = nextItem->itemText.at(0)->cstyle; |
||
866 | Ali = nextItem->itemText.at(0)->cab; |
||
351 | Franz | 867 | } |
868 | else |
||
869 | { |
||
1957 | cbradney | 870 | Ccol = currItem->TxtFill; |
871 | Csha = currItem->ShTxtFill; |
||
872 | Csha = currItem->TxTStyle; |
||
873 | Ali = currItem->textAlignment; |
||
351 | Franz | 874 | } |
875 | setAlign(Ali); |
||
876 | setFarbe(Ccol, Csha); |
||
877 | setStyle(Csty); |
||
253 | Franz | 878 | } |
1957 | cbradney | 879 | while (nextItem != 0) |
351 | Franz | 880 | { |
1957 | cbradney | 881 | for (uint a = 0; a < nextItem->itemText.count(); ++a) |
351 | Franz | 882 | { |
1957 | cbradney | 883 | if (nextItem->itemText.at(a)->ch == QChar(13)) |
351 | Franz | 884 | { |
885 | StyledText.append(chars); |
||
1957 | cbradney | 886 | ParagStyles.append(nextItem->itemText.at(a)->cab); |
887 | Ali = nextItem->itemText.at(a)->cab; |
||
351 | Franz | 888 | chars = new ChList; |
889 | chars->setAutoDelete(true); |
||
890 | chars->clear(); |
||
891 | Text += "\n"; |
||
892 | } |
||
893 | else |
||
894 | { |
||
895 | hg = new PtiSmall; |
||
1957 | cbradney | 896 | hg->ch = nextItem->itemText.at(a)->ch; |
897 | hg->cfont = nextItem->itemText.at(a)->cfont->SCName; |
||
898 | hg->csize = nextItem->itemText.at(a)->csize; |
||
899 | hg->ccolor = nextItem->itemText.at(a)->ccolor; |
||
900 | hg->cshade = nextItem->itemText.at(a)->cshade; |
||
901 | hg->cstroke = nextItem->itemText.at(a)->cstroke; |
||
902 | hg->cshade2 = nextItem->itemText.at(a)->cshade2; |
||
903 | hg->cscale = nextItem->itemText.at(a)->cscale; |
||
2230 | fschmid | 904 | hg->cscalev = nextItem->itemText.at(a)->cscalev; |
1957 | cbradney | 905 | hg->cstyle = nextItem->itemText.at(a)->cstyle; |
906 | hg->cab = nextItem->itemText.at(a)->cab; |
||
907 | hg->cextra = nextItem->itemText.at(a)->cextra; |
||
2234 | fschmid | 908 | hg->cbase = nextItem->itemText.at(a)->cbase; |
2247 | fschmid | 909 | hg->cshadowx = nextItem->itemText.at(a)->cshadowx; |
910 | hg->cshadowy = nextItem->itemText.at(a)->cshadowy; |
||
2257 | fschmid | 911 | hg->coutline = nextItem->itemText.at(a)->coutline; |
2262 | fschmid | 912 | hg->cunderpos = nextItem->itemText.at(a)->cunderpos; |
913 | hg->cunderwidth = nextItem->itemText.at(a)->cunderwidth; |
||
2272 | fschmid | 914 | hg->cstrikepos = nextItem->itemText.at(a)->cstrikepos; |
915 | hg->cstrikewidth = nextItem->itemText.at(a)->cstrikewidth; |
||
351 | Franz | 916 | if ((Ccol == hg->ccolor) && (Ali == hg->cab) && (Csha == hg->cshade) && (Csty == hg->cstyle)) |
917 | { |
||
2319 | cbradney | 918 | if (hg->ch == QChar(ScApp->scrActions["specialPageNumber"]->actionInt())) |
351 | Franz | 919 | { |
920 | setFarbe(Ccol, Csha); |
||
921 | setAlign(Ali); |
||
922 | setStyle(Csty); |
||
923 | insert(Text); |
||
924 | insert("#"); |
||
925 | Text = ""; |
||
926 | chars->append(hg); |
||
927 | continue; |
||
928 | } |
||
2319 | cbradney | 929 | else if (hg->ch == QChar(ScApp->scrActions["specialNonBreakingSpace"]->actionInt())) |
2318 | fschmid | 930 | { |
931 | setFarbe(Ccol, Csha); |
||
932 | setAlign(Ali); |
||
933 | setStyle(Csty); |
||
934 | insert(Text); |
||
935 | insert("_"); |
||
936 | Text = ""; |
||
937 | chars->append(hg); |
||
938 | continue; |
||
939 | } |
||
351 | Franz | 940 | else |
941 | Text += hg->ch; |
||
942 | } |
||
943 | else |
||
944 | { |
||
945 | setFarbe(Ccol, Csha); |
||
946 | setAlign(Ali); |
||
947 | setStyle(Csty); |
||
948 | insert(Text); |
||
949 | Text = hg->ch; |
||
950 | Ccol = hg->ccolor; |
||
951 | Csha = hg->cshade; |
||
952 | Csty = hg->cstyle; |
||
953 | Ali = hg->cab; |
||
954 | } |
||
955 | chars->append(hg); |
||
956 | } |
||
957 | } |
||
1957 | cbradney | 958 | nextItem = nextItem->NextBox; |
351 | Franz | 959 | } |
960 | setAlign(Ali); |
||
961 | setFarbe(Ccol, Csha); |
||
962 | setStyle(Csty); |
||
963 | insert(Text); |
||
876 | fschmid | 964 | StyledText.append(chars); |
965 | ParagStyles.append(Ali); |
||
351 | Franz | 966 | if (StyledText.count() != 0) |
967 | emit setProps(0, 0); |
||
1915 | fschmid | 968 | setUpdatesEnabled(true); |
351 | Franz | 969 | setCursorPosition(0, 0); |
102 | Franz | 970 | } |
971 | |||
1957 | cbradney | 972 | void SEditor::loadText(QString tx, PageItem *currItem) |
102 | Franz | 973 | { |
1915 | fschmid | 974 | setUpdatesEnabled(false); |
351 | Franz | 975 | struct PtiSmall *hg; |
976 | QString Text = ""; |
||
977 | StyledText.clear(); |
||
373 | Franz | 978 | ParagStyles.clear(); |
351 | Franz | 979 | ChList *chars; |
980 | chars = new ChList; |
||
981 | chars->setAutoDelete(true); |
||
982 | chars->clear(); |
||
1957 | cbradney | 983 | setAlign(currItem->textAlignment); |
984 | setFarbe(currItem->TxtFill, currItem->ShTxtFill); |
||
985 | setStyle(currItem->TxTStyle); |
||
351 | Franz | 986 | for (uint a = 0; a < tx.length(); ++a) |
987 | { |
||
988 | if (tx[a] == QChar(13)) |
||
989 | { |
||
990 | StyledText.append(chars); |
||
1957 | cbradney | 991 | ParagStyles.append(currItem->textAlignment); |
351 | Franz | 992 | chars = new ChList; |
993 | chars->setAutoDelete(true); |
||
994 | chars->clear(); |
||
995 | Text += "\n"; |
||
996 | } |
||
997 | else |
||
998 | { |
||
999 | hg = new PtiSmall; |
||
1000 | hg->ch = tx[a]; |
||
1957 | cbradney | 1001 | hg->cfont = currItem->IFont; |
1002 | hg->csize = currItem->ISize; |
||
1003 | hg->ccolor = currItem->TxtFill; |
||
1004 | hg->cshade = currItem->ShTxtFill; |
||
1005 | hg->cstroke = currItem->TxtStroke; |
||
1006 | hg->cshade2 = currItem->ShTxtStroke; |
||
1007 | hg->cscale = currItem->TxtScale; |
||
2230 | fschmid | 1008 | hg->cscalev = currItem->TxtScaleV; |
2234 | fschmid | 1009 | hg->cbase = currItem->TxtBase; |
2247 | fschmid | 1010 | hg->cshadowx = currItem->TxtShadowX; |
1011 | hg->cshadowy = currItem->TxtShadowY; |
||
2257 | fschmid | 1012 | hg->coutline = currItem->TxtOutline; |
2262 | fschmid | 1013 | hg->cunderpos = currItem->TxtUnderPos; |
1014 | hg->cunderwidth = currItem->TxtUnderWidth; |
||
2272 | fschmid | 1015 | hg->cstrikepos = currItem->TxtStrikePos; |
1016 | hg->cstrikewidth = currItem->TxtStrikeWidth; |
||
1957 | cbradney | 1017 | hg->cstyle = currItem->TxTStyle; |
1018 | hg->cab = currItem->textAlignment; |
||
351 | Franz | 1019 | hg->cextra = 0; |
1020 | Text += hg->ch; |
||
1021 | chars->append(hg); |
||
1022 | } |
||
1023 | } |
||
1024 | insert(Text); |
||
876 | fschmid | 1025 | StyledText.append(chars); |
1957 | cbradney | 1026 | ParagStyles.append(currItem->textAlignment); |
351 | Franz | 1027 | if (StyledText.count() != 0) |
1028 | emit setProps(0, 0); |
||
1915 | fschmid | 1029 | setUpdatesEnabled(true); |
351 | Franz | 1030 | setCursorPosition(0, 0); |
102 | Franz | 1031 | } |
1032 | |||
366 | Franz | 1033 | void SEditor::updateAll() |
1034 | { |
||
1035 | if (StyledText.count() == 0) |
||
1036 | return; |
||
1915 | fschmid | 1037 | setUpdatesEnabled(false); |
366 | Franz | 1038 | int p, i; |
1039 | getCursorPosition(&p, &i); |
||
1040 | clear(); |
||
1041 | struct PtiSmall *hg; |
||
1042 | QString Text = ""; |
||
1043 | QString Ccol = ""; |
||
1044 | int Csha; |
||
1045 | int Csty; |
||
1046 | int Ali = 0; |
||
1047 | ChList *chars = StyledText.at(0); |
||
1048 | if (chars->count() != 0) |
||
1049 | { |
||
1050 | Ccol = chars->at(0)->ccolor; |
||
1051 | Csha = chars->at(0)->cshade; |
||
1052 | Csty = chars->at(0)->cstyle; |
||
1053 | Ali = chars->at(0)->cab; |
||
1054 | } |
||
1055 | else |
||
1056 | { |
||
1057 | Ccol = CurrTextFill; |
||
1058 | Csha = CurrTextFillSh; |
||
1059 | Csty = CurrentStyle; |
||
1065 | cbradney | 1060 | Ali = currentParaStyle; |
366 | Franz | 1061 | } |
1062 | setAlign(Ali); |
||
1063 | setFarbe(Ccol, Csha); |
||
1064 | setStyle(Csty); |
||
1065 | for (uint pa = 0; pa < StyledText.count(); ++pa) |
||
1066 | { |
||
1067 | chars = StyledText.at(pa); |
||
1068 | if ((chars->count() == 0) && (pa < StyledText.count()-1)) |
||
1069 | { |
||
1070 | Text += "\n"; |
||
1071 | continue; |
||
1072 | } |
||
1073 | for (uint a = 0; a < chars->count(); ++a) |
||
1074 | { |
||
1075 | hg = chars->at(a); |
||
1076 | if ((Ccol == hg->ccolor) && (Ali == hg->cab) && (Csha == hg->cshade) && (Csty == hg->cstyle)) |
||
1077 | { |
||
1078 | if (hg->ch == QChar(30)) |
||
1079 | { |
||
1080 | setFarbe(Ccol, Csha); |
||
1081 | setAlign(Ali); |
||
1082 | setStyle(Csty); |
||
1083 | insert(Text); |
||
1084 | insert("#"); |
||
1085 | Text = ""; |
||
1086 | continue; |
||
1087 | } |
||
1088 | else |
||
1089 | Text += hg->ch; |
||
1090 | } |
||
1091 | else |
||
1092 | { |
||
1093 | setFarbe(Ccol, Csha); |
||
1094 | setAlign(Ali); |
||
1095 | setStyle(Csty); |
||
1096 | insert(Text); |
||
1097 | Text = hg->ch; |
||
1098 | Ccol = hg->ccolor; |
||
1099 | Csha = hg->cshade; |
||
1100 | Csty = hg->cstyle; |
||
1101 | Ali = hg->cab; |
||
1102 | } |
||
1103 | } |
||
1104 | if (pa < StyledText.count()-1) |
||
1105 | Text += "\n"; |
||
1106 | } |
||
1107 | setAlign(Ali); |
||
1108 | setFarbe(Ccol, Csha); |
||
1109 | setStyle(Csty); |
||
1110 | insert(Text); |
||
1915 | fschmid | 1111 | setUpdatesEnabled(true); |
366 | Franz | 1112 | setCursorPosition(p, i); |
1113 | } |
||
1114 | |||
351 | Franz | 1115 | void SEditor::updateFromChars(int pa) |
102 | Franz | 1116 | { |
351 | Franz | 1117 | ChList *chars = StyledText.at(pa); |
1118 | if (chars->count() == 0) |
||
1119 | return; |
||
1915 | fschmid | 1120 | setUpdatesEnabled(false); |
351 | Franz | 1121 | int SelStart = 0; |
1122 | int SelEnd = 0; |
||
1123 | int p, i; |
||
1124 | getCursorPosition(&p, &i); |
||
1125 | removeSelection(); |
||
1126 | QString Ccol = chars->at(0)->ccolor; |
||
1127 | int Csha = chars->at(0)->cshade; |
||
1128 | int Csty = chars->at(0)->cstyle; |
||
1129 | for (uint a = 0; a < chars->count(); ++a) |
||
167 | Franz | 1130 | { |
351 | Franz | 1131 | if ((Ccol == chars->at(a)->ccolor) && (Csha == chars->at(a)->cshade) && (Csty == chars->at(a)->cstyle)) |
1132 | SelEnd++; |
||
1133 | else |
||
167 | Franz | 1134 | { |
351 | Franz | 1135 | setSelection(pa, SelStart, pa, SelEnd); |
1136 | setFarbe(Ccol, Csha); |
||
1137 | setStyle(Csty); |
||
1138 | removeSelection(); |
||
1139 | Ccol = chars->at(a)->ccolor; |
||
1140 | Csha = chars->at(a)->cshade; |
||
1141 | Csty = chars->at(a)->cstyle; |
||
362 | Franz | 1142 | SelStart = SelEnd; |
351 | Franz | 1143 | SelEnd++; |
167 | Franz | 1144 | } |
351 | Franz | 1145 | } |
1146 | setSelection(pa, SelStart, pa, SelEnd); |
||
1147 | setFarbe(Ccol, Csha); |
||
1148 | setStyle(Csty); |
||
1149 | removeSelection(); |
||
362 | Franz | 1150 | setAlign(chars->at(0)->cab); |
1915 | fschmid | 1151 | setUpdatesEnabled(true); |
351 | Franz | 1152 | setCursorPosition(p, i); |
1153 | } |
||
1154 | |||
1155 | /* updates the internal PtiSmall structure, to be useable for all members of the PtiSmall struct |
||
1156 | there is a code as first parameter to indicate which member should be updated. |
||
1157 | |||
1158 | 1 = Stroke Colour and Stroke Shade |
||
1159 | 2 = Font |
||
1160 | 3 = Font Size |
||
1161 | 4 = Character Style |
||
1162 | 5 = Character Scaling |
||
1163 | 6 = Kerning |
||
2230 | fschmid | 1164 | 7 = Character Scaling Vertical |
2257 | fschmid | 1165 | 8 = Character Shadow |
1166 | 9 = Character Outline |
||
2262 | fschmid | 1167 | 10 = Character Underline |
2272 | fschmid | 1168 | 11 = Character Strikethru |
351 | Franz | 1169 | */ |
1170 | void SEditor::updateSel(int code, struct PtiSmall *hg) |
||
1171 | { |
||
1172 | int PStart, PEnd, SelStart, SelEnd, start, end; |
||
1173 | ChList *chars; |
||
385 | Franz | 1174 | if (StoredSel) |
1175 | { |
||
1176 | setSelection(SelParaStart, SelCharStart, SelParaEnd, SelCharEnd); |
||
1177 | StoredSel = false; |
||
1178 | } |
||
351 | Franz | 1179 | getSelection(&PStart, &SelStart, &PEnd, &SelEnd); |
1180 | for (int pa = PStart; pa < PEnd+1; ++pa) |
||
1181 | { |
||
1182 | chars = StyledText.at(pa); |
||
1183 | if (pa == PStart) |
||
1184 | start = SelStart; |
||
1185 | else |
||
1186 | start = 0; |
||
1187 | if (pa == PEnd) |
||
1188 | end = SelEnd; |
||
1189 | else |
||
1190 | end = chars->count(); |
||
1191 | for (int ca = start; ca < end; ++ca) |
||
167 | Franz | 1192 | { |
351 | Franz | 1193 | switch (code) |
167 | Franz | 1194 | { |
351 | Franz | 1195 | case 0: |
1196 | chars->at(ca)->ccolor = hg->ccolor; |
||
1197 | chars->at(ca)->cshade = hg->cshade; |
||
1198 | break; |
||
217 | Franz | 1199 | case 1: |
351 | Franz | 1200 | chars->at(ca)->cstroke = hg->cstroke; |
1201 | chars->at(ca)->cshade2 = hg->cshade2; |
||
111 | Franz | 1202 | break; |
217 | Franz | 1203 | case 2: |
351 | Franz | 1204 | chars->at(ca)->cfont = hg->cfont; |
217 | Franz | 1205 | break; |
1206 | case 3: |
||
351 | Franz | 1207 | chars->at(ca)->csize = hg->csize; |
111 | Franz | 1208 | break; |
351 | Franz | 1209 | case 4: |
2188 | fschmid | 1210 | chars->at(ca)->cstyle &= ~1919; |
351 | Franz | 1211 | chars->at(ca)->cstyle |= hg->cstyle; |
102 | Franz | 1212 | break; |
351 | Franz | 1213 | case 5: |
1214 | chars->at(ca)->cscale = hg->cscale; |
||
102 | Franz | 1215 | break; |
351 | Franz | 1216 | case 6: |
1217 | chars->at(ca)->cextra = hg->cextra; |
||
102 | Franz | 1218 | break; |
2230 | fschmid | 1219 | case 7: |
1220 | chars->at(ca)->cscalev = hg->cscalev; |
||
1221 | break; |
||
2254 | fschmid | 1222 | case 8: |
1223 | chars->at(ca)->cshadowx = hg->cshadowx; |
||
1224 | chars->at(ca)->cshadowy = hg->cshadowy; |
||
1225 | break; |
||
2257 | fschmid | 1226 | case 9: |
1227 | chars->at(ca)->coutline = hg->coutline; |
||
1228 | break; |
||
2262 | fschmid | 1229 | case 10: |
1230 | chars->at(ca)->cunderpos = hg->cunderpos; |
||
1231 | chars->at(ca)->cunderwidth = hg->cunderwidth; |
||
1232 | break; |
||
2272 | fschmid | 1233 | case 11: |
1234 | chars->at(ca)->cstrikepos = hg->cstrikepos; |
||
1235 | chars->at(ca)->cstrikewidth = hg->cstrikewidth; |
||
1236 | break; |
||
351 | Franz | 1237 | default: |
1238 | break; |
||
167 | Franz | 1239 | } |
102 | Franz | 1240 | } |
167 | Franz | 1241 | } |
102 | Franz | 1242 | } |
1243 | |||
351 | Franz | 1244 | void SEditor::deleteSel() |
102 | Franz | 1245 | { |
351 | Franz | 1246 | int PStart, PEnd, SelStart, SelEnd, start, end; |
800 | fschmid | 1247 | ChList *chars = NULL; |
351 | Franz | 1248 | getSelection(&PStart, &SelStart, &PEnd, &SelEnd); |
1249 | if (PStart == PEnd) |
||
1250 | { |
||
1251 | chars = StyledText.at(PStart); |
||
1252 | for (int a = 0; a < SelEnd-SelStart; ++a) |
||
1253 | { |
||
1254 | chars->remove(SelStart); |
||
1255 | } |
||
1256 | } |
||
1257 | else |
||
1258 | { |
||
1259 | for (int pa = PStart; pa < PEnd+1; ++pa) |
||
1260 | { |
||
367 | Franz | 1261 | bool noChar = false; |
1262 | if (pa >= static_cast<int>(StyledText.count())) |
||
1263 | noChar = true; |
||
1264 | else |
||
1265 | chars = StyledText.at(pa); |
||
351 | Franz | 1266 | if (pa == PStart) |
1267 | start = SelStart; |
||
1268 | else |
||
1269 | start = 0; |
||
1270 | if (pa == PEnd) |
||
1271 | end = SelEnd; |
||
1272 | else |
||
1273 | { |
||
367 | Franz | 1274 | if (noChar) |
1275 | end = 0; |
||
1276 | else |
||
1277 | end = chars->count(); |
||
351 | Franz | 1278 | } |
367 | Franz | 1279 | if (!noChar) |
1280 | { |
||
1281 | for (int ca = 0; ca < end-start; ++ca) |
||
1282 | { |
||
1283 | chars->remove(start); |
||
1284 | } |
||
1285 | } |
||
351 | Franz | 1286 | } |
1287 | if (PEnd-PStart > 1) |
||
1288 | { |
||
1289 | for (int pa2 = 0; pa2 < PEnd - PStart - 1; ++pa2) |
||
1290 | { |
||
367 | Franz | 1291 | if (PStart+1 < static_cast<int>(StyledText.count())) |
373 | Franz | 1292 | { |
367 | Franz | 1293 | StyledText.remove(PStart+1); |
373 | Franz | 1294 | ParagStyles.remove(ParagStyles.at(PStart+1)); |
1295 | } |
||
351 | Franz | 1296 | } |
1297 | } |
||
367 | Franz | 1298 | if (PStart+1 < static_cast<int>(StyledText.count())) |
351 | Franz | 1299 | { |
367 | Franz | 1300 | struct PtiSmall *hg; |
1301 | ChList *chars2 = StyledText.at(PStart+1); |
||
1302 | chars = StyledText.at(PStart); |
||
1303 | int a = static_cast<int>(chars2->count()); |
||
1304 | if (a > 0) |
||
351 | Franz | 1305 | { |
367 | Franz | 1306 | int ca; |
1307 | if (chars->count() > 0) |
||
1308 | ca = chars->at(0)->cab; |
||
1309 | else |
||
1065 | cbradney | 1310 | ca = currentParaStyle; |
367 | Franz | 1311 | for (int s = 0; s < a; ++s) |
1312 | { |
||
1313 | hg = chars2->take(0); |
||
1314 | hg->cab = ca; |
||
1315 | chars->append(hg); |
||
1316 | } |
||
351 | Franz | 1317 | } |
367 | Franz | 1318 | StyledText.remove(PStart+1); |
373 | Franz | 1319 | ParagStyles.remove(ParagStyles.at(PStart+1)); |
351 | Franz | 1320 | } |
1321 | } |
||
1322 | setCursorPosition(PStart, SelStart); |
||
102 | Franz | 1323 | } |
1324 | |||
351 | Franz | 1325 | void SEditor::setStyle(int Csty) |
102 | Franz | 1326 | { |
351 | Franz | 1327 | if (Csty & 8) |
1328 | setUnderline(true); |
||
1329 | else |
||
1330 | setUnderline(false); |
||
374 | Franz | 1331 | QFont f = currentFont(); |
1332 | if (Csty & 16) |
||
1333 | f.setStrikeOut(true); |
||
1334 | else |
||
1335 | f.setStrikeOut(false); |
||
1336 | setCurrentFont(f); |
||
351 | Franz | 1337 | if (Csty & 1) |
1338 | setVerticalAlignment(AlignSuperScript); |
||
1339 | else if (Csty & 2) |
||
1340 | setVerticalAlignment(AlignSubScript); |
||
1341 | else |
||
1342 | setVerticalAlignment(AlignNormal); |
||
1343 | } |
||
1344 | |||
1345 | void SEditor::setFarbe(QString farbe, int shad) |
||
1346 | { |
||
1347 | int h, s, v, sneu; |
||
1348 | QColor tmp; |
||
1349 | doc->PageColors[farbe].getRGBColor().rgb(&h, &s, &v); |
||
1350 | if ((h == s) && (s == v)) |
||
191 | Franz | 1351 | { |
351 | Franz | 1352 | doc->PageColors[farbe].getRGBColor().hsv(&h, &s, &v); |
1353 | sneu = 255 - ((255 - v) * shad / 100); |
||
1354 | tmp.setHsv(h, s, sneu); |
||
191 | Franz | 1355 | } |
351 | Franz | 1356 | else |
1357 | { |
||
1358 | doc->PageColors[farbe].getRGBColor().hsv(&h, &s, &v); |
||
1359 | sneu = s * shad / 100; |
||
1360 | tmp.setHsv(h, sneu, v); |
||
1361 | } |
||
1362 | setColor(tmp); |
||
1363 | } |
||
103 | Franz | 1364 | |
362 | Franz | 1365 | void SEditor::copy() |
1366 | { |
||
372 | Franz | 1367 | emit SideBarUp(false); |
362 | Franz | 1368 | if ((hasSelectedText()) && (selectedText() != "")) |
1369 | { |
||
376 | Franz | 1370 | disconnect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
399 | Franz | 1371 | disconnect(QApplication::clipboard(), SIGNAL(selectionChanged()), this, SLOT(SelClipChange())); |
362 | Franz | 1372 | tBuffer = selectedText(); |
1373 | copyStyledText(); |
||
376 | Franz | 1374 | QApplication::clipboard()->setText(tBuffer, QClipboard::Clipboard); |
1375 | ClipData = 1; |
||
1376 | connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
||
399 | Franz | 1377 | connect(QApplication::clipboard(), SIGNAL(selectionChanged()), this, SLOT(SelClipChange())); |
376 | Franz | 1378 | emit PasteAvail(); |
362 | Franz | 1379 | } |
372 | Franz | 1380 | emit SideBarUp(true); |
362 | Franz | 1381 | } |
1382 | |||
351 | Franz | 1383 | void SEditor::cut() |
1384 | { |
||
362 | Franz | 1385 | copy(); |
372 | Franz | 1386 | emit SideBarUp(false); |
362 | Franz | 1387 | if (hasSelectedText()) |
1388 | { |
||
1389 | deleteSel(); |
||
1390 | removeSelectedText(); |
||
1391 | } |
||
372 | Franz | 1392 | emit SideBarUp(true); |
1393 | emit SideBarUpdate(); |
||
351 | Franz | 1394 | } |
1395 | |||
1396 | void SEditor::paste() |
||
1397 | { |
||
372 | Franz | 1398 | emit SideBarUp(false); |
362 | Franz | 1399 | int p, i; |
399 | Franz | 1400 | QString data = ""; |
362 | Franz | 1401 | getCursorPosition(&p, &i); |
399 | Franz | 1402 | if (ClipData == 1) |
1403 | insStyledText(); |
||
1404 | else |
||
376 | Franz | 1405 | { |
399 | Franz | 1406 | QString data = QApplication::clipboard()->text(QClipboard::Selection); |
1407 | if (data.isNull()) |
||
1408 | data = QApplication::clipboard()->text(QClipboard::Clipboard); |
||
376 | Franz | 1409 | if (!data.isNull()) |
1410 | { |
||
1411 | data.replace(QRegExp("\r"), ""); |
||
1412 | data.replace(QRegExp("\n"), QChar(13)); |
||
1413 | insChars(data); |
||
399 | Franz | 1414 | ClipData = 2; |
1415 | emit PasteAvail(); |
||
376 | Franz | 1416 | } |
399 | Franz | 1417 | else |
1418 | { |
||
1419 | emit SideBarUp(true); |
||
1420 | return; |
||
1421 | } |
||
376 | Franz | 1422 | } |
374 | Franz | 1423 | updateAll(); |
1915 | fschmid | 1424 | sync(); |
1425 | repaintContents(); |
||
372 | Franz | 1426 | emit SideBarUp(true); |
1427 | emit SideBarUpdate(); |
||
351 | Franz | 1428 | } |
1429 | |||
374 | Franz | 1430 | QPopupMenu* SEditor::createPopupMenu(const QPoint & pos) |
1431 | { |
||
1432 | QPopupMenu *p = QTextEdit::createPopupMenu(pos); |
||
1433 | p->removeItemAt(0); |
||
1434 | p->removeItemAt(0); |
||
1435 | p->removeItemAt(0); |
||
1436 | p->removeItemAt(3); |
||
1437 | return p; |
||
1438 | } |
||
1439 | |||
399 | Franz | 1440 | void SEditor::SelClipChange() |
1441 | { |
||
1442 | ClipData = 3; |
||
1443 | emit PasteAvail(); |
||
1444 | } |
||
1445 | |||
376 | Franz | 1446 | void SEditor::ClipChange() |
1447 | { |
||
1448 | ClipData = 2; |
||
1449 | emit PasteAvail(); |
||
1450 | } |
||
1451 | |||
351 | Franz | 1452 | /* Toolbar for Fill Colour */ |
352 | Franz | 1453 | SToolBColorF::SToolBColorF(QMainWindow* parent, ScribusDoc *doc) : QToolBar( tr("Fill Color Settings"), parent) |
351 | Franz | 1454 | { |
1455 | FillIcon = new QLabel( "", this, "FillIcon" ); |
||
1456 | FillIcon->setPixmap(loadIcon("fill.png")); |
||
1457 | FillIcon->setScaledContents( false ); |
||
1458 | TxFill = new QComboBox( true, this, "TxFill" ); |
||
1459 | TxFill->setEditable(false); |
||
1460 | PM2 = new ShadeButton(this); |
||
1461 | TxFill->clear(); |
||
1065 | cbradney | 1462 | ColorList::Iterator it; |
351 | Franz | 1463 | QPixmap pm = QPixmap(15, 15); |
1464 | TxFill->insertItem( tr("None")); |
||
1465 | for (it = doc->PageColors.begin(); it != doc->PageColors.end(); ++it) |
||
1466 | { |
||
1467 | pm.fill(doc->PageColors[it.key()].getRGBColor()); |
||
1468 | TxFill->insertItem(pm, it.key()); |
||
1469 | } |
||
1470 | TxFill->listBox()->setMinimumWidth(TxFill->listBox()->maxItemWidth()+24); |
||
1471 | QToolTip::add( TxFill, tr( "Color of text fill" ) ); |
||
1472 | QToolTip::add( PM2, tr( "Saturation of color of text fill" ) ); |
||
1473 | connect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1474 | connect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1475 | } |
||
1476 | |||
1477 | void SToolBColorF::SetColor(int c) |
||
1478 | { |
||
1479 | disconnect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1480 | TxFill->setCurrentItem(c); |
||
1481 | connect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1482 | } |
||
1483 | |||
1484 | void SToolBColorF::SetShade(int s) |
||
1485 | { |
||
1486 | disconnect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1487 | PM2->setValue(s); |
||
1488 | connect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1489 | } |
||
1490 | |||
1491 | void SToolBColorF::newShadeHandler() |
||
1492 | { |
||
1493 | emit NewColor(TxFill->currentItem(), PM2->getValue()); |
||
1494 | } |
||
1495 | |||
1496 | /* Toolbar for Stroke Colour */ |
||
352 | Franz | 1497 | SToolBColorS::SToolBColorS(QMainWindow* parent, ScribusDoc *doc) : QToolBar( tr("Stroke Color Settings"), parent) |
351 | Franz | 1498 | { |
1499 | StrokeIcon = new QLabel( "", this, "StrokeIcon" ); |
||
1500 | StrokeIcon->setPixmap(loadIcon("Stiftalt.xpm")); |
||
1501 | StrokeIcon->setScaledContents( false ); |
||
1502 | TxStroke = new QComboBox( true, this, "TxStroke" ); |
||
1503 | TxStroke->setEditable(false); |
||
1504 | PM1 = new ShadeButton(this); |
||
1505 | TxStroke->clear(); |
||
1065 | cbradney | 1506 | ColorList::Iterator it; |
351 | Franz | 1507 | QPixmap pm = QPixmap(15, 15); |
1508 | TxStroke->insertItem( tr("None")); |
||
1509 | for (it = doc->PageColors.begin(); it != doc->PageColors.end(); ++it) |
||
1510 | { |
||
1511 | pm.fill(doc->PageColors[it.key()].getRGBColor()); |
||
1512 | TxStroke->insertItem(pm, it.key()); |
||
1513 | } |
||
1514 | TxStroke->listBox()->setMinimumWidth(TxStroke->listBox()->maxItemWidth()+24); |
||
1515 | QToolTip::add( TxStroke, tr( "Color of text stroke" ) ); |
||
1516 | QToolTip::add( PM1, tr( "Saturation of color of text stroke" ) ); |
||
1517 | connect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1518 | connect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1519 | } |
||
1520 | |||
1521 | void SToolBColorS::SetColor(int c) |
||
1522 | { |
||
1523 | disconnect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1524 | TxStroke->setCurrentItem(c); |
||
1525 | connect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
1526 | } |
||
1527 | |||
1528 | void SToolBColorS::SetShade(int s) |
||
1529 | { |
||
1530 | disconnect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1531 | PM1->setValue(s); |
||
1532 | connect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
1533 | } |
||
1534 | |||
1535 | void SToolBColorS::newShadeHandler() |
||
1536 | { |
||
1537 | emit NewColor(TxStroke->currentItem(), PM1->getValue()); |
||
1538 | } |
||
1539 | |||
1540 | /* Toolbar for Character Style Settings */ |
||
352 | Franz | 1541 | SToolBStyle::SToolBStyle(QMainWindow* parent) : QToolBar( tr("Character Settings"), parent) |
351 | Franz | 1542 | { |
1543 | SeStyle = new StyleSelect(this); |
||
1845 | cbradney | 1544 | trackingLabel = new QLabel( tr( "Tracking:" ), this, "trackingLabel" ); |
351 | Franz | 1545 | Extra = new MSpinBox( this, 1 ); |
1546 | Extra->setValues( -300, 300, 10, 0); |
||
1547 | Extra->setSuffix( tr( " pt" ) ); |
||
1845 | cbradney | 1548 | QToolTip::add( Extra, tr( "Manual Tracking" ) ); |
716 | cbradney | 1549 | connect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
351 | Franz | 1550 | connect(Extra, SIGNAL(valueChanged(int)), this, SLOT(newKernHandler())); |
2254 | fschmid | 1551 | connect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
1552 | connect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
||
2257 | fschmid | 1553 | connect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newOutlineHandler())); |
2262 | fschmid | 1554 | connect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
1555 | connect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
||
2272 | fschmid | 1556 | connect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
1557 | connect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
||
351 | Franz | 1558 | } |
1559 | |||
2272 | fschmid | 1560 | void SToolBStyle::newStrikeHandler() |
1561 | { |
||
1562 | int x = qRound(SeStyle->StrikeVal->LPos->value() * 10.0); |
||
1563 | int y = qRound(SeStyle->StrikeVal->LWidth->value() * 10.0); |
||
1564 | emit newUnderline(x, y); |
||
1565 | } |
||
1566 | |||
2262 | fschmid | 1567 | void SToolBStyle::newUnderlineHandler() |
1568 | { |
||
1569 | int x = qRound(SeStyle->UnderlineVal->LPos->value() * 10.0); |
||
1570 | int y = qRound(SeStyle->UnderlineVal->LWidth->value() * 10.0); |
||
1571 | emit newUnderline(x, y); |
||
1572 | } |
||
1573 | |||
2257 | fschmid | 1574 | void SToolBStyle::newOutlineHandler() |
1575 | { |
||
1576 | int x = qRound(SeStyle->OutlineVal->LWidth->value() * 10.0); |
||
1577 | emit newOutline(x); |
||
1578 | } |
||
1579 | |||
2254 | fschmid | 1580 | void SToolBStyle::newShadowHandler() |
1581 | { |
||
1582 | int x = qRound(SeStyle->ShadowVal->Xoffset->value() * 10.0); |
||
1583 | int y = qRound(SeStyle->ShadowVal->Yoffset->value() * 10.0); |
||
1584 | emit NewShadow(x, y); |
||
1585 | } |
||
1586 | |||
351 | Franz | 1587 | void SToolBStyle::newKernHandler() |
1588 | { |
||
1589 | emit NewKern(Extra->value()); |
||
1590 | } |
||
1591 | |||
2257 | fschmid | 1592 | void SToolBStyle::setOutline(int x) |
1593 | { |
||
1594 | disconnect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newOutlineHandler())); |
||
1595 | SeStyle->OutlineVal->LWidth->setValue(x / 10.0); |
||
1596 | connect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newOutlineHandler())); |
||
1597 | } |
||
1598 | |||
2272 | fschmid | 1599 | void SToolBStyle::setStrike(int p, int w) |
1600 | { |
||
1601 | disconnect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
||
1602 | disconnect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
||
1603 | SeStyle->StrikeVal->LWidth->setValue(w / 10.0); |
||
1604 | SeStyle->StrikeVal->LPos->setValue(p / 10.0); |
||
1605 | connect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
||
1606 | connect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newStrikeHandler())); |
||
1607 | } |
||
1608 | |||
2262 | fschmid | 1609 | void SToolBStyle::setUnderline(int p, int w) |
1610 | { |
||
1611 | disconnect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
||
1612 | disconnect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
||
1613 | SeStyle->UnderlineVal->LWidth->setValue(w / 10.0); |
||
1614 | SeStyle->UnderlineVal->LPos->setValue(p / 10.0); |
||
1615 | connect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
||
1616 | connect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(newUnderlineHandler())); |
||
1617 | } |
||
1618 | |||
2254 | fschmid | 1619 | void SToolBStyle::SetShadow(int x, int y) |
1620 | { |
||
1621 | disconnect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
||
1622 | disconnect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
||
1623 | SeStyle->ShadowVal->Xoffset->setValue(x / 10.0); |
||
1624 | SeStyle->ShadowVal->Yoffset->setValue(y / 10.0); |
||
1625 | connect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
||
1626 | connect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(int)), this, SLOT(newShadowHandler())); |
||
1627 | } |
||
1628 | |||
351 | Franz | 1629 | void SToolBStyle::SetStyle(int s) |
1630 | { |
||
716 | cbradney | 1631 | disconnect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
351 | Franz | 1632 | SeStyle->setStyle(s); |
716 | cbradney | 1633 | connect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
351 | Franz | 1634 | } |
1635 | |||
1636 | void SToolBStyle::SetKern(double k) |
||
1637 | { |
||
1638 | disconnect(Extra, SIGNAL(valueChanged(int)), this, SLOT(newKernHandler())); |
||
1639 | Extra->setValue(k); |
||
1640 | connect(Extra, SIGNAL(valueChanged(int)), this, SLOT(newKernHandler())); |
||
1641 | } |
||
1642 | |||
1643 | /* Toolbar for alignment of Paragraphs */ |
||
352 | Franz | 1644 | SToolBAlign::SToolBAlign(QMainWindow* parent) : QToolBar( tr("Style Settings"), parent) |
351 | Franz | 1645 | { |
1646 | GroupAlign = new AlignSelect(this); |
||
1647 | Spal = new Spalette(this); |
||
1648 | QToolTip::add( Spal, tr( "Style of current paragraph" ) ); |
||
716 | cbradney | 1649 | connect(Spal, SIGNAL(newStyle(int)), this, SLOT(newStyleHandler(int ))); |
351 | Franz | 1650 | connect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(NewAlign(int ))); |
1651 | } |
||
1652 | |||
1653 | void SToolBAlign::newStyleHandler(int s) |
||
1654 | { |
||
1655 | if (s != 0) |
||
1656 | GroupAlign->setEnabled(false); |
||
1657 | else |
||
1658 | GroupAlign->setEnabled(true); |
||
716 | cbradney | 1659 | emit newStyle(s); |
351 | Franz | 1660 | } |
1661 | |||
1662 | void SToolBAlign::SetAlign(int s) |
||
1663 | { |
||
716 | cbradney | 1664 | disconnect(Spal, SIGNAL(newStyle(int)), this, SLOT(newStyleHandler(int ))); |
351 | Franz | 1665 | disconnect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(NewAlign(int ))); |
1666 | if (s < 5) |
||
1667 | { |
||
1668 | GroupAlign->setEnabled(true); |
||
1669 | GroupAlign->setStyle(s); |
||
1670 | } |
||
1671 | else |
||
1672 | GroupAlign->setEnabled(false); |
||
1673 | Spal->setFormat(s); |
||
1674 | connect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(NewAlign(int ))); |
||
716 | cbradney | 1675 | connect(Spal, SIGNAL(newStyle(int)), this, SLOT(newStyleHandler(int ))); |
351 | Franz | 1676 | } |
1677 | |||
1678 | /* Toolbar for Font related Settings */ |
||
352 | Franz | 1679 | SToolBFont::SToolBFont(QMainWindow* parent) : QToolBar( tr("Font Settings"), parent) |
351 | Franz | 1680 | { |
1681 | Fonts = new FontCombo(this, &ScApp->Prefs); |
||
1682 | Fonts->setMaximumSize(190, 30); |
||
2247 | fschmid | 1683 | Size = new MSpinBox( 0.5, 2048, this, 1 ); |
351 | Franz | 1684 | Size->setPrefix( "" ); |
1685 | Size->setSuffix( tr( " pt" ) ); |
||
2230 | fschmid | 1686 | ScaleTxt = new QLabel("", this, "ScaleTxt" ); |
1687 | ScaleTxt->setPixmap(loadIcon("textscaleh.png")); |
||
2242 | fschmid | 1688 | ChScale = new MSpinBox( 10, 400, this, 1 ); |
351 | Franz | 1689 | ChScale->setValue( 100 ); |
1690 | ChScale->setSuffix( tr( " %" ) ); |
||
2230 | fschmid | 1691 | ScaleTxtV = new QLabel("", this, "ScaleTxtV" ); |
1692 | ScaleTxtV->setPixmap(loadIcon("textscalev.png")); |
||
2242 | fschmid | 1693 | ChScaleV = new MSpinBox( 10, 400, this, 1 ); |
2230 | fschmid | 1694 | ChScaleV->setValue( 100 ); |
1695 | ChScaleV->setSuffix( tr( " %" ) ); |
||
351 | Franz | 1696 | QToolTip::add( Fonts, tr( "Font of selected text" ) ); |
1697 | QToolTip::add( Size, tr( "Font Size" ) ); |
||
1698 | QToolTip::add( ChScale, tr( "Scaling width of characters" ) ); |
||
2230 | fschmid | 1699 | QToolTip::add( ChScaleV, tr( "Scaling height of characters" ) ); |
351 | Franz | 1700 | connect(ChScale, SIGNAL(valueChanged(int)), this, SIGNAL(NewScale(int))); |
2230 | fschmid | 1701 | connect(ChScaleV, SIGNAL(valueChanged(int)), this, SIGNAL(NewScaleV(int))); |
351 | Franz | 1702 | connect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
1703 | connect(Size, SIGNAL(valueChanged(int)), this, SLOT(newSizeHandler())); |
||
1704 | } |
||
1705 | |||
1706 | void SToolBFont::SetFont(QString f) |
||
1707 | { |
||
1708 | disconnect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
||
1709 | Fonts->setCurrentText(f); |
||
1710 | connect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
||
1711 | } |
||
1712 | |||
1713 | void SToolBFont::SetSize(double s) |
||
1714 | { |
||
1715 | disconnect(Size, SIGNAL(valueChanged(int)), this, SLOT(newSizeHandler())); |
||
2242 | fschmid | 1716 | Size->setValue(s / 10.0); |
351 | Franz | 1717 | connect(Size, SIGNAL(valueChanged(int)), this, SLOT(newSizeHandler())); |
1718 | } |
||
1719 | |||
1720 | void SToolBFont::SetScale(int s) |
||
1721 | { |
||
1722 | disconnect(ChScale, SIGNAL(valueChanged(int)), this, SIGNAL(NewScale(int))); |
||
2242 | fschmid | 1723 | ChScale->setValue(s / 10.0); |
351 | Franz | 1724 | connect(ChScale, SIGNAL(valueChanged(int)), this, SIGNAL(NewScale(int))); |
1725 | } |
||
1726 | |||
2230 | fschmid | 1727 | void SToolBFont::SetScaleV(int s) |
1728 | { |
||
1729 | disconnect(ChScaleV, SIGNAL(valueChanged(int)), this, SIGNAL(NewScaleV(int))); |
||
2242 | fschmid | 1730 | ChScaleV->setValue(s / 10.0); |
2230 | fschmid | 1731 | connect(ChScaleV, SIGNAL(valueChanged(int)), this, SIGNAL(NewScaleV(int))); |
1732 | } |
||
1733 | |||
351 | Franz | 1734 | void SToolBFont::newSizeHandler() |
1735 | { |
||
1736 | emit NewSize(Size->value()); |
||
1737 | } |
||
1738 | |||
1739 | /* Main Story Editor Class */ |
||
1549 | subik | 1740 | StoryEditor::StoryEditor(QWidget* parent, ScribusDoc *docc, PageItem *ite) |
351 | Franz | 1741 | : QMainWindow(parent, "StoryEditor", WShowModal | WType_Dialog) |
1742 | { |
||
1743 | setCaption( tr( "Story Editor" ) ); |
||
1744 | setIcon(loadIcon("AppIcon.png")); |
||
1745 | doc = docc; |
||
1746 | QHBox* vb = new QHBox( this ); |
||
1747 | StoryEd2Layout = new QHBoxLayout( 0, 5, 5, "StoryEd2Layout"); |
||
1748 | /* Setting up Menu Bar */ |
||
217 | Franz | 1749 | fmenu = new QPopupMenu(); |
412 | Franz | 1750 | fmenu->insertItem(loadIcon("editdelete.png"), tr("&New"), this, SLOT(Do_new()), CTRL+Key_N); |
1208 | cbradney | 1751 | M_FileRevert = fmenu->insertItem(loadIcon("reload16.png"), tr("&Reload Text from Frame"), this, SLOT(slotFileRevert())); |
162 | Franz | 1752 | fmenu->insertSeparator(); |
351 | Franz | 1753 | fmenu->insertItem(loadIcon("DateiSave16.png"), tr("&Save to File..."), this, SLOT(SaveTextFile())); |
1754 | fmenu->insertItem(loadIcon("DateiOpen16.png"), tr("&Load from File..."), this, SLOT(LoadTextFile())); |
||
1755 | fmenu->insertItem(tr("Save &Document"), this, SLOT(Do_saveDocument()), CTRL+Key_S); |
||
162 | Franz | 1756 | fmenu->insertSeparator(); |
295 | Franz | 1757 | /* changes to fit the #662 bug 05/28/04 petr vanek */ |
412 | Franz | 1758 | fmenu->insertItem(loadIcon("ok.png"), tr("&Update Text Frame and Exit"), this, SLOT(Do_leave2())); |
353 | Franz | 1759 | fmenu->insertItem(loadIcon("exit.png"), tr("&Exit Without Updating Text Frame"), this, SLOT(Do_leave())); |
295 | Franz | 1760 | /* end of changes */ |
217 | Franz | 1761 | emenu = new QPopupMenu(); |
352 | Franz | 1762 | emenu->insertItem( tr("Select &All"), this, SLOT(Do_selectAll()), CTRL+Key_A); |
351 | Franz | 1763 | Mcopy = emenu->insertItem(loadIcon("editcut.png"), tr("Cu&t"), this, SLOT(Do_cut()), CTRL+Key_X); |
1764 | Mcut = emenu->insertItem(loadIcon("editcopy.png"), tr("&Copy"), this, SLOT(Do_copy()), CTRL+Key_C); |
||
1765 | Mpaste = emenu->insertItem(loadIcon("editpaste.png"), tr("&Paste"), this, SLOT(Do_paste()), CTRL+Key_V); |
||
360 | Franz | 1766 | Mdel = emenu->insertItem(loadIcon("editdelete.png"), tr("C&lear"), this, SLOT(Do_del()), Key_Delete); |
103 | Franz | 1767 | emenu->insertSeparator(); |
357 | Franz | 1768 | emenu->insertItem(loadIcon("find16.png"), tr("&Search/Replace..."), this, SLOT(SearchText())); |
2005 | cbradney | 1769 | emenu->insertItem( tr("&Insert Glyph..."), this , SLOT(Do_insSp())); |
189 | Franz | 1770 | emenu->insertSeparator(); |
355 | Franz | 1771 | emenu->insertItem( tr("&Edit Styles..."), this , SLOT(slotEditStyles())); |
364 | Franz | 1772 | emenu->insertItem( tr("&Fonts Preview..."), this , SLOT(Do_fontPrev())); |
353 | Franz | 1773 | Mupdt = emenu->insertItem(loadIcon("compfile16.png"), tr("&Update Text Frame"), this, SLOT(updateTextFrame()), CTRL+Key_U); |
357 | Franz | 1774 | settingsMenu = new QPopupMenu(); |
1775 | settingsMenu->insertItem( tr("&Background..."), this , SLOT(setBackPref())); |
||
1776 | settingsMenu->insertItem( tr("&Display Font..."), this , SLOT(setFontPref())); |
||
461 | fschmid | 1777 | smartSel = settingsMenu->insertItem( tr("&Smart text selection"), this, SLOT(ToggleSmart())); |
1778 | smartSelection = false; |
||
1779 | settingsMenu->setItemChecked(smartSel, smartSelection); |
||
351 | Franz | 1780 | menuBar()->insertItem( tr("&File"), fmenu); |
1781 | menuBar()->insertItem( tr("&Edit"), emenu); |
||
357 | Franz | 1782 | menuBar()->insertItem( tr("&Settings"), settingsMenu ); |
124 | Franz | 1783 | |
351 | Franz | 1784 | /* Setting up Toolbars */ |
353 | Franz | 1785 | FileTools = new QToolBar( tr("File"), this); |
412 | Franz | 1786 | DatNeu = new QToolButton(loadIcon("editdelete.png"), tr("Clear all Text"), QString::null, this, SLOT(Do_new()), FileTools); |
353 | Franz | 1787 | DatOpe = new QToolButton(loadIcon("DateiOpen.xpm"), tr("Load Text from File"), QString::null, this, SLOT(LoadTextFile()), FileTools); |
1788 | DatSav = new QToolButton(loadIcon("DateiSave2.png"), tr("Save Text to File"), QString::null, this, SLOT(SaveTextFile()), FileTools); |
||
983 | cbradney | 1789 | DatClo = new QToolButton(loadIcon("ok22.png"), tr("Update Text Frame and Exit"), QString::null, this, SLOT(Do_leave2()), FileTools); |
353 | Franz | 1790 | DatCan = new QToolButton(loadIcon("exit22.png"), tr("Exit Without Updating Text Frame"), QString::null, this, SLOT(Do_leave()), FileTools); |
1791 | DatRel = new QToolButton(loadIcon("reload.png"), tr("Reload Text from Frame"), QString::null, this, SLOT(slotFileRevert()), FileTools); |
||
1792 | DatUpdt = new QToolButton(loadIcon("compfile.png"), tr("Update Text Frame"), QString::null, this, SLOT(updateTextFrame()), FileTools); |
||
357 | Franz | 1793 | DatFin = new QToolButton(loadIcon("find.png"), tr("Search/Replace"), QString::null, this, SLOT(SearchText()), FileTools); |
353 | Franz | 1794 | DatUpdt->setEnabled(false); |
1795 | DatRel->setEnabled(false); |
||
1796 | setDockEnabled(FileTools, DockLeft, false); |
||
1797 | setDockEnabled(FileTools, DockRight, false); |
||
1798 | setDockEnabled(FileTools, DockBottom, false); |
||
351 | Franz | 1799 | FontTools = new SToolBFont(this); |
1800 | setDockEnabled(FontTools, DockLeft, false); |
||
1801 | setDockEnabled(FontTools, DockRight, false); |
||
1802 | setDockEnabled(FontTools, DockBottom, false); |
||
1803 | AlignTools = new SToolBAlign(this); |
||
1804 | setDockEnabled(AlignTools, DockLeft, false); |
||
1805 | setDockEnabled(AlignTools, DockRight, false); |
||
1806 | setDockEnabled(AlignTools, DockBottom, false); |
||
716 | cbradney | 1807 | AlignTools->Spal->setFormats(doc); |
351 | Franz | 1808 | StyleTools = new SToolBStyle(this); |
1809 | setDockEnabled(StyleTools, DockLeft, false); |
||
1810 | setDockEnabled(StyleTools, DockRight, false); |
||
1811 | setDockEnabled(StyleTools, DockBottom, false); |
||
1812 | StrokeTools = new SToolBColorS(this, doc); |
||
1813 | setDockEnabled(StrokeTools, DockLeft, false); |
||
1814 | setDockEnabled(StrokeTools, DockRight, false); |
||
1815 | setDockEnabled(StrokeTools, DockBottom, false); |
||
352 | Franz | 1816 | StrokeTools->TxStroke->setEnabled(false); |
1817 | StrokeTools->PM1->setEnabled(false); |
||
351 | Franz | 1818 | FillTools = new SToolBColorF(this, doc); |
1819 | setDockEnabled(FillTools, DockLeft, false); |
||
1820 | setDockEnabled(FillTools, DockRight, false); |
||
1821 | setDockEnabled(FillTools, DockBottom, false); |
||
125 | Franz | 1822 | |
371 | Franz | 1823 | EdSplit = new QSplitter(vb); |
1824 | /* SideBar Widget */ |
||
1825 | EditorBar = new SideBar(EdSplit); |
||
351 | Franz | 1826 | /* Editor Widget, subclass of QTextEdit */ |
371 | Franz | 1827 | Editor = new SEditor(EdSplit, docc); |
1828 | StoryEd2Layout->addWidget( EdSplit ); |
||
1549 | subik | 1829 | |
351 | Franz | 1830 | /* Setting up Status Bar */ |
1831 | ButtonGroup1 = new QButtonGroup( statusBar(), "ButtonGroup1" ); |
||
125 | Franz | 1832 | ButtonGroup1->setFrameShape( QButtonGroup::NoFrame ); |
1833 | ButtonGroup1->setFrameShadow( QButtonGroup::Plain ); |
||
1834 | ButtonGroup1->setTitle(""); |
||
1835 | ButtonGroup1->setExclusive( true ); |
||
1836 | ButtonGroup1->setColumnLayout(0, Qt::Vertical ); |
||
1837 | ButtonGroup1->layout()->setSpacing( 0 ); |
||
1838 | ButtonGroup1->layout()->setMargin( 0 ); |
||
1839 | ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() ); |
||
1840 | ButtonGroup1Layout->setAlignment( Qt::AlignTop ); |
||
1841 | ButtonGroup1Layout->setSpacing( 2 ); |
||
1842 | ButtonGroup1Layout->setMargin( 0 ); |
||
1843 | WordCT1 = new QLabel(ButtonGroup1, "wt"); |
||
1844 | WordCT1->setText( tr("Current Paragraph:")); |
||
1845 | ButtonGroup1Layout->addMultiCellWidget( WordCT1, 0, 0, 0, 3 ); |
||
1846 | WordCT = new QLabel(ButtonGroup1, "wt"); |
||
124 | Franz | 1847 | WordCT->setText( tr("Words: ")); |
125 | Franz | 1848 | ButtonGroup1Layout->addWidget( WordCT, 1, 0 ); |
1849 | WordC = new QLabel(ButtonGroup1, "wc"); |
||
1850 | ButtonGroup1Layout->addWidget( WordC, 1, 1 ); |
||
1851 | CharCT = new QLabel(ButtonGroup1, "ct"); |
||
124 | Franz | 1852 | CharCT->setText( tr("Chars: ")); |
125 | Franz | 1853 | ButtonGroup1Layout->addWidget( CharCT, 1, 2 ); |
1854 | CharC = new QLabel(ButtonGroup1, "cc"); |
||
1855 | ButtonGroup1Layout->addWidget( CharC, 1, 3 ); |
||
351 | Franz | 1856 | statusBar()->addWidget(ButtonGroup1, 1, true); |
1857 | ButtonGroup2 = new QButtonGroup( statusBar(), "ButtonGroup2" ); |
||
125 | Franz | 1858 | ButtonGroup2->setFrameShape( QButtonGroup::NoFrame ); |
1859 | ButtonGroup2->setFrameShadow( QButtonGroup::Plain ); |
||
1860 | ButtonGroup2->setTitle(""); |
||
1861 | ButtonGroup2->setExclusive( true ); |
||
1862 | ButtonGroup2->setColumnLayout(0, Qt::Vertical ); |
||
1863 | ButtonGroup2->layout()->setSpacing( 0 ); |
||
1864 | ButtonGroup2->layout()->setMargin( 0 ); |
||
1865 | ButtonGroup2Layout = new QGridLayout( ButtonGroup2->layout() ); |
||
1866 | ButtonGroup2Layout->setAlignment( Qt::AlignTop ); |
||
1867 | ButtonGroup2Layout->setSpacing( 2 ); |
||
1868 | ButtonGroup2Layout->setMargin( 0 ); |
||
1869 | WordCT3 = new QLabel(ButtonGroup2, "wt"); |
||
1870 | WordCT3->setText( tr("Totals:")); |
||
1871 | ButtonGroup2Layout->addMultiCellWidget( WordCT3, 0, 0, 0, 5 ); |
||
1872 | ParCT = new QLabel(ButtonGroup2, "pt"); |
||
1873 | ParCT->setText( tr("Paragraphs: ")); |
||
1874 | ButtonGroup2Layout->addWidget( ParCT, 1, 0 ); |
||
1875 | ParC = new QLabel(ButtonGroup2, "pc"); |
||
1876 | ButtonGroup2Layout->addWidget( ParC, 1, 1 ); |
||
1877 | WordCT2 = new QLabel(ButtonGroup2, "wt"); |
||
124 | Franz | 1878 | WordCT2->setText( tr("Words: ")); |
125 | Franz | 1879 | ButtonGroup2Layout->addWidget( WordCT2, 1, 2 ); |
1880 | WordC2 = new QLabel(ButtonGroup2, "wc"); |
||
1881 | ButtonGroup2Layout->addWidget( WordC2, 1, 3 ); |
||
1882 | CharCT2 = new QLabel(ButtonGroup2, "ct"); |
||
124 | Franz | 1883 | CharCT2->setText( tr("Chars: ")); |
125 | Franz | 1884 | ButtonGroup2Layout->addWidget( CharCT2, 1, 4 ); |
1885 | CharC2 = new QLabel(ButtonGroup2, "cc"); |
||
1886 | ButtonGroup2Layout->addWidget( CharC2, 1, 5 ); |
||
351 | Franz | 1887 | statusBar()->addWidget(ButtonGroup2, 1, true); |
1888 | setCentralWidget( vb ); |
||
1889 | /* Final polishment */ |
||
1208 | cbradney | 1890 | fmenu->setItemEnabled(M_FileRevert, 0); |
351 | Franz | 1891 | emenu->setItemEnabled(Mcopy, 0); |
1892 | emenu->setItemEnabled(Mcut, 0); |
||
1893 | emenu->setItemEnabled(Mpaste, 0); |
||
1894 | emenu->setItemEnabled(Mdel, 0); |
||
1895 | emenu->setItemEnabled(Mupdt, 0); |
||
1896 | resize( QSize(660, 500).expandedTo(minimumSizeHint()) ); |
||
357 | Franz | 1897 | Editor->setPaper(ScApp->Prefs.STEcolor); |
1898 | QFont fo; |
||
1899 | fo.fromString(ScApp->Prefs.STEfont); |
||
1900 | Editor->setFont(fo); |
||
351 | Franz | 1901 | CurrItem = ite; |
353 | Franz | 1902 | firstSet = false; |
351 | Franz | 1903 | Editor->loadItemText(ite); |
1904 | updateProps(0,0); |
||
1905 | updateStatus(); |
||
1906 | TextChanged = false; |
||
371 | Franz | 1907 | EditorBar->setFrameStyle(Editor->frameStyle()); |
1908 | EditorBar->setLineWidth(Editor->lineWidth()); |
||
1909 | EditorBar->editor = Editor; |
||
351 | Franz | 1910 | connect(Editor, SIGNAL(textChanged()), this, SLOT(modifiedText())); |
364 | Franz | 1911 | connect(Editor, SIGNAL(clicked(int, int)), this, SLOT(updateProps(int, int))); |
351 | Franz | 1912 | connect(Editor, SIGNAL(setProps(int, int)), this, SLOT(updateProps(int, int))); |
1913 | connect(Editor, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(updateProps(int, int))); |
||
360 | Franz | 1914 | connect(Editor, SIGNAL(copyAvailable(bool)), this, SLOT(CopyAvail(bool ))); |
376 | Franz | 1915 | connect(Editor, SIGNAL(PasteAvail()), this, SLOT(PasteAvail())); |
373 | Franz | 1916 | connect(Editor, SIGNAL(contentsMoving(int, int)), EditorBar, SLOT(doMove(int, int ))); |
371 | Franz | 1917 | connect(Editor, SIGNAL(textChanged()), EditorBar, SLOT(doRepaint())); |
372 | Franz | 1918 | connect(Editor, SIGNAL(SideBarUp(bool )), EditorBar, SLOT(setRepaint(bool ))); |
1919 | connect(Editor, SIGNAL(SideBarUpdate( )), EditorBar, SLOT(doRepaint())); |
||
445 | fschmid | 1920 | // 10/12/2004 - pv - #1203: wrong selection on double click |
1921 | connect(Editor, SIGNAL(doubleClicked(int, int)), this, SLOT(doubleClick(int, int))); |
||
374 | Franz | 1922 | connect(EditorBar, SIGNAL(ChangeStyle(int, int )), this, SLOT(changeAlignSB(int, int ))); |
1893 | subik | 1923 | connect(EditorBar, SIGNAL(sigEditStyles()), this, SLOT(slotEditStyles())); |
716 | cbradney | 1924 | connect(AlignTools, SIGNAL(newStyle(int)), this, SLOT(newAlign(int))); |
351 | Franz | 1925 | connect(AlignTools, SIGNAL(NewAlign(int)), this, SLOT(newAlign(int))); |
1926 | connect(FillTools, SIGNAL(NewColor(int, int)), this, SLOT(newTxFill(int, int))); |
||
1927 | connect(StrokeTools, SIGNAL(NewColor(int, int)), this, SLOT(newTxStroke(int, int))); |
||
1928 | connect(FontTools, SIGNAL(NewSize(double )), this, SLOT(newTxSize(double))); |
||
1929 | connect(FontTools, SIGNAL(NewFont(const QString& )), this, SLOT(newTxFont(const QString& ))); |
||
1930 | connect(FontTools, SIGNAL(NewScale(int )), this, SLOT(newTxScale(int ))); |
||
2230 | fschmid | 1931 | connect(FontTools, SIGNAL(NewScaleV(int )), this, SLOT(newTxScaleV(int ))); |
351 | Franz | 1932 | connect(StyleTools, SIGNAL(NewKern(double )), this, SLOT(newTxKern(double ))); |
716 | cbradney | 1933 | connect(StyleTools, SIGNAL(newStyle(int )), this, SLOT(newTxStyle(int ))); |
2254 | fschmid | 1934 | connect(StyleTools, SIGNAL(NewShadow(int, int)), this, SLOT(newShadowOffs(int, int))); |
2257 | fschmid | 1935 | connect(StyleTools, SIGNAL(newOutline(int )), this, SLOT(newTxtOutline(int ))); |
2272 | fschmid | 1936 | connect(StyleTools, SIGNAL(newUnderline(int, int)), this, SLOT(newTxtUnderline(int, int))); |
1937 | connect(StyleTools, SIGNAL(newStrike(int, int )), this, SLOT(newTxtStrike(int, int))); |
||
392 | Franz | 1938 | Editor->setFocus(); |
351 | Franz | 1939 | } |
1549 | subik | 1940 | |
445 | fschmid | 1941 | /** 10/12/2004 - pv - #1203: wrong selection on double click |
1942 | Catch the double click signal - cut the wrong selection (with |
||
1943 | whitespaces on the tail) - select only one word - return |
||
1944 | controlling back to story editor - have rest */ |
||
1945 | void StoryEditor::doubleClick(int para, int position) |
||
1946 | { |
||
1947 | int paraFrom, indexFrom, paraTo, indexTo; |
||
1948 | QString selText = Editor->selectedText(); |
||
461 | fschmid | 1949 | if (selText.length() == 0 || !smartSelection) |
445 | fschmid | 1950 | { |
1951 | updateProps(para, position); |
||
1952 | return; |
||
1953 | } |
||
1954 | Editor->getSelection(¶From, &indexFrom, ¶To, &indexTo); |
||
1955 | selText = selText.stripWhiteSpace(); |
||
1956 | Editor->setSelection(paraFrom, indexFrom, paraFrom, indexFrom + selText.length()); |
||
1957 | updateProps(para, position); |
||
1958 | } |
||
1959 | |||
461 | fschmid | 1960 | void StoryEditor::ToggleSmart() |
1961 | { |
||
1962 | smartSelection = !smartSelection; |
||
1963 | settingsMenu->setItemChecked(smartSel, smartSelection); |
||
1964 | } |
||
1965 | |||
351 | Franz | 1966 | int StoryEditor::exec() |
1967 | { |
||
1968 | clearWFlags( WDestructiveClose ); |
||
1969 | setWFlags( WShowModal ); |
||
1970 | result = 0; |
||
1971 | show(); |
||
392 | Franz | 1972 | Editor->setFocus(); |
351 | Franz | 1973 | qApp->enter_loop(); |
1974 | clearWFlags( WShowModal ); |
||
1975 | return result; |
||
1976 | } |
||
124 | Franz | 1977 | |
795 | fschmid | 1978 | void StoryEditor::closeEvent(QCloseEvent *) |
351 | Franz | 1979 | { |
1980 | if (TextChanged) |
||
167 | Franz | 1981 | { |
351 | Franz | 1982 | int t = QMessageBox::warning(this, tr("Warning"), |
1983 | tr("Do you want to save your changes?"), |
||
1946 | craig | 1984 | QMessageBox::Yes|QMessageBox::Default, |
1985 | QMessageBox::No, |
||
1986 | QMessageBox::Cancel|QMessageBox::Escape); |
||