1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <[email protected]>
Copyright (C) 2005 Martin Ellis <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef paragdia_h
#define paragdia_h
#include <kdialogbase.h>
#include <tqstringlist.h>
#include <tqptrlist.h>
#include <tqstylesheet.h>
#include <KoRuler.h>
#include <KoUnit.h>
#include <KoUnitWidgets.h>
#include <tqdict.h>
#include <tqlineedit.h>
#include "KoParagLayout.h"
#include "KoParagCounter.h"
#include <knuminput.h>
#include <tqgroupbox.h>
#include <tqvgroupbox.h>
#include <koffice_export.h>
class KoTextZoomHandler;
class KButtonBox;
class KPushButton;
class KColorButton;
class KoTextDocument;
class KoBorderPreview;
class KoStylePreview;
class KPagePreview2;
class KPagePreview;
class KoSpinBox;
class TQButtonGroup;
class TQCheckBox;
class TQComboBox;
class TQGridLayout;
class TQGroupBox;
class TQLabel;
class TQListBox;
class TQPushButton;
class TQRadioButton;
class TQWidget;
class TQWidgetStack;
class KIntNumInput;
class KDoubleNumInput;
class KComboBox;
class TQVBoxLayout;
class KoUnitDoubleSpinBox;
class KoParagDecorationTab; // From KoParagDecorationTab.ui
/**
* This is the base class for any widget [usually used in a tab]
* that handles modifying a part of a KoParagLayout.
* Used by the paragraph dialog (this file) and by the style editor.
*/
class KOTEXT_EXPORT KoParagLayoutWidget : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
// Constructor: parent widget, flag (PD_SOMETHING) and name
KoParagLayoutWidget( int flag, TQWidget * parent, const char * name = 0 )
: TQWidget( parent, name ), m_flag( flag )
{
}
virtual ~KoParagLayoutWidget() {}
// Display settings, from the paragLayout
virtual void display( const KoParagLayout & lay ) = 0;
// Save the settings, into the paragLayout
// This is only used by the stylist, not by paragdia (which needs undo/redo, applying partially etc.)
virtual void save( KoParagLayout & lay ) = 0;
// Return true if the settings where modified
// ## maybe too global, but how to do it differently? We'll see if we need this.
//virtual bool isModified() = 0;
/** return the (i18n-ed) name of the tab */
virtual TQString tabName() = 0;
// Return the part of the paraglayout that this widget cares about
int flag() const { return m_flag; }
private:
int m_flag;
};
/**
* The widget for editing idents and spacings (tab 1)
*/
class KOTEXT_EXPORT KoIndentSpacingWidget : public KoParagLayoutWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoIndentSpacingWidget( KoUnit::Unit unit, double _frameWidth, TQWidget * parent,const char * name = 0 );
virtual ~KoIndentSpacingWidget() {}
virtual void display( const KoParagLayout & lay );
virtual void save( KoParagLayout & lay );
//virtual bool isModified();
virtual TQString tabName();
double leftIndent() const;
double rightIndent() const;
double firstLineIndent() const;
double spaceBeforeParag() const;
double spaceAfterParag() const;
double lineSpacing() const;
KoParagLayout::SpacingType lineSpacingType() const;
private slots:
void leftChanged( double );
void rightChanged( double );
void firstChanged( double );
void spacingActivated( int );
void spacingChanged( double );
void spacingChanged( int );
void beforeChanged( double );
void afterChanged( double );
private:
void updateLineSpacing( KoParagLayout::SpacingType _type );
TQWidgetStack *sSpacingStack;
KIntNumInput *eSpacingPercent;
KoUnitDoubleSpinBox *eBefore, *eAfter, *eSpacing;
KoUnitDoubleSpinBox *eLeft, *eRight, *eFirstLine;
TQComboBox *cSpacing;
KPagePreview *prev1;
KoUnit::Unit m_unit;
};
/**
* The widget for editing paragraph alignment (tab 2)
*/
class KOTEXT_EXPORT KoParagAlignWidget : public KoParagLayoutWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoParagAlignWidget(bool breakLine, TQWidget * parent, const char * name = 0 );
virtual ~KoParagAlignWidget() {}
virtual void display( const KoParagLayout & lay );
virtual void save( KoParagLayout & lay );
//virtual bool isModified();
virtual TQString tabName();
int pageBreaking() const;
int align() const;
protected slots:
void alignLeft();
void alignCenter();
void alignRight();
void alignJustify();
protected:
void clearAligns();
private:
TQRadioButton *rLeft, *rCenter, *rRight, *rJustify;
TQCheckBox *cKeepLinesTogether, *cHardBreakBefore, *cHardBreakAfter;
KPagePreview2 *prev2;
};
/**
* The widget for editing paragraph borders (tab 3)
*/
class KOTEXT_EXPORT KoParagDecorationWidget : public KoParagLayoutWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoParagDecorationWidget( TQWidget * parent, const char * name = 0 );
virtual ~KoParagDecorationWidget() {}
virtual void display( const KoParagLayout & lay );
virtual void save( KoParagLayout & lay );
//virtual bool isModified();
virtual TQString tabName();
// Borders
KoBorder leftBorder() const { return m_leftBorder; }
KoBorder rightBorder() const { return m_rightBorder; }
KoBorder topBorder() const { return m_topBorder; }
KoBorder bottomBorder() const { return m_bottomBorder; }
bool joinBorder() const { return m_joinBorder; }
// Background color
TQColor backgroundColor() const;
protected slots:
void brdLeftToggled( bool );
void brdRightToggled( bool );
void brdTopToggled( bool );
void brdBottomToggled( bool );
void brdJoinToggled( bool );
void slotPressEvent(TQMouseEvent *_ev);
protected:
void updateBorders();
private:
// GUI
KoBorderPreview *wPreview;
//! Widget defined in .ui file
KoParagDecorationTab *wDeco;
//! Get the currently selected border style
KoBorder::BorderStyle curBorderStyle() const;
//! Get the currently selected border width
unsigned int curBorderWidth() const;
//! Get the currently selected border color
TQColor curBorderColor() const;
// Borders
KoBorder m_leftBorder, m_rightBorder, m_topBorder, m_bottomBorder;
bool m_joinBorder;
/**
* Update a border that has been clicked in the border preview.
*
* If there is no border already at the clicked @p position, then
* create a border at that position using the selected width,color and
* style.
*
* If the clicked border is already on, and it is different to the
* selected width, color or style, then update it to match the
* current selection. If it's the same, then remove the border.
*
* Used by slotPressEvent.
* @param border the border to be updated
* @param position the position of the border to be updated
* @param corresponding the toggle button corresponding to the border
*/
void clickedBorderPreview( KoBorder& border, KoBorder::BorderType position,
KPushButton *corresponding );
//! Set a given border according to the values selected in the GUI
void updateBorder( KoBorder& border );
//! Check whether a border is the same as that selected in the GUI
bool borderChanged( const KoBorder& border );
};
class KOTEXT_EXPORT KoCounterStyleWidget : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoCounterStyleWidget( bool displayDepth= true, bool onlyStyleTypeLetter = false, bool disableAll=false, TQWidget* parent = 0, const char* name = 0 );
class StyleRepresenter {
public:
StyleRepresenter (const TQString name, KoParagCounter::Style style, bool bullet=false) {
m_name=name;
m_style=style;
m_bullet=bullet;
}
TQString name() const { return m_name; }
KoParagCounter::Style style() const { return m_style; }
bool isBullet() const { return m_bullet; }
private:
TQString m_name;
KoParagCounter::Style m_style;
bool m_bullet;
};
static void makeCounterRepresenterList( TQPtrList<StyleRepresenter>& stylesList , bool onlyStyleTypeLetter = false );
void fillStyleCombo(KoParagCounter::Numbering type = KoParagCounter::NUM_LIST);
void display( const KoParagLayout & lay );
void changeKWSpinboxType(KoParagCounter::Style st);
const KoParagCounter & counter() const { return m_counter; }
void setCounter( const KoParagCounter& counter );
public slots:
void numTypeChanged( int nType );
signals:
void sig_startChanged( int );
void sig_restartChanged(bool);
void sig_depthChanged(int);
void sig_displayLevelsChanged(int);
void sig_suffixChanged(const TQString &);
void sig_prefixChanged(const TQString &);
void sig_numTypeChanged( int );
void sig_alignmentChanged( int );
void changeCustomBullet( const TQString & , TQChar );
void changeStyle( KoParagCounter::Style );
protected slots:
void startChanged(int i) {m_counter.setStartNumber(i);emit sig_startChanged(i);}
void restartChanged(bool b) {m_counter.setRestartCounter(b);emit sig_restartChanged(b);}
void depthChanged(int i) {m_counter.setDepth(i);emit sig_depthChanged(i);}
void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i);emit sig_displayLevelsChanged(i);}
void alignmentChanged(const TQString& s);
void suffixChanged(const TQString & txt) {m_counter.setSuffix(txt);emit sig_suffixChanged(txt); }
void prefixChanged(const TQString & txt) {m_counter.setPrefix(txt);emit sig_prefixChanged(txt); }
void numStyleChanged();
void selectCustomBullet();
protected:
void displayStyle( KoParagCounter::Style style );
private:
TQGroupBox *gStyle;
TQPtrList <StyleRepresenter> stylesList;
TQListBox *lstStyle;
KoParagCounter m_counter;
TQLineEdit *sSuffix, *sPrefix;
TQPushButton *bCustom;
KoSpinBox *spnStart;
TQSpinBox *spnDepth;
TQSpinBox *spnDisplayLevels;
TQLabel *lStart;
TQLabel *lCustom;
TQCheckBox *cbRestart;
KComboBox *cbAlignment;
TQLabel *lAlignment;
unsigned int styleBuffer;
bool noSignals;
};
/**
* The widget for editing counters (bullets & numbering) (tab 4)
*/
class KOTEXT_EXPORT KoParagCounterWidget : public KoParagLayoutWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoParagCounterWidget( bool disableAll=false ,TQWidget * parent=0L, const char * name = 0 );
virtual ~KoParagCounterWidget() {}
virtual void display( const KoParagLayout & lay );
virtual void save( KoParagLayout & lay );
//virtual bool isModified();
virtual TQString tabName();
const KoParagCounter & counter() const { return m_counter; }
protected slots:
//void selectCustomBullet();
//void numStyleChanged(); // selected another style from the combobox
void numTypeChanged( int ); // selected another type radiobutton.
void suffixChanged(const TQString & txt) {m_counter.setSuffix(txt); updatePreview(); }
void prefixChanged(const TQString & txt) {m_counter.setPrefix(txt); updatePreview();}
void startChanged(int i) {m_counter.setStartNumber(i); updatePreview();}
void restartChanged(bool b) {m_counter.setRestartCounter(b); }
void depthChanged(int i) {m_counter.setDepth(i); updatePreview();}
void displayLevelsChanged(int i) {m_counter.setDisplayLevels(i); updatePreview();}
void alignmentChanged(int i) {m_counter.setAlignment(i); updatePreview();}
void slotChangeCustomBullet( const TQString & f, TQChar c);
void styleChanged (KoParagCounter::Style st );
private:
void updatePreview();
TQButtonGroup *gNumbering;
KoParagCounter m_counter;
KoStylePreview *preview;
KoCounterStyleWidget *m_styleWidget;
unsigned int styleBuffer;
bool noSignals;
};
/**
*
*/
class KoTabulatorsLineEdit : public KoUnitDoubleSpinBox
{
Q_OBJECT
TQ_OBJECT
public:
KoTabulatorsLineEdit( TQWidget *parent, double lower, double upper, double step, double value = 0.0,
KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
protected:
virtual void keyPressEvent ( TQKeyEvent * );
signals:
void keyReturnPressed();
};
/**
* The widget for editing tabulators (tab 5)
*/
class KOTEXT_EXPORT KoParagTabulatorsWidget : public KoParagLayoutWidget
{
Q_OBJECT
TQ_OBJECT
public:
KoParagTabulatorsWidget( KoUnit::Unit unit, double _frameWidth, TQWidget * parent, const char * name = 0 );
virtual ~KoParagTabulatorsWidget() {}
virtual void display( const KoParagLayout & lay );
virtual void save( KoParagLayout & lay );
virtual TQString tabName();
KoTabulatorList tabList() const { return m_tabList; }
void setCurrentTab( double tabPos );
protected slots:
void slotTabValueChanged( double );
void slotAlignCharChanged( const TQString &_text );
void newClicked();
void deleteClicked();
void deleteAllClicked();
void setActiveItem(int selected);
void updateAlign(int selected);
void updateFilling(int selected);
void updateWidth();
private:
void sortLists();
TQString tabToString(const KoTabulator &tab);
TQVBoxLayout* editLayout;
TQListBox* lstTabs;
TQGroupBox* gPosition;
KoTabulatorsLineEdit* sTabPos;
TQButtonGroup* bgAlign;
TQRadioButton* rAlignLeft;
TQRadioButton* rAlignCentre;
TQRadioButton* rAlignRight;
TQRadioButton* rAlignVar;
TQLineEdit* sAlignChar;
TQGroupBox* gTabLeader;
TQComboBox* cFilling;
KoUnitDoubleSpinBox* eWidth;
TQPushButton* bNew;
TQPushButton* bDelete;
TQPushButton* bDeleteAll;
KoTabulatorList m_tabList;
KoUnit::Unit m_unit;
double m_toplimit;
bool noSignals;
};
/**
* KoStylePreview. Previewing text with style :)
* Used in the parag bullet/number tab of the parag dia,
* and in the main tab of the stylist.
*/
class KoStylePreview : public TQGroupBox
{
Q_OBJECT
TQ_OBJECT
public:
KoStylePreview( const TQString &title, const TQString &text, TQWidget *parent, const char* name = 0 );
virtual ~KoStylePreview();
/** Apply the given @p style to the preview.
* Note that this overwrites anything done by setCounter. */
void setStyle( KoParagStyle *style );
/** Set the given @p counter to the preview. */
void setCounter( const KoParagCounter & counter );
protected:
void drawContents( TQPainter *painter );
KoTextDocument *m_textdoc;
KoTextZoomHandler *m_zoomHandler;
};
/**
* The complete(*) dialog for changing attributes of a paragraph
*
* (*) the flags (to only show parts of it) have been kept just in case
* but are not currently used.
*/
class KOTEXT_EXPORT KoParagDia : public KDialogBase
{
Q_OBJECT
TQ_OBJECT
public:
enum { PD_SPACING = 1, PD_ALIGN = 2, PD_DECORATION = 4, PD_NUMBERING = 8,
PD_TABS = 16 };
/**
* breakLine : kpresenter didn't used this attibute, kword use it.
*/
KoParagDia( TQWidget*, const char*, int flags, KoUnit::Unit unit, double _frameWidth=-1,bool breakLine=true, bool disableAll = false);
~KoParagDia();
/** Flags passed to constructor */
int getFlags()const { return m_flags; }
/** Make a given page the current one - @p page is a flag (PD_something) value */
void setCurrentPage( int page );
/** Set the values to be displayed */
void setParagLayout( const KoParagLayout & lay );
// Get values (in pt) - tab 1
double leftIndent() const { return m_indentSpacingWidget->leftIndent(); }
double rightIndent() const { return m_indentSpacingWidget->rightIndent(); }
double firstLineIndent() const { return m_indentSpacingWidget->firstLineIndent(); }
double spaceBeforeParag() const { return m_indentSpacingWidget->spaceBeforeParag(); }
double spaceAfterParag() const { return m_indentSpacingWidget->spaceAfterParag(); }
double lineSpacing() const { return m_indentSpacingWidget->lineSpacing(); }
KoParagLayout::SpacingType lineSpacingType() const{ return m_indentSpacingWidget->lineSpacingType(); }
// tab 2
int align() const { return m_alignWidget->align(); }
int pageBreaking() const { return m_alignWidget->pageBreaking(); }
// tab 3
KoBorder leftBorder() const { return m_decorationsWidget->leftBorder(); }
KoBorder rightBorder() const { return m_decorationsWidget->rightBorder(); }
KoBorder topBorder() const { return m_decorationsWidget->topBorder(); }
KoBorder bottomBorder() const { return m_decorationsWidget->bottomBorder(); }
bool joinBorder() const { return m_decorationsWidget->joinBorder(); }
// tab 4
const KoParagCounter & counter() const { return m_counterWidget->counter(); }
// tab 5
KoTabulatorList tabListTabulator() const { return m_tabulatorsWidget->tabList(); }
KoParagTabulatorsWidget * tabulatorsWidget() const { return m_tabulatorsWidget; }
TQColor backgroundColor() const { return m_decorationsWidget->backgroundColor(); }
// Support for "what has changed?"
bool isAlignChanged() const {return oldLayout.alignment!=align();}
bool isLineSpacingChanged() const {
return (oldLayout.lineSpacingValue() !=lineSpacing() ||
oldLayout.lineSpacingType != lineSpacingType());
}
bool isLeftMarginChanged() const {
return oldLayout.margins[TQStyleSheetItem::MarginLeft]!=leftIndent();
}
bool isRightMarginChanged() const {
return oldLayout.margins[TQStyleSheetItem::MarginRight]!=rightIndent();
}
bool isFirstLineChanged() const {
return oldLayout.margins[ TQStyleSheetItem::MarginFirstLine]!=firstLineIndent();
}
bool isSpaceBeforeChanged() const {
return oldLayout.margins[TQStyleSheetItem::MarginTop]!=spaceBeforeParag();
}
bool isSpaceAfterChanged() const {
return oldLayout.margins[TQStyleSheetItem::MarginBottom]!=spaceAfterParag();
}
bool isPageBreakingChanged() const {
return oldLayout.pageBreaking!=pageBreaking();
}
bool isCounterChanged() const;
bool isBorderChanged() const {
return (oldLayout.leftBorder!=leftBorder() ||
oldLayout.rightBorder!=rightBorder() ||
oldLayout.topBorder!=topBorder() ||
oldLayout.bottomBorder!=bottomBorder() );
}
bool isJoinBorderChanged() const { return oldLayout.joinBorder!=joinBorder(); }
bool listTabulatorChanged() const {return oldLayout.tabList()!=tabListTabulator();}
bool isBackgroundColorChanged() const { return oldLayout.backgroundColor != backgroundColor(); }
KoParagLayout paragLayout() const;
/// @return the set of flags which were changed
int changedFlags() const;
protected slots:
void slotReset();
virtual void slotOk();
virtual void slotApply();
signals:
void applyParagStyle();
private:
KoIndentSpacingWidget * m_indentSpacingWidget;
KoParagAlignWidget * m_alignWidget;
KoParagDecorationWidget * m_decorationsWidget;
KoParagCounterWidget * m_counterWidget;
KoParagTabulatorsWidget * m_tabulatorsWidget;
int m_flags;
KoParagLayout oldLayout;
};
#endif
|