00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef paragdia_h
00022 #define paragdia_h
00023
00024 #include <kdialogbase.h>
00025 #include <qstringlist.h>
00026 #include <qptrlist.h>
00027 #include <qstylesheet.h>
00028 #include <KoRuler.h>
00029 #include <KoUnit.h>
00030 #include <KoUnitWidgets.h>
00031 #include <qdict.h>
00032 #include <qlineedit.h>
00033 #include "KoParagLayout.h"
00034 #include "KoParagCounter.h"
00035 #include <knuminput.h>
00036 #include <qgroupbox.h>
00037 #include <qvgroupbox.h>
00038 #include <koffice_export.h>
00039 class KoTextZoomHandler;
00040 class KButtonBox;
00041 class KPushButton;
00042 class KColorButton;
00043 class KoTextDocument;
00044 class KoBorderPreview;
00045 class KoStylePreview;
00046 class KPagePreview2;
00047 class KPagePreview;
00048 class KoSpinBox;
00049 class QButtonGroup;
00050 class QCheckBox;
00051 class QComboBox;
00052 class QGridLayout;
00053 class QGroupBox;
00054 class QLabel;
00055 class QListBox;
00056 class QPushButton;
00057 class QRadioButton;
00058 class QWidget;
00059 class QWidgetStack;
00060 class KIntNumInput;
00061 class KDoubleNumInput;
00062 class KComboBox;
00063 class QVBoxLayout;
00064 class KoUnitDoubleSpinBox;
00065 class KoParagDecorationTab;
00066
00072 class KOTEXT_EXPORT KoParagLayoutWidget : public QWidget
00073 {
00074 Q_OBJECT
00075 public:
00076
00077 KoParagLayoutWidget( int flag, QWidget * parent, const char * name = 0 )
00078 : QWidget( parent, name ), m_flag( flag )
00079 {
00080 }
00081 virtual ~KoParagLayoutWidget() {}
00082
00083
00084 virtual void display( const KoParagLayout & lay ) = 0;
00085
00086
00087
00088 virtual void save( KoParagLayout & lay ) = 0;
00089
00090
00091
00092
00093
00095 virtual QString tabName() = 0;
00096
00097
00098 int flag() const { return m_flag; }
00099
00100 private:
00101 int m_flag;
00102 };
00103
00107 class KOTEXT_EXPORT KoIndentSpacingWidget : public KoParagLayoutWidget
00108 {
00109 Q_OBJECT
00110 public:
00111 KoIndentSpacingWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent,const char * name = 0 );
00112 virtual ~KoIndentSpacingWidget() {}
00113
00114 virtual void display( const KoParagLayout & lay );
00115 virtual void save( KoParagLayout & lay );
00116
00117 virtual QString tabName();
00118
00119 double leftIndent() const;
00120 double rightIndent() const;
00121 double firstLineIndent() const;
00122 double spaceBeforeParag() const;
00123 double spaceAfterParag() const;
00124 double lineSpacing() const;
00125 KoParagLayout::SpacingType lineSpacingType() const;
00126 private slots:
00127 void leftChanged( double );
00128 void rightChanged( double );
00129 void firstChanged( double );
00130 void spacingActivated( int );
00131 void spacingChanged( double );
00132 void spacingChanged( int );
00133 void beforeChanged( double );
00134 void afterChanged( double );
00135 private:
00136 void updateLineSpacing( KoParagLayout::SpacingType _type );
00137
00138 QWidgetStack *sSpacingStack;
00139 KIntNumInput *eSpacingPercent;
00140 KoUnitDoubleSpinBox *eBefore, *eAfter, *eSpacing;
00141 KoUnitDoubleSpinBox *eLeft, *eRight, *eFirstLine;
00142 QComboBox *cSpacing;
00143 KPagePreview *prev1;
00144 KoUnit::Unit m_unit;
00145 };
00146
00150 class KOTEXT_EXPORT KoParagAlignWidget : public KoParagLayoutWidget
00151 {
00152 Q_OBJECT
00153 public:
00154 KoParagAlignWidget(bool breakLine, QWidget * parent, const char * name = 0 );
00155 virtual ~KoParagAlignWidget() {}
00156
00157 virtual void display( const KoParagLayout & lay );
00158 virtual void save( KoParagLayout & lay );
00159
00160 virtual QString tabName();
00161
00162 int pageBreaking() const;
00163 int align() const;
00164
00165 protected slots:
00166 void alignLeft();
00167 void alignCenter();
00168 void alignRight();
00169 void alignJustify();
00170
00171 protected:
00172 void clearAligns();
00173
00174 private:
00175 QRadioButton *rLeft, *rCenter, *rRight, *rJustify;
00176 QCheckBox *cKeepLinesTogether, *cHardBreakBefore, *cHardBreakAfter;
00177 KPagePreview2 *prev2;
00178 };
00179
00183 class KOTEXT_EXPORT KoParagDecorationWidget : public KoParagLayoutWidget
00184 {
00185 Q_OBJECT
00186 public:
00187 KoParagDecorationWidget( QWidget * parent, const char * name = 0 );
00188 virtual ~KoParagDecorationWidget() {}
00189
00190 virtual void display( const KoParagLayout & lay );
00191 virtual void save( KoParagLayout & lay );
00192
00193 virtual QString tabName();
00194
00195
00196 KoBorder leftBorder() const { return m_leftBorder; }
00197 KoBorder rightBorder() const { return m_rightBorder; }
00198 KoBorder topBorder() const { return m_topBorder; }
00199 KoBorder bottomBorder() const { return m_bottomBorder; }
00200 bool joinBorder() const { return m_joinBorder; }
00201
00202
00203 QColor backgroundColor() const;
00204
00205 protected slots:
00206 void brdLeftToggled( bool );
00207 void brdRightToggled( bool );
00208 void brdTopToggled( bool );
00209 void brdBottomToggled( bool );
00210 void brdJoinToggled( bool );
00211 void slotPressEvent(QMouseEvent *_ev);
00212
00213 protected:
00214 void updateBorders();
00215
00216 private:
00217
00218 KoBorderPreview *wPreview;
00220 KoParagDecorationTab *wDeco;
00222 KoBorder::BorderStyle curBorderStyle() const;
00224 unsigned int curBorderWidth() const;
00226 QColor curBorderColor() const;
00227
00228
00229 KoBorder m_leftBorder, m_rightBorder, m_topBorder, m_bottomBorder;
00230 bool m_joinBorder;
00231
00248 void clickedBorderPreview( KoBorder& border, KoBorder::BorderType position,
00249 KPushButton *corresponding );
00250
00252 void updateBorder( KoBorder& border );
00254 bool borderChanged( const KoBorder& border );
00255
00256 };
00257
00258
00259 class KOTEXT_EXPORT KoCounterStyleWidget : public QWidget
00260 {
00261 Q_OBJECT
00262 public:
00263 KoCounterStyleWidget( bool displayDepth= true, bool onlyStyleTypeLetter = false, bool disableAll=false, QWidget* parent = 0, const char* name = 0 );
00264
00265 class StyleRepresenter {
00266 public:
00267 StyleRepresenter (const QString name, KoParagCounter::Style style, bool bullet=false) {
00268 m_name=name;
00269 m_style=style;
00270 m_bullet=bullet;
00271 }
00272 QString name() const { return m_name; }
00273 KoParagCounter::Style style() const { return m_style; }
00274 bool isBullet() const { return m_bullet; }
00275
00276 private:
00277 QString m_name;
00278 KoParagCounter::Style m_style;
00279 bool m_bullet;
00280 };
00281
00282 static void makeCounterRepresenterList( QPtrList<StyleRepresenter>& stylesList , bool onlyStyleTypeLetter = false );
00283 void fillStyleCombo(KoParagCounter::Numbering type = KoParagCounter::NUM_LIST);
00284 void display( const KoParagLayout & lay );
00285 void changeKWSpinboxType(KoParagCounter::Style st);
00286 const KoParagCounter & counter() const { return m_counter; }
00287 void setCounter( const KoParagCounter& counter );
00288
00289 public slots:
00290 void numTypeChanged( int nType );
00291
00292 signals:
00293 void sig_startChanged( int );
00294 void sig_restartChanged(bool);
00295 void sig_depthChanged(int);
00296 void sig_displayLevelsChanged(int);
00297 void sig_suffixChanged(const QString &);
00298 void sig_prefixChanged(const QString &);
00299 void sig_numTypeChanged( int );
00300 void sig_alignmentChanged( int );
00301 void changeCustomBullet( const QString & , QChar );
00302 void changeStyle( KoParagCounter::Style );
00303 protected slots:
00304 void startChanged(int i) {m_counter.setStartNumber(i);emit sig_startChanged(i);}
00305 void restartChanged(bool b) {m_counter.setRestartCounter(b);emit sig_restartChanged(b);}
00306 void depthChanged(int i) {m_counter.setDepth(i);emit sig_depthChanged(i);}
00307 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i);emit sig_displayLevelsChanged(i);}
00308 void alignmentChanged(const QString& s);
00309 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt);emit sig_suffixChanged(txt); }
00310 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt);emit sig_prefixChanged(txt); }
00311
00312 void numStyleChanged();
00313 void selectCustomBullet();
00314
00315 protected:
00316 void displayStyle( KoParagCounter::Style style );
00317
00318 private:
00319 QGroupBox *gStyle;
00320 QPtrList <StyleRepresenter> stylesList;
00321 QListBox *lstStyle;
00322 KoParagCounter m_counter;
00323 QLineEdit *sSuffix, *sPrefix;
00324 QPushButton *bCustom;
00325 KoSpinBox *spnStart;
00326 QSpinBox *spnDepth;
00327 QSpinBox *spnDisplayLevels;
00328 QLabel *lStart;
00329 QLabel *lCustom;
00330 QCheckBox *cbRestart;
00331 KComboBox *cbAlignment;
00332 QLabel *lAlignment;
00333 unsigned int styleBuffer;
00334 bool noSignals;
00335 };
00336
00340 class KOTEXT_EXPORT KoParagCounterWidget : public KoParagLayoutWidget
00341 {
00342 Q_OBJECT
00343 public:
00344
00345 KoParagCounterWidget( bool disableAll=false ,QWidget * parent=0L, const char * name = 0 );
00346 virtual ~KoParagCounterWidget() {}
00347
00348 virtual void display( const KoParagLayout & lay );
00349 virtual void save( KoParagLayout & lay );
00350
00351 virtual QString tabName();
00352
00353 const KoParagCounter & counter() const { return m_counter; }
00354
00355 protected slots:
00356
00357
00358 void numTypeChanged( int );
00359
00360 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt); updatePreview(); }
00361 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt); updatePreview();}
00362 void startChanged(int i) {m_counter.setStartNumber(i); updatePreview();}
00363 void restartChanged(bool b) {m_counter.setRestartCounter(b); }
00364 void depthChanged(int i) {m_counter.setDepth(i); updatePreview();}
00365 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i); updatePreview();}
00366 void alignmentChanged(int i) {m_counter.setAlignment(i); updatePreview();}
00367 void slotChangeCustomBullet( const QString & f, QChar c);
00368 void styleChanged (KoParagCounter::Style st );
00369
00370 private:
00371 void updatePreview();
00372
00373 QButtonGroup *gNumbering;
00374 KoParagCounter m_counter;
00375 KoStylePreview *preview;
00376 KoCounterStyleWidget *m_styleWidget;
00377 unsigned int styleBuffer;
00378 bool noSignals;
00379 };
00380
00384 class KoTabulatorsLineEdit : public KoUnitDoubleSpinBox
00385 {
00386 Q_OBJECT
00387 public:
00388 KoTabulatorsLineEdit( QWidget *parent, double lower, double upper, double step, double value = 0.0,
00389 KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
00390
00391 protected:
00392 virtual void keyPressEvent ( QKeyEvent * );
00393 signals:
00394 void keyReturnPressed();
00395 };
00396
00400 class KOTEXT_EXPORT KoParagTabulatorsWidget : public KoParagLayoutWidget
00401 {
00402 Q_OBJECT
00403 public:
00404 KoParagTabulatorsWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent, const char * name = 0 );
00405 virtual ~KoParagTabulatorsWidget() {}
00406
00407 virtual void display( const KoParagLayout & lay );
00408 virtual void save( KoParagLayout & lay );
00409 virtual QString tabName();
00410
00411 KoTabulatorList tabList() const { return m_tabList; }
00412
00413 void setCurrentTab( double tabPos );
00414
00415 protected slots:
00416 void slotTabValueChanged( double );
00417 void slotAlignCharChanged( const QString &_text );
00418 void newClicked();
00419 void deleteClicked();
00420 void deleteAllClicked();
00421 void setActiveItem(int selected);
00422 void updateAlign(int selected);
00423 void updateFilling(int selected);
00424 void updateWidth();
00425
00426 private:
00427
00428 void sortLists();
00429 QString tabToString(const KoTabulator &tab);
00430
00431 QVBoxLayout* editLayout;
00432
00433 QListBox* lstTabs;
00434 QGroupBox* gPosition;
00435 KoTabulatorsLineEdit* sTabPos;
00436 QButtonGroup* bgAlign;
00437 QRadioButton* rAlignLeft;
00438 QRadioButton* rAlignCentre;
00439 QRadioButton* rAlignRight;
00440 QRadioButton* rAlignVar;
00441 QLineEdit* sAlignChar;
00442 QGroupBox* gTabLeader;
00443 QComboBox* cFilling;
00444 KoUnitDoubleSpinBox* eWidth;
00445 QPushButton* bNew;
00446 QPushButton* bDelete;
00447 QPushButton* bDeleteAll;
00448
00449 KoTabulatorList m_tabList;
00450 KoUnit::Unit m_unit;
00451 double m_toplimit;
00452 bool noSignals;
00453 };
00454
00460 class KoStylePreview : public QGroupBox
00461 {
00462 Q_OBJECT
00463
00464 public:
00465 KoStylePreview( const QString &title, const QString &text, QWidget *parent, const char* name = 0 );
00466 virtual ~KoStylePreview();
00467
00470 void setStyle( KoParagStyle *style );
00471
00473 void setCounter( const KoParagCounter & counter );
00474
00475 protected:
00476 void drawContents( QPainter *painter );
00477
00478 KoTextDocument *m_textdoc;
00479 KoTextZoomHandler *m_zoomHandler;
00480 };
00481
00482
00489 class KOTEXT_EXPORT KoParagDia : public KDialogBase
00490 {
00491 Q_OBJECT
00492
00493 public:
00494 enum { PD_SPACING = 1, PD_ALIGN = 2, PD_DECORATION = 4, PD_NUMBERING = 8,
00495 PD_TABS = 16 };
00496
00500 KoParagDia( QWidget*, const char*, int flags, KoUnit::Unit unit, double _frameWidth=-1,bool breakLine=true, bool disableAll = false);
00501 ~KoParagDia();
00502
00504 int getFlags()const { return m_flags; }
00505
00507 void setCurrentPage( int page );
00508
00510 void setParagLayout( const KoParagLayout & lay );
00511
00512
00513 double leftIndent() const { return m_indentSpacingWidget->leftIndent(); }
00514 double rightIndent() const { return m_indentSpacingWidget->rightIndent(); }
00515 double firstLineIndent() const { return m_indentSpacingWidget->firstLineIndent(); }
00516 double spaceBeforeParag() const { return m_indentSpacingWidget->spaceBeforeParag(); }
00517 double spaceAfterParag() const { return m_indentSpacingWidget->spaceAfterParag(); }
00518 double lineSpacing() const { return m_indentSpacingWidget->lineSpacing(); }
00519 KoParagLayout::SpacingType lineSpacingType() const{ return m_indentSpacingWidget->lineSpacingType(); }
00520
00521
00522 int align() const { return m_alignWidget->align(); }
00523 int pageBreaking() const { return m_alignWidget->pageBreaking(); }
00524
00525
00526 KoBorder leftBorder() const { return m_decorationsWidget->leftBorder(); }
00527 KoBorder rightBorder() const { return m_decorationsWidget->rightBorder(); }
00528 KoBorder topBorder() const { return m_decorationsWidget->topBorder(); }
00529 KoBorder bottomBorder() const { return m_decorationsWidget->bottomBorder(); }
00530 bool joinBorder() const { return m_decorationsWidget->joinBorder(); }
00531
00532
00533 const KoParagCounter & counter() const { return m_counterWidget->counter(); }
00534
00535
00536 KoTabulatorList tabListTabulator() const { return m_tabulatorsWidget->tabList(); }
00537 KoParagTabulatorsWidget * tabulatorsWidget() const { return m_tabulatorsWidget; }
00538
00539 QColor backgroundColor() const { return m_decorationsWidget->backgroundColor(); }
00540
00541
00542 bool isAlignChanged() const {return oldLayout.alignment!=align();}
00543 bool isLineSpacingChanged() const {
00544 return (oldLayout.lineSpacingValue() !=lineSpacing() ||
00545 oldLayout.lineSpacingType != lineSpacingType());
00546 }
00547 bool isLeftMarginChanged() const {
00548 return oldLayout.margins[QStyleSheetItem::MarginLeft]!=leftIndent();
00549 }
00550 bool isRightMarginChanged() const {
00551 return oldLayout.margins[QStyleSheetItem::MarginRight]!=rightIndent();
00552 }
00553 bool isFirstLineChanged() const {
00554 return oldLayout.margins[ QStyleSheetItem::MarginFirstLine]!=firstLineIndent();
00555 }
00556 bool isSpaceBeforeChanged() const {
00557 return oldLayout.margins[QStyleSheetItem::MarginTop]!=spaceBeforeParag();
00558 }
00559 bool isSpaceAfterChanged() const {
00560 return oldLayout.margins[QStyleSheetItem::MarginBottom]!=spaceAfterParag();
00561 }
00562 bool isPageBreakingChanged() const {
00563 return oldLayout.pageBreaking!=pageBreaking();
00564 }
00565 bool isCounterChanged() const;
00566 bool isBorderChanged() const {
00567 return (oldLayout.leftBorder!=leftBorder() ||
00568 oldLayout.rightBorder!=rightBorder() ||
00569 oldLayout.topBorder!=topBorder() ||
00570 oldLayout.bottomBorder!=bottomBorder() );
00571 }
00572 bool isJoinBorderChanged() const { return oldLayout.joinBorder!=joinBorder(); }
00573 bool listTabulatorChanged() const {return oldLayout.tabList()!=tabListTabulator();}
00574 bool isBackgroundColorChanged() const { return oldLayout.backgroundColor != backgroundColor(); }
00575
00576 KoParagLayout paragLayout() const;
00578 int changedFlags() const;
00579
00580 protected slots:
00581 void slotReset();
00582 virtual void slotOk();
00583 virtual void slotApply();
00584 signals:
00585 void applyParagStyle();
00586
00587 private:
00588 KoIndentSpacingWidget * m_indentSpacingWidget;
00589 KoParagAlignWidget * m_alignWidget;
00590 KoParagDecorationWidget * m_decorationsWidget;
00591 KoParagCounterWidget * m_counterWidget;
00592 KoParagTabulatorsWidget * m_tabulatorsWidget;
00593 int m_flags;
00594 KoParagLayout oldLayout;
00595 };
00596
00597 #endif