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
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
00068
KoParagLayoutWidget(
int flag,
QWidget * parent,
const char * name = 0 )
00069 :
QWidget( parent, name ), m_flag( flag )
00070 {
00071 }
00072
virtual ~
KoParagLayoutWidget() {}
00073
00074
00075
virtual void display(
const KoParagLayout & lay ) = 0;
00076
00077
00078
00079
virtual void save(
KoParagLayout & lay ) = 0;
00080
00081
00082
00083
00084
00086
virtual QString tabName() = 0;
00087
00088
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
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
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
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
00196
00197
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
00300
virtual QString tabName();
00301
00302
const KoParagCounter & counter()
const {
return m_counter; }
00303
00304
protected slots:
00305
00306
00307
void numTypeChanged(
int );
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
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
00469
int align()
const {
return m_alignWidget->
align(); }
00470
00471
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
00478
const KoParagCounter & counter()
const {
return m_counterWidget->
counter(); }
00479
00480
00481
KoTabulatorList tabListTabulator()
const {
return m_tabulatorsWidget->
tabList(); }
00482
KoParagTabulatorsWidget * tabulatorsWidget()
const {
return m_tabulatorsWidget; }
00483
00484
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