Back to index

scribus-ng  1.3.4.dfsg+svn20071115
story.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           story.h    -  description
00009                              -------------------
00010     begin                : Tue Nov 11 2003
00011     copyright            : (C) 2003 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef STORY_H
00025 #define STORY_H
00026 
00027 #include <qguardedptr.h>
00028 #include <qvariant.h>
00029 #include <qmainwindow.h>
00030 #include <qptrlist.h>
00031 #include <qtable.h>
00032 #include <qtextedit.h>
00033 #include <qpopupmenu.h>
00034 #include <qmap.h>
00035 #include <qmenubar.h>
00036 #include <qstatusbar.h>
00037 #include <qlabel.h>
00038 #include <qbuttongroup.h>
00039 #include <qspinbox.h>
00040 #include <qstringlist.h>
00041 #include <qtoolbutton.h>
00042 #include <qtoolbar.h>
00043 #include <qlayout.h>
00044 #include <qsplitter.h>
00045 #include <qcheckbox.h>
00046 
00047 #include "scribusapi.h"
00048 #include "pageitem.h"
00049 #include "text/storytext.h"
00050 
00051 class MenuManager;
00052 class MSpinBox;
00053 class ParaStyleComboBox;
00054 class StyleSelect;
00055 class AlignSelect;
00056 class FontCombo;
00057 class ScrAction;
00058 class ShadeButton;
00059 class PrefsManager;
00060 class PrefsContext;
00061 class StoryEditor;
00062 class ColorCombo;
00063 class CharSelect;
00064 
00065 
00066 class SCRIBUS_API SEditor : public QTextEdit
00067 {
00068        Q_OBJECT
00069 
00070 public:
00071        SEditor (QWidget* parent, ScribusDoc *docc, StoryEditor* parentSE);
00072        ~SEditor() {};
00073        void setCurrentDocument(ScribusDoc *docc);
00074        void setAlign(int style);
00075        void saveItemText(PageItem *currItem);
00076        void loadItemText(PageItem *currItem);
00077        void loadText(QString tx, PageItem *currItem);
00078        void updateAll();
00079        void updateFromChars(int p);
00080        void updateSel(const CharStyle& style);
00081        void updateSel(const ParagraphStyle& style);
00082        void deleteSel();
00083        void setStyle(int Csty);
00084        void setFarbe(bool marker);
00085        void insChars(QString t);
00086        void insStyledText();
00087        void copyStyledText();
00088 
00089        StoryText StyledText;
00090        QPtrList<PageItem> FrameItems;
00091        ScribusDoc* doc;
00092        bool unicodeTextEditMode;
00093        bool wasMod;
00094        bool ready;
00095        int unicodeInputCount;
00096        StyleFlag CurrentStyle;
00097        QString currentParaStyle;
00098        int CurrAlign;
00099        int CurrFontSize;
00100        int CurrTextFillSh;
00101        int CurrTextStrokeSh;
00102        int CurrTextScale;
00103        int CurrTextScaleV;
00104        int CurrTextBase;
00105        int CurrTextShadowX;
00106        int CurrTextShadowY;
00107        int CurrTextOutline;
00108        int CurrTextUnderPos;
00109        int CurrTextUnderWidth;
00110        int CurrTextStrikePos;
00111        int CurrTextStrikeWidth;
00112        int CurrTextKern;
00113        QString CurrTextStroke;
00114        QString CurrTextFill;
00115        QString prevFont;
00116        QString CurrFont;
00117        QString unicodeInputString;
00118        QString tBuffer;
00119        StoryText cBuffer;
00120        int ClipData;
00121        bool StoredSel;
00122        int SelParaStart;
00123        int SelParaEnd;
00124        int SelCharStart;
00125        int SelCharEnd;
00126 
00127 protected:
00128        void keyPressEvent(QKeyEvent *k);
00129        void imEndEvent(QIMEvent *e);
00130        void focusOutEvent(QFocusEvent *e);
00131        void focusInEvent(QFocusEvent *e);
00132        QPopupMenu* createPopupMenu(const QPoint & pos);
00133        StoryEditor* parentStoryEditor;
00134 
00135 public slots:
00136        void cut();
00137        void copy();
00138        void paste();
00139        void ClipChange();
00140        void SelClipChange();
00141 
00142 signals:
00143        void setProps(int, int);
00144        void SideBarUp(bool);
00145        void SideBarUpdate();
00146        void PasteAvail();
00147 };
00148 
00149 class SCRIBUS_API SideBar : public QLabel
00150 {
00151        Q_OBJECT
00152 
00153 public:
00154        SideBar(QWidget *pa);
00155        ~SideBar() {};
00156        int offs;
00157        int CurrentPar;
00158        SEditor *editor;
00159        QPopupMenu *pmen;
00160        bool noUpdt;
00161        bool inRep;
00162 
00163 protected:
00164        void paintEvent(QPaintEvent *e);
00165        void mouseReleaseEvent(QMouseEvent *m);
00166 
00167 signals:
00168        void ChangeStyle(int, const QString&);
00170        void sigEditStyles();
00171 
00172 public slots:
00173        void setPStyle(const QString&);
00174        void doMove(int x, int y);
00175        void doRepaint();
00176        void setRepaint(bool r);
00178        void editStyles();
00179 };
00180 
00181 class SCRIBUS_API SToolBColorF : public QToolBar
00182 {
00183        Q_OBJECT
00184 
00185 public:
00186        SToolBColorF(QMainWindow* parent, ScribusDoc *doc);
00187        ~SToolBColorF() {};
00188        void setCurrentDocument(ScribusDoc *doc);
00189        QLabel* FillIcon;
00190        ColorCombo* TxFill;
00191        ShadeButton *PM2;
00192 
00193 public slots:
00194        void SetColor(int c);
00195        void SetShade(int s);
00196        void newShadeHandler();
00197        void languageChange();
00198 
00199 signals:
00200        void NewColor(int, int);
00201 };
00202 
00203 class SCRIBUS_API SToolBColorS : public QToolBar
00204 {
00205        Q_OBJECT
00206 
00207 public:
00208        SToolBColorS(QMainWindow* parent, ScribusDoc *doc);
00209        ~SToolBColorS() {};
00210        void setCurrentDocument(ScribusDoc *doc);
00211        QLabel* StrokeIcon;
00212        ColorCombo* TxStroke;
00213        ShadeButton *PM1;
00214 
00215 public slots:
00216        void SetColor(int c);
00217        void SetShade(int s);
00218        void newShadeHandler();
00219        void languageChange();
00220 
00221 signals:
00222        void NewColor(int, int);
00223 };
00224 
00225 class SCRIBUS_API SToolBStyle : public QToolBar
00226 {
00227        Q_OBJECT
00228 
00229 public:
00230        SToolBStyle(QMainWindow* parent);
00231        ~SToolBStyle() {};
00232        StyleSelect* SeStyle;
00233        QLabel* trackingLabel;
00234        MSpinBox* Extra;
00235 
00236 public slots:
00237        void newStrikeHandler();
00238        void newUnderlineHandler();
00239        void newOutlineHandler();
00240        void newShadowHandler();
00241        void newKernHandler();
00242        void SetShadow(int x, int y);
00243        void setStrike(int p, int w);
00244        void setUnderline(int p, int w);
00245        void setOutline(int o);
00246        void SetStyle(int s);
00247        void SetKern(int k);
00248        void languageChange();
00249 
00250 signals:
00251        void NewKern(int);
00252        void NewShadow(int, int);
00253        void newOutline(int);
00254        void newStrike(int, int);
00255        void newUnderline(int, int);
00256        void newStyle(int);
00257 };
00258 
00259 class SCRIBUS_API SToolBAlign : public QToolBar
00260 {
00261        Q_OBJECT
00262 
00263 public:
00264        SToolBAlign(QMainWindow* parent);
00265        ~SToolBAlign() {};
00266        AlignSelect* GroupAlign;
00267        ParaStyleComboBox *paraStyleCombo;
00268 
00269 public slots:
00270        void SetAlign(int s);
00271        void SetParaStyle(int s);
00272        void languageChange();
00273 
00274 signals:
00275        void newAlign(int);
00276        void newParaStyle(const QString&);
00277 };
00278 
00279 class SCRIBUS_API SToolBFont : public QToolBar
00280 {
00281        Q_OBJECT
00282 
00283 public:
00284        SToolBFont(QMainWindow* parent);
00285        ~SToolBFont() {};
00286        FontCombo* Fonts;
00287        MSpinBox* ChScale;
00288        MSpinBox* ChScaleV;
00289 
00290 public slots:
00291        void SetFont(QString f);
00292        void SetSize(double s);
00293        void SetScale(int s);
00294        void SetScaleV(int s);
00295        void newSizeHandler();
00296 
00297 signals:
00298        void NewFont(const QString &);
00299        void NewSize(double);
00300        void NewScale(int);
00301        void NewScaleV(int);
00302 
00303 private:
00304        MSpinBox* Size;
00305        QLabel* ScaleTxt;
00306        QLabel* ScaleTxtV;
00307 
00308 private slots:
00309        void languageChange();
00310 };
00311 
00312 class SCRIBUS_API StoryEditor : public QMainWindow
00313 {
00314        Q_OBJECT
00315        friend class SEditor;
00316 
00317 public:
00318        StoryEditor( QWidget* parent );
00319 //     StoryEditor( QWidget* parent, ScribusDoc *docc, PageItem* ite );
00320        ~StoryEditor();
00321 
00322        void setCurrentDocumentAndItem(ScribusDoc *doc=NULL, PageItem *item=NULL);
00323 
00324        ScribusDoc* currentDocument() const;
00325        PageItem* currentItem() const;
00326        SEditor* Editor;
00327        bool activFromApp;
00328 
00329 public slots:
00330        void newAlign(int st);
00331        void newTxFill(int c, int s);
00332        void newTxStroke(int c, int s);
00333        void newTxFont(const QString &f);
00334        void newTxSize(double s);
00335        void newTxStyle(int s);
00336 
00337 signals:
00338        void DocChanged();
00339        void EditSt();
00340 
00341 private:
00342        //int exec();
00343        void changeAlign(int align);
00344        int result;
00345        bool textDataChanged() const;
00346 
00348        bool smartSelection;
00349        int smartSel;
00350 
00351        ScribusDoc* currDoc;
00352        PageItem* currItem;
00353 
00354        bool textChanged;
00355        bool firstSet;
00356 
00357        bool blockUpdate;
00358        int CurrPara;
00359        int CurrChar;
00360 
00361 protected slots:
00362        void setBackPref();
00363        void setFontPref();
00364        void newTxScale(int s);
00365        void newTxScaleV(int s);
00366        void newTxKern(int s);
00367        void newShadowOffs(int x, int y);
00368        void newTxtOutline(int o);
00369        void newTxtUnderline(int p, int w);
00370        void newTxtStrike(int p, int w);
00371        void updateProps(int p, int ch);
00372 
00373        void newStyle(const QString&);
00374        void changeStyleSB(int pa, const QString&);
00375        void changeStyle();
00376        void updateStatus();
00377        void Do_leave();
00378        void Do_leave2();
00380        void Do_saveDocument();
00381        bool Do_new();
00382        void slotFileRevert();
00383 
00384        void Do_selectAll();
00385        void Do_copy();
00386        void Do_paste();
00387        void Do_cut();
00388        void Do_del();
00389        void Do_insSp();
00390        void Do_fontPrev();
00391        void CopyAvail(bool u);
00392        void PasteAvail();
00393        void updateTextFrame();
00394        void SearchText();
00395        void slotEditStyles();
00396        void modifiedText();
00397        void LoadTextFile();
00398        void SaveTextFile();
00399        void setSmart(bool);
00400        void languageChange();
00401 
00402        void specialActionKeyEvent(const QString& actionName, int unicodevalue);
00404        void slot_insertSpecialChar();
00405        void slot_insertUserSpecialChar(QChar);
00406        // 10/12/2004 - pv - #1203: wrong selection on double click
00407        void doubleClick(int para, int pos);
00408 
00409 protected:
00410        void initActions();
00411        void updateUnicodeActions();
00412        void buildMenus();
00413        void buildGUI();
00414        void connectSignals();
00415        void disconnectSignals();
00418        void loadPrefs();
00420        void savePrefs();
00421 
00430        CharSelect *charSelect;
00431        bool charSelectUsed;
00432        void showEvent(QShowEvent *);
00433        void hideEvent(QHideEvent *);
00434 
00435        void closeEvent(QCloseEvent *);
00436        void keyPressEvent (QKeyEvent * e);
00437        bool eventFilter( QObject* ob, QEvent* ev );
00438 
00439     QHBoxLayout* StoryEd2Layout;
00440        QGridLayout* ButtonGroup1Layout;
00441        QGridLayout* ButtonGroup2Layout;
00442 
00443        PrefsManager* prefsManager;
00444        PrefsContext* prefs;
00445 
00446        QMap<QString, QGuardedPtr<ScrAction> > seActions;
00447        QStringList unicodeCharActionNames;
00448        MenuManager* seMenuMgr;
00449        QPixmap noIcon;
00450 
00451        QToolBar* FileTools;
00452        SToolBFont* FontTools;
00453        SToolBAlign* AlignTools;
00454        SToolBColorF* FillTools;
00455        SToolBColorS* StrokeTools;
00456        SToolBStyle* StyleTools;
00457        QSplitter* EdSplit;
00458        SideBar* EditorBar;
00459        QButtonGroup* ButtonGroup1;
00460        QButtonGroup* ButtonGroup2;
00461        QLabel* WordCT1;
00462        QLabel* WordCT3;
00463        QLabel* ParCT;
00464        QLabel* ParC;
00465        QLabel* WordCT;
00466        QLabel* WordC;
00467        QLabel* CharCT;
00468        QLabel* CharC;
00469        QLabel* WordCT2;
00470        QLabel* WordC2;
00471        QLabel* CharCT2;
00472        QLabel* CharC2;
00473 };
00474 
00475 #endif
00476