Scribus
Open source desktop publishing at your fingertips
storyeditor.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  storyeditor.h - description
9  -------------------
10  begin : Tue Nov 11 2003
11  copyright : (C) 2003 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  * *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or *
20  * (at your option) any later version. *
21  * *
22  ***************************************************************************/
23 
24 #ifndef STORYEDITOR_H
25 #define STORYEDITOR_H
26 
27 #include <QTextEdit>
28 #include <QAction>
29 #include <QCheckBox>
30 #include <QCloseEvent>
31 #include <QEvent>
32 #include <QFocusEvent>
33 #include <QHideEvent>
34 #include <QKeyEvent>
35 #include <QLabel>
36 #include <QLayout>
37 #include <QList>
38 #include <QMainWindow>
39 #include <QMap>
40 #include <QMenu>
41 #include <QMenuBar>
42 #include <QMouseEvent>
43 #include <QPaintEvent>
44 #include <QPixmap>
45 #include <QPointer>
46 #include <QShowEvent>
47 #include <QSpinBox>
48 #include <QSplitter>
49 #include <QStatusBar>
50 #include <QStringList>
51 #include <QToolBar>
52 #include <QToolButton>
53 #include <QVariant>
54 #include <QWidgetAction>
55 
56 class QEvent;
57 class QGridLayout;
58 class QHBoxLayout;
59 class QFrame;
60 
61 #include "scribusapi.h"
62 #include "text/storytext.h"
63 
64 class PageItem;
65 class MenuManager;
66 class ScrSpinBox;
67 class ParaStyleComboBox;
68 class StyleSelect;
69 class AlignSelect;
70 class FontCombo;
71 class ScrAction;
72 class ShadeButton;
73 class PrefsManager;
74 class PrefsContext;
75 class StoryEditor;
76 class ColorCombo;
77 class CharSelect;
78 
79 class SCRIBUS_API SEditor : public QTextEdit
80 {
81  Q_OBJECT
82 
83 public:
84  SEditor (QWidget* parent, ScribusDoc *docc, StoryEditor* parentSE);
85  ~SEditor() {};
86  void setCurrentDocument(ScribusDoc *docc);
87  void setAlign(int align);
88  void saveItemText(PageItem *currItem);
89  void loadItemText(PageItem *currItem);
90  void loadText(QString tx, PageItem *currItem);
91  void updateAll();
92  void updateFromChars(int p);
93  void updateSel(const CharStyle& style);
94  void updateSel(const ParagraphStyle& style);
95  void deleteSel();
96  void setEffects(int effects);
97  void setColor(bool marker);
98 
99  void insertChars(const QString& text);
100  void insertChars(const QString& styledText, const QString& editText);
101 
102  StoryText StyledText;
103  QList<PageItem*> FrameItems;
104  ScribusDoc* doc;
105  bool unicodeTextEditMode;
106  bool wasMod;
107  bool ready;
108  int unicodeInputCount;
109  StyleFlag CurrentEffects;
110  QString currentParaStyle;
111  int CurrAlign;
112  double CurrFontSize;
113  double CurrTextFillSh;
114  double CurrTextStrokeSh;
115  double CurrTextScale;
116  double CurrTextScaleV;
117  double CurrTextBase;
118  double CurrTextShadowX;
119  double CurrTextShadowY;
120  double CurrTextOutline;
121  double CurrTextUnderPos;
122  double CurrTextUnderWidth;
123  double CurrTextStrikePos;
124  double CurrTextStrikeWidth;
125  double CurrTextKern;
126  QString CurrTextStroke;
127  QString CurrTextFill;
128  QString prevFont;
129  QString CurrFont;
130  QString unicodeInputString;
131  bool StoredSel;
132  int SelParaStart;
133  int SelParaEnd;
134  int SelCharStart;
135  int SelCharEnd;
136  int SuspendContentsChange; // input method
137 
138 protected:
139 
140  void insertCharsInternal(const QString& t);
141  void insertCharsInternal(const QString& t, int position);
142 
143  void insertStyledText(const StoryText& styledText);
144  void insertStyledText(const StoryText& styledText, int position);
145 
146  void insertUpdate(int position, int len);
147 
148  void setAlign(QTextCursor& tCursor, int style);
149  void setEffects(QTextCursor& tCursor, int effects);
150 
151  int blockContentsChangeHook;
152  void keyPressEvent(QKeyEvent *k);
153  void inputMethodEvent(QInputMethodEvent *event);
154  void focusOutEvent(QFocusEvent *e);
155  void focusInEvent(QFocusEvent *e);
156  void scrollContentsBy(int dx, int dy);
157  virtual bool canInsertFromMimeData( const QMimeData * source ) const;
158  virtual QMimeData * createMimeDataFromSelection () const;
159  virtual void insertFromMimeData ( const QMimeData * source );
160  StoryEditor* parentStoryEditor;
161 
162 protected slots:
163  void handleContentsChange(int position, int charsRemoved, int charsAdded);
164 
165 public slots:
166  void cut();
167  void copy();
168  void paste();
169  void ClipChange();
170  void SelClipChange();
171 
172 signals:
173  void setProps(int, int);
174  void SideBarUp(bool);
175  void SideBarUpdate();
176  void PasteAvail();
177  void contentsMoving(int, int);
178 };
179 
180 class SCRIBUS_API SideBar : public QLabel
181 {
182  Q_OBJECT
183 
184 public:
185  SideBar(QWidget *pa);
186  ~SideBar() {};
187  int offs;
188  int CurrentPar;
189  SEditor *editor;
190  QMenu *pmen;
191  QWidgetAction* paraStyleAct;
192  bool noUpdt;
193  bool inRep;
194 
195 protected:
196  void paintEvent(QPaintEvent *e);
197  void mouseReleaseEvent(QMouseEvent *m);
198 
199 signals:
200  void ChangeStyle(int, const QString&);
202  //void sigEditStyles();
203 
204 public slots:
205  void setPStyle(const QString&);
206  void doMove(int x, int y);
207  void doRepaint();
208  void setRepaint(bool r);
210  //void editStyles();
211 };
212 
213 class SCRIBUS_API SToolBColorF : public QToolBar
214 {
215  Q_OBJECT
216 
217 public:
218  SToolBColorF(QMainWindow* parent, ScribusDoc *doc);
219  ~SToolBColorF() {};
220 
221  virtual void changeEvent(QEvent *e);
222 
223  void setCurrentDocument(ScribusDoc *doc);
224  QLabel* FillIcon;
225  ColorCombo* TxFill;
226  ShadeButton *PM2;
227  QAction* pm2Action;
228  QAction* txFillAction;
229  QAction* fillIconAction;
230 
231 public slots:
232  void SetColor(int c);
233  void SetShade(double s);
234  void newShadeHandler();
235  void languageChange();
236 
237 signals:
238  void NewColor(int, int);
239 };
240 
241 class SCRIBUS_API SToolBColorS : public QToolBar
242 {
243  Q_OBJECT
244 
245 public:
246  SToolBColorS(QMainWindow* parent, ScribusDoc *doc);
247  ~SToolBColorS() {};
248 
249  virtual void changeEvent(QEvent *e);
250 
251  void setCurrentDocument(ScribusDoc *doc);
252  QLabel* StrokeIcon;
253  ColorCombo* TxStroke;
254  ShadeButton *PM1;
255  QAction* strokeIconAction;
256  QAction* txStrokeAction;
257  QAction* pm1Action;
258 
259 
260 public slots:
261  void SetColor(int c);
262  void SetShade(double s);
263  void newShadeHandler();
264  void languageChange();
265 
266 signals:
267  void NewColor(int, int);
268 };
269 
270 class SCRIBUS_API SToolBStyle : public QToolBar
271 {
272  Q_OBJECT
273 
274 public:
275  SToolBStyle(QMainWindow* parent);
276  ~SToolBStyle() {};
277 
278  virtual void changeEvent(QEvent *e);
279 
280  StyleSelect* SeStyle;
281  QLabel* trackingLabel;
282  ScrSpinBox* Extra;
283  QAction* seStyleAction;
284  QAction* trackingLabelAction;
285  QAction* extraAction;
286 
287 public slots:
288  void newStrikeHandler();
289  void newUnderlineHandler();
290  void newOutlineHandler();
291  void newShadowHandler();
292  void newKernHandler();
293  void SetShadow(double x, double y);
294  void setStrike(double p, double w);
295  void setUnderline(double p, double w);
296  void setOutline(double o);
297  void SetStyle(int s);
298  void SetKern(double k);
299  void languageChange();
300 
301 signals:
302  void NewKern(double);
303  void NewShadow(double, double);
304  void newOutline(double);
305  void newStrike(double, double);
306  void newUnderline(double, double);
307  void newStyle(int);
308 };
309 
310 class SCRIBUS_API SToolBAlign : public QToolBar
311 {
312  Q_OBJECT
313 
314 public:
315  SToolBAlign(QMainWindow* parent);
316  ~SToolBAlign() {};
317 
318  virtual void changeEvent(QEvent *e);
319 
320  AlignSelect* GroupAlign;
321  ParaStyleComboBox *paraStyleCombo;
322  QAction* groupAlignAction;
323  QAction* paraStyleComboAction;
324 
325 public slots:
326  void SetAlign(int s);
327  void SetParaStyle(QString s);
328  void languageChange();
329 
330 signals:
331  void newAlign(int);
332  void newParaStyle(const QString&);
333 };
334 
335 class SCRIBUS_API SToolBFont : public QToolBar
336 {
337  Q_OBJECT
338 
339 public:
340  SToolBFont(QMainWindow* parent);
341  ~SToolBFont() {};
342 
343  virtual void changeEvent(QEvent *e);
344 
345  FontCombo* Fonts;
346  ScrSpinBox* ChScale;
347  ScrSpinBox* ChScaleV;
348  QAction* fontsAction;
349  QAction* chScaleAction;
350  QAction* chScaleVAction;
351 
352 public slots:
353  void SetFont(QString f);
354  void SetSize(double s);
355  void SetScale(double s);
356  void SetScaleV(double s);
357  void newSizeHandler();
358 
359 signals:
360  void NewFont(const QString &);
361  void NewSize(double);
362  void newScale(double);
363  void newScaleV(double);
364 
365 private:
366  ScrSpinBox* Size;
367  QLabel* ScaleTxt;
368  QLabel* ScaleTxtV;
369  QAction* sizeAction;
370  QAction* scaleTxtAction;
371  QAction* scaleTxtVAction;
372 
373 private slots:
374  void languageChange();
375 };
376 
377 class SCRIBUS_API StoryEditor : public QMainWindow
378 {
379  Q_OBJECT
380  friend class SEditor;
381 
382 public:
383  StoryEditor( QWidget* parent );
384 // StoryEditor( QWidget* parent, ScribusDoc *docc, PageItem* ite );
385  ~StoryEditor();
386 
387  virtual void changeEvent(QEvent *e);
388 
389  void setCurrentDocumentAndItem(ScribusDoc *doc=NULL, PageItem *item=NULL);
390  void setSpellActive(bool ssa);
391 
392  ScribusDoc* currentDocument() const;
393  PageItem* currentItem() const;
394  SEditor* Editor;
395  bool activFromApp;
396  MenuManager* seMenuMgr;
397  QMap<QString, QPointer<ScrAction> > seActions;
398 
399 public slots:
400  void newStyle(const QString&);
401  void newAlign(int st);
402  void newTxFill(int c, int s);
403  void newTxStroke(int c, int s);
404  void newTxFont(const QString &f);
405  void newTxSize(double s);
406  void newTxStyle(int s);
407 
408 signals:
409  void DocChanged();
410  void EditSt();
411 
412 private:
413  //int exec();
414  void changeAlign(int align);
415  bool textDataChanged() const;
416 
418  bool m_smartSelection;
419 
420  ScribusDoc* m_doc;
421  PageItem* m_item;
422 
423  bool m_textChanged;
424  bool m_firstSet;
425  bool m_blockUpdate;
426 
427  int m_result;
428  int m_currPara;
429  int m_currChar;
430 
431 protected slots:
432  void setBackPref();
433  void setFontPref();
434  void newTxScale();
435  void newTxScaleV();
436  void newTxKern(double s);
437  void newShadowOffs(double x, double y);
438  void newTxtOutline(double o);
439  void newTxtUnderline(double p, double w);
440  void newTxtStrike(double p, double w);
441  void updateProps();
442  void updateProps(QTextCursor &cur);
443  void updateProps(int p, int ch);
444 
445  void changeStyleSB(int pa, const QString&);
446  void changeStyle();
447  void updateStatus();
448  void Do_leave();
449  void Do_leave2();
451  void Do_saveDocument();
452  bool Do_new();
453  void slotFileRevert();
454 
455  void Do_selectAll();
456  void Do_copy();
457  void Do_paste();
458  void Do_cut();
459  void Do_del();
460  void Do_insSp();
464  void insertSampleText();
465  void Do_fontPrev();
466  void CopyAvail(bool u);
467  void PasteAvail();
468  void updateTextFrame();
469  void SearchText();
470  //void slotEditStyles();
471  void modifiedText();
472  void LoadTextFile();
473  void SaveTextFile();
474  void setSmart(bool);
475  void languageChange();
476 
477  void specialActionKeyEvent(int unicodevalue);
479  void slot_insertSpecialChar();
480  void slot_insertUserSpecialChar(QChar, QString);
481  // 10/12/2004 - pv - #1203: wrong selection on double click
482  void doubleClick(int para, int pos);
483 
484 protected:
485  void initActions();
486  void updateUnicodeActions();
487  void buildMenus();
488  void buildGUI();
489  void connectSignals();
490  void disconnectSignals();
493  void loadPrefs();
495  void savePrefs();
496 
508 
509  void showEvent(QShowEvent *);
510  void hideEvent(QHideEvent *);
511 
512  void closeEvent(QCloseEvent *);
513  void keyPressEvent (QKeyEvent * e);
514  bool eventFilter( QObject* ob, QEvent* ev );
515 
516  QHBoxLayout* StoryEd2Layout;
517  QGridLayout* ButtonGroup1Layout;
518  QGridLayout* ButtonGroup2Layout;
519 
520  PrefsManager* prefsManager;
521  PrefsContext* prefs;
522 
523  QStringList unicodeCharActionNames;
524  QPixmap noIcon;
525 
526  QToolBar* FileTools;
527  SToolBFont* FontTools;
528  SToolBAlign* AlignTools;
529  SToolBColorF* FillTools;
530  SToolBColorS* StrokeTools;
531  SToolBStyle* StyleTools;
532  QSplitter* EdSplit;
533  SideBar* EditorBar;
534  QFrame* ButtonGroup1;
535  QFrame* ButtonGroup2;
536  QLabel* WordCT1;
537  QLabel* WordCT3;
538  QLabel* ParCT;
539  QLabel* ParC;
540  QLabel* WordCT;
541  QLabel* WordC;
542  QLabel* CharCT;
543  QLabel* CharC;
544  QLabel* WordCT2;
545  QLabel* WordC2;
546  QLabel* CharCT2;
547  QLabel* CharC2;
548 
549  bool m_spellActive;
550 };
551 
552 #endif
553 
554 
Definition: charstyle.h:47
Definition: storytext.h:71
Definition: charstyle.h:78
Definition: storyeditor.h:310
Definition: storyeditor.h:270
Definition: menumanager.h:43
The ColorCombo widget is a combo box for displaying list of colors.
Definition: colorcombo.h:33
Definition: storyeditor.h:377
Definition: shadebutton.h:14
Definition: storyeditor.h:213
Definition: paragraphstyle.h:27
Definition: storyeditor.h:180
the Document Class
Definition: scribusdoc.h:90
Definition: alignselect.h:18
Definition: spalette.h:36
Character Palette for direct glyphs inserting. The "classical" one is opened as CharSelectEnhanced in...
Definition: charselect.h:33
ScrSpinBox is a Qt4 replacement for our old ScrSpinBox using Qt3.
Definition: scrspinbox.h:21
Definition: storyeditor.h:79
Definition: scraction.h:33
Definition: prefscontext.h:40
Definition: styleselect.h:103
Definition: pageitem.h:92
Definition: storyeditor.h:241
Definition: editor.h:26
Definition: storyeditor.h:335
bool charSelectUsed
True when there were some glyphs inserted via charSelect.
Definition: storyeditor.h:507
Definition: fontcombo.h:43
Manage Scribus preferences here, and here alone Start to move the preferences out of scribus...
Definition: prefsmanager.h:43
CharSelect * charSelect
Special Characters dialog. It uses a little bit ugly method to operate with. It's a duplication of th...
Definition: storyeditor.h:505