00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef paragdia_h
00021 #define paragdia_h
00022
00023 #include <kdialogbase.h>
00024 #include <qstringlist.h>
00025 #include <qptrlist.h>
00026 #include <qstylesheet.h>
00027 #include <koRuler.h>
00028 #include <koUnit.h>
00029 #include <qdict.h>
00030 #include <qlineedit.h>
00031 #include "koparaglayout.h"
00032 #include "koparagcounter.h"
00033 #include <knuminput.h>
00034 #include <qgroupbox.h>
00035 #include <qvgroupbox.h>
00036 #include <koffice_export.h>
00037 class KButtonBox;
00038 class KColorButton;
00039 class KoTextDocument;
00040 class KoBorderPreview;
00041 class KoStylePreview;
00042 class KPagePreview2;
00043 class KPagePreview;
00044 class KoSpinBox;
00045 class QButtonGroup;
00046 class QCheckBox;
00047 class QComboBox;
00048 class QGridLayout;
00049 class QGroupBox;
00050 class QLabel;
00051 class QListBox;
00052 class QPushButton;
00053 class QRadioButton;
00054 class QWidget;
00055 class KDoubleNumInput;
00056 class KComboBox;
00057 class QVBoxLayout;
00058
00064 class KOTEXT_EXPORT KoParagLayoutWidget : public QWidget
00065 {
00066 Q_OBJECT
00067 public:
00068
00069 KoParagLayoutWidget( int flag, QWidget * parent, const char * name = 0 )
00070 : QWidget( parent, name ), m_flag( flag )
00071 {
00072 }
00073 virtual ~KoParagLayoutWidget() {}
00074
00075
00076 virtual void display( const KoParagLayout & lay ) = 0;
00077
00078
00079
00080 virtual void save( KoParagLayout & lay ) = 0;
00081
00082
00083
00084
00085
00087 virtual QString tabName() = 0;
00088
00089
00090 int flag() const { return m_flag; }
00091
00092 private:
00093 int m_flag;
00094 };
00095
00099 class KOTEXT_EXPORT KoIndentSpacingWidget : public KoParagLayoutWidget
00100 {
00101 Q_OBJECT
00102 public:
00103 KoIndentSpacingWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent,const char * name = 0 );
00104 virtual ~KoIndentSpacingWidget() {}
00105
00106 virtual void display( const KoParagLayout & lay );
00107 virtual void save( KoParagLayout & lay );
00108
00109 virtual QString tabName();
00110
00111 double leftIndent() const;
00112 double rightIndent() const;
00113 double firstLineIndent() const;
00114 double spaceBeforeParag() const;
00115 double spaceAfterParag() const;
00116 double lineSpacing() const;
00117 KoParagLayout::SpacingType lineSpacingType() const;
00118 private slots:
00119 void leftChanged( double );
00120 void rightChanged( double );
00121 void firstChanged( double );
00122 void spacingActivated( int );
00123 void spacingChanged( double );
00124 void beforeChanged( double );
00125 void afterChanged( double );
00126 private:
00127 void updateLineSpacing( KoParagLayout::SpacingType _type );
00128
00129 KDoubleNumInput *eLeft, *eRight, *eFirstLine, *eBefore, *eAfter, *eSpacing;
00130 QComboBox *cSpacing;
00131 KPagePreview *prev1;
00132 KoUnit::Unit m_unit;
00133 };
00134
00138 class KOTEXT_EXPORT KoParagAlignWidget : public KoParagLayoutWidget
00139 {
00140 Q_OBJECT
00141 public:
00142 KoParagAlignWidget(bool breakLine, QWidget * parent, const char * name = 0 );
00143 virtual ~KoParagAlignWidget() {}
00144
00145 virtual void display( const KoParagLayout & lay );
00146 virtual void save( KoParagLayout & lay );
00147
00148 virtual QString tabName();
00149
00150 int pageBreaking() const;
00151 int align() const;
00152
00153 protected slots:
00154 void alignLeft();
00155 void alignCenter();
00156 void alignRight();
00157 void alignJustify();
00158
00159 protected:
00160 void clearAligns();
00161
00162 private:
00163 QRadioButton *rLeft, *rCenter, *rRight, *rJustify;
00164 QCheckBox *cKeepLinesTogether, *cHardBreakBefore, *cHardBreakAfter;
00165 KPagePreview2 *prev2;
00166 };
00167
00171 class KOTEXT_EXPORT KoParagBorderWidget : public KoParagLayoutWidget
00172 {
00173 Q_OBJECT
00174 public:
00175 KoParagBorderWidget( QWidget * parent, const char * name = 0 );
00176 virtual ~KoParagBorderWidget() {}
00177
00178 virtual void display( const KoParagLayout & lay );
00179 virtual void save( KoParagLayout & lay );
00180
00181 virtual QString tabName();
00182
00183 KoBorder leftBorder() const { return m_leftBorder; }
00184 KoBorder rightBorder() const { return m_rightBorder; }
00185 KoBorder topBorder() const { return m_topBorder; }
00186 KoBorder bottomBorder() const { return m_bottomBorder; }
00187
00188 protected:
00189 void updateBorders();
00190
00191 protected slots:
00192 void brdLeftToggled( bool );
00193 void brdRightToggled( bool );
00194 void brdTopToggled( bool );
00195 void brdBottomToggled( bool );
00196
00197
00198
00199 void slotPressEvent(QMouseEvent *_ev);
00200
00201 private:
00202 QComboBox *cWidth, *cStyle;
00203 QPushButton *bLeft, *bRight, *bTop, *bBottom;
00204 KColorButton *bColor;
00205 KoBorder m_leftBorder, m_rightBorder, m_topBorder, m_bottomBorder;
00206 KoBorderPreview *prev3;
00207 };
00208
00209 class KOTEXT_EXPORT KoCounterStyleWidget : public QWidget
00210 {
00211 Q_OBJECT
00212 public:
00213 KoCounterStyleWidget( bool displayDepth= true, bool onlyStyleTypeLetter = false, bool disableAll=false, QWidget* parent = 0, const char* name = 0 );
00214
00215 class StyleRepresenter {
00216 public:
00217 StyleRepresenter (const QString name, KoParagCounter::Style style, bool bullet=false) {
00218 m_name=name;
00219 m_style=style;
00220 m_bullet=bullet;
00221 }
00222 QString name() const { return m_name; }
00223 KoParagCounter::Style style() const { return m_style; }
00224 bool isBullet() const { return m_bullet; }
00225
00226 private:
00227 QString m_name;
00228 KoParagCounter::Style m_style;
00229 bool m_bullet;
00230 };
00231
00232 static void makeCounterRepresenterList( QPtrList<StyleRepresenter>& stylesList , bool onlyStyleTypeLetter = false );
00233 void fillStyleCombo(KoParagCounter::Numbering type = KoParagCounter::NUM_LIST);
00234 void display( const KoParagLayout & lay );
00235 void changeKWSpinboxType(KoParagCounter::Style st);
00236 const KoParagCounter & counter() const { return m_counter; }
00237 void setCounter( const KoParagCounter& counter );
00238
00239 public slots:
00240 void numTypeChanged( int nType );
00241
00242 signals:
00243 void sig_startChanged( int );
00244 void sig_restartChanged(bool);
00245 void sig_depthChanged(int);
00246 void sig_displayLevelsChanged(int);
00247 void sig_suffixChanged(const QString &);
00248 void sig_prefixChanged(const QString &);
00249 void sig_numTypeChanged( int );
00250 void sig_alignmentChanged( int );
00251 void changeCustomBullet( const QString & , QChar );
00252 void changeStyle( KoParagCounter::Style );
00253 protected slots:
00254 void startChanged(int i) {m_counter.setStartNumber(i);emit sig_startChanged(i);}
00255 void restartChanged(bool b) {m_counter.setRestartCounter(b);emit sig_restartChanged(b);}
00256 void depthChanged(int i) {m_counter.setDepth(i);emit sig_depthChanged(i);}
00257 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i);emit sig_displayLevelsChanged(i);}
00258 void alignmentChanged(const QString& s);
00259 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt);emit sig_suffixChanged(txt); }
00260 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt);emit sig_prefixChanged(txt); }
00261
00262 void numStyleChanged();
00263 void selectCustomBullet();
00264
00265 protected:
00266 void displayStyle( KoParagCounter::Style style );
00267
00268 private:
00269 QGroupBox *gStyle;
00270 QPtrList <StyleRepresenter> stylesList;
00271 QListBox *lstStyle;
00272 KoParagCounter m_counter;
00273 QLineEdit *sSuffix, *sPrefix;
00274 QPushButton *bCustom;
00275 KoSpinBox *spnStart;
00276 QSpinBox *spnDepth;
00277 QSpinBox *spnDisplayLevels;
00278 QLabel *lStart;
00279 QLabel *lCustom;
00280 QCheckBox *cbRestart;
00281 KComboBox *cbAlignment;
00282 QLabel *lAlignment;
00283 unsigned int styleBuffer;
00284 bool noSignals;
00285 };
00286
00290 class KOTEXT_EXPORT KoParagCounterWidget : public KoParagLayoutWidget
00291 {
00292 Q_OBJECT
00293 public:
00294
00295 KoParagCounterWidget( bool disableAll=false ,QWidget * parent=0L, const char * name = 0 );
00296 virtual ~KoParagCounterWidget() {}
00297
00298 virtual void display( const KoParagLayout & lay );
00299 virtual void save( KoParagLayout & lay );
00300
00301 virtual QString tabName();
00302
00303 const KoParagCounter & counter() const { return m_counter; }
00304
00305 protected slots:
00306
00307
00308 void numTypeChanged( int );
00309
00310 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt); updatePreview(); }
00311 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt); updatePreview();}
00312 void startChanged(int i) {m_counter.setStartNumber(i); updatePreview();}
00313 void restartChanged(bool b) {m_counter.setRestartCounter(b); }
00314 void depthChanged(int i) {m_counter.setDepth(i); updatePreview();}
00315 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i); updatePreview();}
00316 void alignmentChanged(int i) {m_counter.setAlignment(i); updatePreview();}
00317 void slotChangeCustomBullet( const QString & f, QChar c);
00318 void styleChanged (KoParagCounter::Style st );
00319
00320 private:
00321 void updatePreview();
00322
00323 QButtonGroup *gNumbering;
00324 KoParagCounter m_counter;
00325 KoStylePreview *preview;
00326 KoCounterStyleWidget *m_styleWidget;
00327 unsigned int styleBuffer;
00328 bool noSignals;
00329 };
00330
00334 class KoTabulatorsLineEdit : public KDoubleNumInput
00335 {
00336 Q_OBJECT
00337 public:
00338 KoTabulatorsLineEdit ( QWidget * parent, const char * name=0 );
00339
00340 protected:
00341 virtual void keyPressEvent ( QKeyEvent * );
00342 signals:
00343 void keyReturnPressed();
00344 };
00345
00349 class KOTEXT_EXPORT KoParagTabulatorsWidget : public KoParagLayoutWidget
00350 {
00351 Q_OBJECT
00352 public:
00353 KoParagTabulatorsWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent, const char * name = 0 );
00354 virtual ~KoParagTabulatorsWidget() {}
00355
00356 virtual void display( const KoParagLayout & lay );
00357 virtual void save( KoParagLayout & lay );
00358 virtual QString tabName();
00359
00360 KoTabulatorList tabList() const { return m_tabList; }
00361
00362 void setCurrentTab( double tabPos );
00363
00364 protected slots:
00365 void slotTabValueChanged( double );
00366 void slotAlignCharChanged( const QString &_text );
00367 void newClicked();
00368 void deleteClicked();
00369 void deleteAllClicked();
00370 void setActiveItem(int selected);
00371 void updateAlign(int selected);
00372 void updateFilling(int selected);
00373 void updateWidth();
00374
00375 private:
00376
00377 void sortLists();
00378 QString tabToString(const KoTabulator &tab);
00379
00380 QVBoxLayout* editLayout;
00381
00382 QListBox* lstTabs;
00383 QGroupBox* gPosition;
00384 KoTabulatorsLineEdit* sTabPos;
00385 QButtonGroup* bgAlign;
00386 QRadioButton* rAlignLeft;
00387 QRadioButton* rAlignCentre;
00388 QRadioButton* rAlignRight;
00389 QRadioButton* rAlignVar;
00390 QLineEdit* sAlignChar;
00391 QGroupBox* gTabLeader;
00392 QComboBox* cFilling;
00393 KDoubleNumInput* eWidth;
00394 QPushButton* bNew;
00395 QPushButton* bDelete;
00396 QPushButton* bDeleteAll;
00397
00398 KoTabulatorList m_tabList;
00399 KoUnit::Unit m_unit;
00400 double m_toplimit;
00401 bool noSignals;
00402 };
00403
00409 class KoStylePreview : public QGroupBox
00410 {
00411 Q_OBJECT
00412
00413 public:
00414 KoStylePreview( const QString &title, const QString &text, QWidget *parent, const char* name = 0 );
00415 virtual ~KoStylePreview();
00416
00419 void setStyle( KoParagStyle *style );
00420
00422 void setCounter( const KoParagCounter & counter );
00423
00424 protected:
00425 void drawContents( QPainter *painter );
00426
00427 KoTextDocument *m_textdoc;
00428 KoZoomHandler *m_zoomHandler;
00429 };
00430
00437 class KOTEXT_EXPORT KoParagDia : public KDialogBase
00438 {
00439 Q_OBJECT
00440
00441 public:
00442 enum { PD_SPACING = 1, PD_ALIGN = 2, PD_BORDERS = 4, PD_NUMBERING = 8,
00443 PD_TABS = 16 };
00444
00448 KoParagDia( QWidget*, const char*, int flags, KoUnit::Unit unit, double _frameWidth=-1,bool breakLine=true, bool disableAll = false);
00449 ~KoParagDia();
00450
00452 int getFlags()const { return m_flags; }
00453
00455 void setCurrentPage( int page );
00456
00458 void setParagLayout( const KoParagLayout & lay );
00459
00460
00461 double leftIndent() const { return m_indentSpacingWidget->leftIndent(); }
00462 double rightIndent() const { return m_indentSpacingWidget->rightIndent(); }
00463 double firstLineIndent() const { return m_indentSpacingWidget->firstLineIndent(); }
00464 double spaceBeforeParag() const { return m_indentSpacingWidget->spaceBeforeParag(); }
00465 double spaceAfterParag() const { return m_indentSpacingWidget->spaceAfterParag(); }
00466 double lineSpacing() const { return m_indentSpacingWidget->lineSpacing(); }
00467 KoParagLayout::SpacingType lineSpacingType() const{ return m_indentSpacingWidget->lineSpacingType(); }
00468
00469
00470 int align() const { return m_alignWidget->align(); }
00471 int pageBreaking() const { return m_alignWidget->pageBreaking(); }
00472
00473
00474 KoBorder leftBorder() const { return m_borderWidget->leftBorder(); }
00475 KoBorder rightBorder() const { return m_borderWidget->rightBorder(); }
00476 KoBorder topBorder() const { return m_borderWidget->topBorder(); }
00477 KoBorder bottomBorder() const { return m_borderWidget->bottomBorder(); }
00478
00479
00480 const KoParagCounter & counter() const { return m_counterWidget->counter(); }
00481
00482
00483 KoTabulatorList tabListTabulator() const { return m_tabulatorsWidget->tabList(); }
00484 KoParagTabulatorsWidget * tabulatorsWidget() const { return m_tabulatorsWidget; }
00485
00486
00487 bool isAlignChanged() const {return oldLayout.alignment!=align();}
00488 bool isLineSpacingChanged() const {return (oldLayout.lineSpacingValue() !=lineSpacing() || oldLayout.lineSpacingType != lineSpacingType());}
00489 bool isLeftMarginChanged() const { return oldLayout.margins[QStyleSheetItem::MarginLeft]!=leftIndent(); }
00490 bool isRightMarginChanged() const { return oldLayout.margins[QStyleSheetItem::MarginRight]!=rightIndent();}
00491 bool isFirstLineChanged() const {return oldLayout.margins[ QStyleSheetItem::MarginFirstLine]!=firstLineIndent();}
00492 bool isSpaceBeforeChanged() const { return oldLayout.margins[QStyleSheetItem::MarginTop]!=spaceBeforeParag();}
00493 bool isSpaceAfterChanged() const {return oldLayout.margins[QStyleSheetItem::MarginBottom]!=spaceAfterParag();}
00494 bool isPageBreakingChanged() const { return oldLayout.pageBreaking!=pageBreaking(); }
00495 bool isCounterChanged() const;
00496
00497 bool isBorderChanged() const { return (oldLayout.leftBorder!=leftBorder() ||
00498 oldLayout.rightBorder!=rightBorder() ||
00499 oldLayout.topBorder!=topBorder() ||
00500 oldLayout.bottomBorder!=bottomBorder() ); }
00501 bool listTabulatorChanged() const {return oldLayout.tabList()!=tabListTabulator();}
00502 KoParagLayout paragLayout() const;
00504 int changedFlags() const;
00505
00506 protected slots:
00507 void slotReset();
00508 virtual void slotOk();
00509 virtual void slotApply();
00510 signals:
00511 void applyParagStyle();
00512
00513 private:
00514 KoIndentSpacingWidget * m_indentSpacingWidget;
00515 KoParagAlignWidget * m_alignWidget;
00516 KoParagBorderWidget * m_borderWidget;
00517 KoParagCounterWidget * m_counterWidget;
00518 KoParagTabulatorsWidget * m_tabulatorsWidget;
00519
00520 int m_flags;
00521 KoParagLayout oldLayout;
00522 };
00523
00524 #endif