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