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