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