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