lib Library API Documentation

koParagDia.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 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 00036 class KButtonBox; 00037 class KColorButton; 00038 class KoTextDocument; 00039 class KoBorderPreview; 00040 class KoStylePreview; 00041 class KPagePreview2; 00042 class KPagePreview; 00043 class KoSpinBox; 00044 class QButtonGroup; 00045 class QCheckBox; 00046 class QComboBox; 00047 class QGridLayout; 00048 class QGroupBox; 00049 class QLabel; 00050 class QListBox; 00051 class QPushButton; 00052 class QRadioButton; 00053 class QWidget; 00054 class KDoubleNumInput; 00055 class KComboBox; 00056 class QVBoxLayout; 00057 00063 class KoParagLayoutWidget : public QWidget 00064 { 00065 Q_OBJECT 00066 public: 00067 // Constructor: parent widget, flag (PD_SOMETHING) and name 00068 KoParagLayoutWidget( int flag, QWidget * parent, const char * name = 0 ) 00069 : QWidget( parent, name ), m_flag( flag ) 00070 { 00071 } 00072 virtual ~KoParagLayoutWidget() {} 00073 00074 // Display settings, from the paragLayout 00075 virtual void display( const KoParagLayout & lay ) = 0; 00076 00077 // Save the settings, into the paragLayout 00078 // This is only used by the stylist, not by paragdia (which needs undo/redo, applying partially etc.) 00079 virtual void save( KoParagLayout & lay ) = 0; 00080 00081 // Return true if the settings where modified 00082 // ## maybe too global, but how to do it differently? We'll see if we need this. 00083 //virtual bool isModified() = 0; 00084 00086 virtual QString tabName() = 0; 00087 00088 // Return the part of the paraglayout that this widget cares about 00089 int flag() const { return m_flag; } 00090 00091 private: 00092 int m_flag; 00093 }; 00094 00098 class KoIndentSpacingWidget : public KoParagLayoutWidget 00099 { 00100 Q_OBJECT 00101 public: 00102 KoIndentSpacingWidget( KoUnit::Unit unit, bool breakLine, double _frameWidth, QWidget * parent,const char * name = 0 ); 00103 virtual ~KoIndentSpacingWidget() {} 00104 00105 virtual void display( const KoParagLayout & lay ); 00106 virtual void save( KoParagLayout & lay ); 00107 //virtual bool isModified(); 00108 virtual QString tabName(); 00109 00110 double leftIndent() const; 00111 double rightIndent() const; 00112 double firstLineIndent() const; 00113 double spaceBeforeParag() const; 00114 double spaceAfterParag() const; 00115 double lineSpacing() const; 00116 int pageBreaking() 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 QCheckBox *cKeepLinesTogether, *cHardBreakBefore, *cHardBreakAfter; 00132 KPagePreview *prev1; 00133 KoUnit::Unit m_unit; 00134 }; 00135 00139 class KoParagAlignWidget : public KoParagLayoutWidget 00140 { 00141 Q_OBJECT 00142 public: 00143 KoParagAlignWidget( QWidget * parent, const char * name = 0 ); 00144 virtual ~KoParagAlignWidget() {} 00145 00146 virtual void display( const KoParagLayout & lay ); 00147 virtual void save( KoParagLayout & lay ); 00148 //virtual bool isModified(); 00149 virtual QString tabName(); 00150 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 KPagePreview2 *prev2; 00165 }; 00166 00170 class KoParagBorderWidget : public KoParagLayoutWidget 00171 { 00172 Q_OBJECT 00173 public: 00174 KoParagBorderWidget( QWidget * parent, const char * name = 0 ); 00175 virtual ~KoParagBorderWidget() {} 00176 00177 virtual void display( const KoParagLayout & lay ); 00178 virtual void save( KoParagLayout & lay ); 00179 //virtual bool isModified(); 00180 virtual QString tabName(); 00181 00182 KoBorder leftBorder() const { return m_leftBorder; } 00183 KoBorder rightBorder() const { return m_rightBorder; } 00184 KoBorder topBorder() const { return m_topBorder; } 00185 KoBorder bottomBorder() const { return m_bottomBorder; } 00186 00187 protected: 00188 void updateBorders(); 00189 00190 protected slots: 00191 void brdLeftToggled( bool ); 00192 void brdRightToggled( bool ); 00193 void brdTopToggled( bool ); 00194 void brdBottomToggled( bool ); 00195 //void brdStyleChanged( const QString & ); 00196 //void brdWidthChanged( const QString & ); 00197 //void brdColorChanged( const QColor& ); 00198 void slotPressEvent(QMouseEvent *_ev); 00199 00200 private: 00201 QComboBox *cWidth, *cStyle; 00202 QPushButton *bLeft, *bRight, *bTop, *bBottom; 00203 KColorButton *bColor; 00204 KoBorder m_leftBorder, m_rightBorder, m_topBorder, m_bottomBorder; 00205 KoBorderPreview *prev3; 00206 }; 00207 00208 class KoCounterStyleWidget : public QWidget 00209 { 00210 Q_OBJECT 00211 public: 00212 KoCounterStyleWidget( bool displayDepth= true, bool onlyStyleTypeLetter = false, bool disableAll=false, QWidget* parent = 0, const char* name = 0 ); 00213 00214 class StyleRepresenter { 00215 public: 00216 StyleRepresenter (const QString name, KoParagCounter::Style style, bool bullet=false) { 00217 m_name=name; 00218 m_style=style; 00219 m_bullet=bullet; 00220 } 00221 QString name() const { return m_name; } 00222 KoParagCounter::Style style() const { return m_style; } 00223 bool isBullet() const { return m_bullet; } 00224 00225 private: 00226 QString m_name; 00227 KoParagCounter::Style m_style; 00228 bool m_bullet; 00229 }; 00230 00231 static void makeCounterRepresenterList( QPtrList<StyleRepresenter>& stylesList , bool onlyStyleTypeLetter = false ); 00232 void fillStyleCombo(KoParagCounter::Numbering type = KoParagCounter::NUM_LIST); 00233 void display( const KoParagLayout & lay ); 00234 void changeKWSpinboxType(KoParagCounter::Style st); 00235 const KoParagCounter & counter() const { return m_counter; } 00236 void setCounter (KoParagCounter counter ); 00237 00238 public slots: 00239 void numTypeChanged( int nType ); 00240 00241 signals: 00242 void sig_startChanged( int ); 00243 void sig_restartChanged(bool); 00244 void sig_depthChanged(int); 00245 void sig_displayLevelsChanged(int); 00246 void sig_suffixChanged(const QString &); 00247 void sig_prefixChanged(const QString &); 00248 void sig_numTypeChanged( int ); 00249 void sig_alignmentChanged( int ); 00250 void changeCustomBullet( const QString & , QChar ); 00251 void changeStyle( KoParagCounter::Style ); 00252 protected slots: 00253 void startChanged(int i) {m_counter.setStartNumber(i);emit sig_startChanged(i);} 00254 void restartChanged(bool b) {m_counter.setRestartCounter(b);emit sig_restartChanged(b);} 00255 void depthChanged(int i) {m_counter.setDepth(i);emit sig_depthChanged(i);} 00256 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i);emit sig_displayLevelsChanged(i);} 00257 void alignmentChanged(const QString& s); 00258 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt);emit sig_suffixChanged(txt); } 00259 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt);emit sig_prefixChanged(txt); } 00260 00261 void numStyleChanged(); 00262 void selectCustomBullet(); 00263 00264 protected: 00265 void displayStyle( KoParagCounter::Style style ); 00266 00267 private: 00268 QGroupBox *gStyle; 00269 QPtrList <StyleRepresenter> stylesList; 00270 QListBox *lstStyle; 00271 KoParagCounter m_counter; 00272 QLineEdit *sSuffix, *sPrefix; 00273 QPushButton *bCustom; 00274 KoSpinBox *spnStart; 00275 QSpinBox *spnDepth; 00276 QSpinBox *spnDisplayLevels; 00277 QLabel *lStart; 00278 QLabel *lCustom; 00279 QCheckBox *cbRestart; 00280 KComboBox *cbAlignment; 00281 QLabel *lAlignment; 00282 unsigned int styleBuffer; 00283 bool noSignals; 00284 }; 00285 00289 class KoParagCounterWidget : public KoParagLayoutWidget 00290 { 00291 Q_OBJECT 00292 public: 00293 00294 KoParagCounterWidget( bool disableAll=false ,QWidget * parent=0L, const char * name = 0 ); 00295 virtual ~KoParagCounterWidget() {} 00296 00297 virtual void display( const KoParagLayout & lay ); 00298 virtual void save( KoParagLayout & lay ); 00299 //virtual bool isModified(); 00300 virtual QString tabName(); 00301 00302 const KoParagCounter & counter() const { return m_counter; } 00303 00304 protected slots: 00305 //void selectCustomBullet(); 00306 //void numStyleChanged(); // selected another style from the combobox 00307 void numTypeChanged( int ); // selected another type radiobutton. 00308 00309 void suffixChanged(const QString & txt) {m_counter.setSuffix(txt); updatePreview(); } 00310 void prefixChanged(const QString & txt) {m_counter.setPrefix(txt); updatePreview();} 00311 void startChanged(int i) {m_counter.setStartNumber(i); updatePreview();} 00312 void restartChanged(bool b) {m_counter.setRestartCounter(b); } 00313 void depthChanged(int i) {m_counter.setDepth(i); updatePreview();} 00314 void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i); updatePreview();} 00315 void alignmentChanged(int i) {m_counter.setAlignment(i); updatePreview();} 00316 void slotChangeCustomBullet( const QString & f, QChar c); 00317 void styleChanged (KoParagCounter::Style st ); 00318 00319 private: 00320 void updatePreview(); 00321 00322 QButtonGroup *gNumbering; 00323 KoParagCounter m_counter; 00324 KoStylePreview *preview; 00325 KoCounterStyleWidget *m_styleWidget; 00326 unsigned int styleBuffer; 00327 bool noSignals; 00328 }; 00329 00333 class KoTabulatorsLineEdit : public KDoubleNumInput 00334 { 00335 Q_OBJECT 00336 public: 00337 KoTabulatorsLineEdit ( QWidget * parent, const char * name=0 ); 00338 00339 protected: 00340 virtual void keyPressEvent ( QKeyEvent * ); 00341 signals: 00342 void keyReturnPressed(); 00343 }; 00344 00348 class KoParagTabulatorsWidget : public KoParagLayoutWidget 00349 { 00350 Q_OBJECT 00351 public: 00352 KoParagTabulatorsWidget( KoUnit::Unit unit, double _frameWidth, QWidget * parent, const char * name = 0 ); 00353 virtual ~KoParagTabulatorsWidget() {} 00354 00355 virtual void display( const KoParagLayout & lay ); 00356 virtual void save( KoParagLayout & lay ); 00357 virtual QString tabName(); 00358 00359 KoTabulatorList tabList() const { return m_tabList; } 00360 00361 void setCurrentTab( double tabPos ); 00362 00363 protected slots: 00364 void slotTabValueChanged( double ); 00365 void slotAlignCharChanged( const QString &_text ); 00366 void newClicked(); 00367 void deleteClicked(); 00368 void deleteAllClicked(); 00369 void setActiveItem(int selected); 00370 void updateAlign(int selected); 00371 void updateFilling(int selected); 00372 void updateWidth(); 00373 00374 private: 00375 00376 void sortLists(); 00377 QString tabToString(const KoTabulator &tab); 00378 00379 QVBoxLayout* editLayout; 00380 00381 QListBox* lstTabs; 00382 QGroupBox* gPosition; 00383 KoTabulatorsLineEdit* sTabPos; 00384 QButtonGroup* bgAlign; 00385 QRadioButton* rAlignLeft; 00386 QRadioButton* rAlignCentre; 00387 QRadioButton* rAlignRight; 00388 QRadioButton* rAlignVar; 00389 QLineEdit* sAlignChar; 00390 QGroupBox* gTabLeader; 00391 QComboBox* cFilling; 00392 KDoubleNumInput* eWidth; 00393 QPushButton* bNew; 00394 QPushButton* bDelete; 00395 QPushButton* bDeleteAll; 00396 00397 KoTabulatorList m_tabList; 00398 KoUnit::Unit m_unit; 00399 double m_toplimit; 00400 bool noSignals; 00401 }; 00402 00408 class KoStylePreview : public QGroupBox 00409 { 00410 Q_OBJECT 00411 00412 public: 00413 KoStylePreview( const QString &title, const QString &text, QWidget *parent, const char* name = 0 ); 00414 virtual ~KoStylePreview(); 00415 00418 void setStyle( KoStyle *style ); 00419 00421 void setCounter( const KoParagCounter & counter ); 00422 00423 protected: 00424 void drawContents( QPainter *painter ); 00425 00426 KoTextDocument *m_textdoc; 00427 KoZoomHandler *m_zoomHandler; 00428 }; 00429 00436 class KoParagDia : public KDialogBase 00437 { 00438 Q_OBJECT 00439 00440 public: 00441 enum { PD_SPACING = 1, PD_ALIGN = 2, PD_BORDERS = 4, PD_NUMBERING = 8, 00442 PD_TABS = 16 }; 00443 00447 KoParagDia( QWidget*, const char*, int flags, KoUnit::Unit unit, double _frameWidth=-1,bool breakLine=true, bool disableAll = false); 00448 ~KoParagDia(); 00449 00450 int getFlags()const { return m_flags; } 00451 00453 void setCurrentPage( int page ); 00454 00456 void setParagLayout( const KoParagLayout & lay ); 00457 00458 // Get values (in pt) - tab 1 00459 double leftIndent() const { return m_indentSpacingWidget->leftIndent(); } 00460 double rightIndent() const { return m_indentSpacingWidget->rightIndent(); } 00461 double firstLineIndent() const { return m_indentSpacingWidget->firstLineIndent(); } 00462 double spaceBeforeParag() const { return m_indentSpacingWidget->spaceBeforeParag(); } 00463 double spaceAfterParag() const { return m_indentSpacingWidget->spaceAfterParag(); } 00464 double lineSpacing() const { return m_indentSpacingWidget->lineSpacing(); } 00465 KoParagLayout::SpacingType lineSpacingType() const{ return m_indentSpacingWidget->lineSpacingType(); } 00466 int pageBreaking() const { return m_indentSpacingWidget->pageBreaking(); } 00467 00468 // tab 2 00469 int align() const { return m_alignWidget->align(); } 00470 00471 // tab 3 00472 KoBorder leftBorder() const { return m_borderWidget->leftBorder(); } 00473 KoBorder rightBorder() const { return m_borderWidget->rightBorder(); } 00474 KoBorder topBorder() const { return m_borderWidget->topBorder(); } 00475 KoBorder bottomBorder() const { return m_borderWidget->bottomBorder(); } 00476 00477 // tab 4 00478 const KoParagCounter & counter() const { return m_counterWidget->counter(); } 00479 00480 // tab 5 00481 KoTabulatorList tabListTabulator() const { return m_tabulatorsWidget->tabList(); } 00482 KoParagTabulatorsWidget * tabulatorsWidget() const { return m_tabulatorsWidget; } 00483 00484 // Support for "what has changed?" 00485 bool isAlignChanged() const {return oldLayout.alignment!=align();} 00486 bool isLineSpacingChanged() const {return (oldLayout.lineSpacingValue() !=lineSpacing() || oldLayout.lineSpacingType != lineSpacingType());} 00487 bool isLeftMarginChanged() const { return oldLayout.margins[QStyleSheetItem::MarginLeft]!=leftIndent(); } 00488 bool isRightMarginChanged() const { return oldLayout.margins[QStyleSheetItem::MarginRight]!=rightIndent();} 00489 bool isFirstLineChanged() const {return oldLayout.margins[ QStyleSheetItem::MarginFirstLine]!=firstLineIndent();} 00490 bool isSpaceBeforeChanged() const { return oldLayout.margins[QStyleSheetItem::MarginTop]!=spaceBeforeParag();} 00491 bool isSpaceAfterChanged() const {return oldLayout.margins[QStyleSheetItem::MarginBottom]!=spaceAfterParag();} 00492 bool isPageBreakingChanged() const { return oldLayout.pageBreaking!=pageBreaking(); } 00493 bool isCounterChanged() const; 00494 00495 bool isBorderChanged() const { return (oldLayout.leftBorder!=leftBorder() || 00496 oldLayout.rightBorder!=rightBorder() || 00497 oldLayout.topBorder!=topBorder() || 00498 oldLayout.bottomBorder!=bottomBorder() ); } 00499 bool listTabulatorChanged() const {return oldLayout.tabList()!=tabListTabulator();} 00500 00501 protected slots: 00502 void slotReset(); 00503 virtual void slotOk(); 00504 virtual void slotApply(); 00505 signals: 00506 void applyParagStyle(); 00507 00508 private: 00509 KoIndentSpacingWidget * m_indentSpacingWidget; 00510 KoParagAlignWidget * m_alignWidget; 00511 KoParagBorderWidget * m_borderWidget; 00512 KoParagCounterWidget * m_counterWidget; 00513 KoParagTabulatorsWidget * m_tabulatorsWidget; 00514 00515 int m_flags; 00516 KoParagLayout oldLayout; 00517 }; 00518 00519 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:04:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003