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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <[email protected]>
Copyright (C) 2002-2005 Thorsten Zachmann <[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 __KPRCANVAS__
#define __KPRCANVAS__
#include <tqwidget.h>
#include <tqptrlist.h>
#include <tqpicture.h>
#include <tqvaluelist.h>
#include <tqpixmap.h>
#include <tqpointarray.h>
#include <tqvaluevector.h>
#include <tqtimer.h>
#include <KoGuides.h>
#include <KoRuler.h>
#include <KoQueryTrader.h>
#include "KoPointArray.h"
#include "global.h"
#include <KoRect.h>
#include <KoTextFormat.h>
#include "presstep.h"
class KURL;
class KoTextFormatInterface;
class KPrView;
class KPrDocument;
class TQPainter;
class KTextEdit;
class KPrTextObject;
class KPrObject;
class TDEPopupMenu;
class TQResizeEvent;
class TQPaintEvent;
class TQDragEnterEvent;
class TQDragMoveEvent;
class TQDropEvent;
class TQFocusEvent;
class TQMouseEvent;
class TQWheelEvent;
class TQKeyEvent;
class KPrPixmapObject;
class KPrBackGround;
class TQRect;
class TQSize;
class TQPoint;
class KPrSoundPlayer;
class KoTextObject;
class KoParagCounter;
class KPrPage;
class KPrinter;
class KPrTextView;
class KPrPartObject;
class KCommand;
class KPrEffectHandler;
class KPrPageEffects;
/**
* Class KPCanvas - There is a single instance of this class for a given view.
*
* It manages the graphical representation of all the objects.
*/
class KPrCanvas : public TQWidget
{
TQ_OBJECT
public:
/// constructor
KPrCanvas( TQWidget *parent=0,const char *name=0,KPrView *_view=0 );
/// destructor
~KPrCanvas();
KPrView * getView()const { return m_view; }
// The equivalent of contentsX() and contentsY() for a TQScrollView
// The Canvas is a widget, not a scrollview (because we handle the scrollbars ourselves,
// to have the "goto page" buttons at the bottom of the scrollbars etc.)
int diffx() const { return m_xOffset; }
int diffy() const { return m_yOffset; }
void setDiffX( int _diffX ) { m_xOffset = _diffX; }
void setDiffY( int _diffY ) { m_yOffset = _diffY; }
void scrollX( int x );
void scrollY( int y );
// public functions
void selectAllObj();
void deSelectAllObj();
void selectObj( KPrObject* );
void deSelectObj( KPrObject* );
void setTextFormat(const KoTextFormat &format, int flags);
void setTextColor( const TQColor & );
void setTextBackgroundColor( const TQColor & );
void setTextAlign( int );
void setTextDepthPlus();
void setTextDepthMinus();
void setNewRightIndent(double _rightIndent);
void setNewLeftIndent(double _leftIndent);
void setNewFirstIndent(double _firstIndent);
//void setTextCounter(KoParagCounter counter);
void setTabList( const KoTabulatorList & tabList );
void setTextBold( bool b );
void setTextItalic( bool b );
void setTextUnderline( bool b );
void setTextStrikeOut( bool b );
void setTextFamily( const TQString &f );
void setTextPointSize( int s );
void setTextSubScript( bool b );
void setTextSuperScript( bool b );
void setTextDefaultFormat( );
void setIncreaseFontSize();
void setDecreaseFontSize();
KPrTextObject* kpTxtObj() const;
/**
* Start a screen presentation
* All pages if @p curPgNum is -1, otherwise just @p curPgNum (1-based)
*/
void startScreenPresentation( double zoomX, double zoomY, int curPgNum = -1);
void stopScreenPresentation();
/**
* Go to the next step in the presentation.
* gotoNextPage: if is set to true go to beginning of the
* next page.
*/
bool pNext( bool gotoNextPage = false );
/**
* Go to previous step of the presentation.
* gotoPreviousPage: if is set to true go to beginning of the
* previous page.
*/
bool pPrev( bool gotoPreviousPage = false );
/// returns the current page of the presentation 1 based
unsigned int presPage() const { return m_step.m_pageNumber + 1; }
/// returns the current step of the presentation
int presStep() const { return m_step.m_step; }
int numPresSteps() const { return m_pageEffectSteps.count(); }
int numPresPages() const { return m_presentationSlides.count(); }
bool canAssignEffect( TQPtrList<KPrObject> &objs ) const;
void print( TQPainter*, KPrinter*, float, float );
void setPartEntry( KoDocumentEntry& _e )
{ partEntry = _e; }
void setToolEditMode( ToolEditMode _m, bool updateView = true );
void setAutoForm( const TQString &_autoform )
{ autoform = _autoform; }
/**
\brief Draw page into TQPixmap.
Draws page pgnum of the currently open presentation into a TQPixmap
using the specified zoom factor (or fixed width/height dimensions, resp.)
Set forceWidth and/or forceHeight to override the zoom factor
and obtain a pixmap of the specified width and/or height.
By omitting one of them you make sure that the aspect ratio
of your page is used for the resulting image.
\sa exportPage
*/
void drawPageInPix( TQPixmap&, int pgnum, int zoom,
bool forceRealVariableValue = false,
int forceWidth = 0,
int forceHeight = 0 );
/**
\brief Save page to bitmap file.
Export a page of the currently open presentation to disk
using a bitmap format like e.g. PNG.
This method uses a TQPixmap::save() call.
\param nPage the internally used <b>0-based</b> page number
\param nWidth the desired image width in px
\param nHeight the desired image height in px
\param fileURL the URL of the image file to be created: if this
does not point to a local file a KTempFile is created by TQPixmap::save()
which is then copied over to the desired location.
\param format the format of the image file (see TQPixmap::save())
\param quality the quality of the image (see TQPixmap::save())
example:
\verbatim
exportPage( 0, s, 800, 600, "/home/khz/page0.png", "PNG", 100 );
\endverbatim
\returns True if the file was written successfully.
\sa drawPageInPix, KPrViewIface::exportPage
*/
bool exportPage( int nPage, int nWidth, int nHeight,
const KURL& fileURL,
const char* format,
int quality = -1 );
void gotoPage( int pg );
/**
* Go to first slide of presentation.
* Used in presentation mode.
*/
void presGotoFirstPage();
KPrPage* activePage() const;
bool oneObjectTextExist() const;
bool oneObjectTextSelected() const;
bool isOneObjectSelected() const;
/** Returns the list of selected text objects */
TQPtrList<KPrTextObject> selectedTextObjs() const;
/**
* Returns the list of interfaces to use for changing the text format.
* This can be either the currently edited text object,
* or the list of text objects currently selected
*/
TQPtrList<KoTextFormatInterface> applicableTextInterfaces() const;
/**
* Returns the list of text objects, either selected or activated.
*/
TQPtrList<KPrTextObject> applicableTextObjects() const;
void setMouseSelectedObject(bool b);
bool haveASelectedPartObj() const;
bool haveASelectedGroupObj() const;
bool haveASelectedPixmapObj() const;
KPrTextView *currentTextObjectView() const { return m_currentTextObjectView; }
TQPtrList<KPrObject> objectList() const;
// get - set data
const TQPtrList<KPrObject> & getObjectList() const;
void playSound( const TQString &soundFileName );
void stopSound();
///for KPrTextView
void dragStarted() { mousePressed = false; }
void setXimPosition( int x, int y, int w, int h, TQFont *f );
void createEditing( KPrTextObject *textObj );
/**
* @brief Add a line
*
* @param startPoint the start point of the line
* @param endPoint the end point of the line
*/
void insertLine( const KoPoint &startPoint, const KoPoint &endPoint );
/**
* @brief Add a rectangle
*
* @param rect the size and position of the rectangle
*/
void insertRect( const KoRect &rect);
/**
* @brief Add a ellipse
*
* @param rect the size and position of the ellipse
*/
void insertEllipse( const KoRect &rect );
/**
* @brief Add a pie/arc/chord
*
* @param rect the size and position of the pie/arc/chord
*/
void insertPie( const KoRect &rect );
/**
* @brief Add a text object
*
* @param rect the size and position of the text object
*/
KPrTextObject* insertTextObject( const KoRect &rect );
/**
* @brief Add a picture
*
* @param rect the size and position of the picture
*/
void insertPicture( const KoRect &rect );
void changePicture( const KURL & url, TQWidget *window );
int numberOfObjectSelected() const;
KPrObject *getSelectedObj() const;
KPrPixmapObject *getSelectedImage() const;
bool getEditMode() const { return editMode; }
void ungroupObjects();
void groupObjects();
unsigned int objNums() const;
void ensureVisible( int x, int y, int xmargin, int ymargin );
/**
* @brief get the rect for the objects
*
* @param all true if the rect for all objects shoud be returned
* false if only the rect for selected objects sould be returned
*
* @return rect of the objects
*/
KoRect objectRect( bool all ) const;
void scrollTopLeftPoint( const TQPoint & pos );
void textContentsToHeight();
void textObjectToContents();
void flipObject( bool _horizontal );
void lowerObjs( bool backward );
void raiseObjs( bool forward );
/**
* @brief Align objects
*
* This will align all selected non protected objects according to the
* align type at.
*
* @param at the align type
*/
void alignObjects( AlignType at );
bool canMoveOneObject()const;
TQPtrList<KPrTextObject> listOfTextObjs() const;
TQPixmap getPicturePixmap() const;
void closeObject(bool _close);
void layout();
void alignVertical(VerticalAlignmentType _type );
void savePicture();
void dropImage( TQMimeSource * data, bool resizeImageToOriginalSize = false , int posX = 10, int posY=10 );
KoGuides & guideLines() { return m_gl; }
/**
* @brief Open the object popup
*
* @param object the selected object
* @param point where the popup should be displayed
*/
void objectPopup( KPrObject *object, const TQPoint &point );
public slots:
// use repaint = false when the KPrCanvas is destroyed to avaid a possible crash
void exitEditMode( bool repaint = true );
void clipCut();
void clipCopy();
void clipPaste();
void deleteObjs();
void copyObjs();
void copyOasisObjs();
void chPic();
void picViewOriginalSize();
void picViewOrig640x480();
void picViewOrig800x600();
void picViewOrig1024x768();
void picViewOrig1280x1024();
void picViewOrig1600x1200();
void picViewOrigFactor();
void setActivePage( KPrPage* active );
/**
* @brief Set the guide move state
*
* @param state true set guide move state
* false unset guide move state
*/
void setPaintGuides( bool state );
signals:
// signals to notify of changes
void fontChanged( const TQFont & );
void colorChanged( const TQColor & );
void alignChanged( int );
/**
* Emmitted when presentation should be restarted
* This is used in automatic screen and infinite loop mode.
*/
void stopAutomaticPresentation();
/**
* Emmitted when presentation should be restarted
* This is used in automatic screen and infinite loop mode.
*/
void restartPresentation();
void objectSelectedChanged();
void objectSizeChanged();
/// Emitted when the current frameset edit changes
void currentObjectEditChanged();
void selectionChanged( bool hasSelection );
void sigMouseWheelEvent( TQWheelEvent * );
protected:
struct PicCache
{
TQPicture pic;
int num;
int subPresStep;
};
// functions for displaying
/**
* This method is used for repainting the canvas.
*/
virtual void paintEvent( TQPaintEvent* );
/**
* Draws the background of page to painter.
* Set edit to true if in edit mode, false in presentation mode.
*/
void drawBackground( TQPainter* painter, const TQRect& rect, KPrPage * page, bool edit = false ) const;
/**
* Draw obj to painter.
*/
void drawAllObjectsInPage( TQPainter *painter, const TQPtrList<KPrObject> & obj, int pageNum ) const;
/**
* Draw _objects shown at step to painter.
* This method is used for presentation mode, printing.
*/
void drawObjectsPres( TQPainter *painter, const TQPtrList<KPrObject> &_objects, PresStep step ) const;
/**
* Draw _objects to painter.
* Only rect is painted.
* This method is used for edit mode.
*/
void drawObjectsEdit( TQPainter *painter, const KoRect &rect, const TQPtrList<KPrObject> &_objects,
SelectionMode selectionMode, int page ) const;
/**
* Draw _objects to painter.
* contour if true only countor of selected objects is drawn
* selectionMode selected objects use this selection mode
* textView if set print editable textobject (used by drawObjectsEdit)
* This method is used by drawObjectsPres and drawObjectsEdit.
*/
void drawObjects( TQPainter *painter, const TQPtrList<KPrObject> &objects, SelectionMode selectionMode,
bool contour, KPrTextView * textView, int pageNum ) const;
/**
* Draw _objects of page to painter.
* This method is used for edit mode.
*/
void drawEditPage( TQPainter *painter, const TQRect &_rect,
KPrPage *page, SelectionMode selectionMode ) const;
/**
* Draw _objects of page shown at step to painter.
* This method is used for presentation mode, printing.
*/
void drawPresPage( TQPainter *painter, const TQRect &_rect, PresStep step ) const;
/// draw grid
void drawGrid(TQPainter *painter, const TQRect &rect2) const;
/**
* Finish the object effects.
* This shown the last step of the effect. It stops the effect timer and
* disconnect it and the effect handler deleted.
*/
bool finishObjectEffects();
bool finishPageEffect( bool cancel = false );
void drawCurrentPageInPix( TQPixmap& ) const;
virtual void mousePressEvent( TQMouseEvent *e );
virtual void mouseReleaseEvent( TQMouseEvent *e );
virtual void mouseMoveEvent( TQMouseEvent *e );
virtual void mouseDoubleClickEvent( TQMouseEvent *e );
virtual void wheelEvent( TQWheelEvent *e );
virtual void resizeEvent( TQResizeEvent *e );
virtual bool close( bool alsoDelete );
/**
* Returns the object at position pos
* @param pos the position in the document on which to look
* @param withoutProtected if set to true only unprotecred objects are returned
* @return the object at position pos
*/
KPrObject *getObjectAt( const KoPoint &pos, bool withoutProtected = false );
virtual void focusInEvent( TQFocusEvent* ) {}
virtual void focusOutEvent( TQFocusEvent* ) {}
virtual void enterEvent( TQEvent *e );
virtual void leaveEvent( TQEvent *e );
virtual void dragEnterEvent( TQDragEnterEvent *e );
virtual void dragMoveEvent( TQDragMoveEvent *e );
virtual void dropEvent( TQDropEvent *e );
virtual void keyPressEvent( TQKeyEvent *e );
virtual void keyReleaseEvent( TQKeyEvent *e );
virtual void imStartEvent( TQIMEvent * e );
virtual void imComposeEvent( TQIMEvent * e );
virtual void imEndEvent( TQIMEvent * e );
void eraseEmptySpace( TQPainter * painter, const TQRegion & emptySpaceRegion, const TQBrush & brush ) const;
/// setup popupmenus
void setupMenus();
unsigned int currPgNum() const;
TQColor txtBackCol() const;
bool spInfiniteLoop() const;
bool spShowEndOfPresentationSlide() const;
bool spManualSwitch() const;
TQRect getPageRect( bool decBorders = true ) const;
unsigned int pageNums() const;
void _repaint( bool erase=true );
void _repaint( const TQRect &r );
void _repaint( KPrObject *o );
/**
* Draw page defined in step to painter.
* This method is used for printing a presentation.
*/
void printPage( TQPainter*, PresStep step, KPrinter *printer, int rows, int cols );
/**
* This method animates the objects in the presentation.
*/
void doObjEffects( bool isAllreadyPainted = false );
/**
* @brief Add a object
*
* @param rect the size and position of the object
*/
KPrPartObject *insertObject( const KoRect &rect );
/**
* @brief Add a autoform object
*
* @param rect the size and position of the autoform object
*/
void insertAutoform( const KoRect &rect );
void insertFreehand( const KoPointArray &_pointArray );
void insertPolyline( const KoPointArray &_pointArray );
void insertCubicBezierCurve( const KoPointArray &_pointArray );
void insertPolygon( const KoPointArray &_pointArray );
void insertClosedLine( const KoPointArray &_pointArray );
void selectNext();
void selectPrev();
void scalePixmapToBeOrigIn( const KoSize ¤tSize, const KoSize &pgSize,
const TQSize &presSize, KPrPixmapObject *obj );
bool getPixmapOrigAndCurrentSize( KPrPixmapObject *&obj, KoSize *origSize, KoSize *currentSize );
void setTextBackground( KPrTextObject *obj );
virtual bool eventFilter( TQObject *o, TQEvent *e );
virtual bool focusNextPrevChild( bool );
void endDrawPolyline();
/**
* @brief Draw a cubic bezier curve.
*/
void drawCubicBezierCurve( TQPainter &p, KoPointArray &points );
//void drawCubicBezierCurve( int _dx, int _dy );
void endDrawCubicBezierCurve();
/**
* @brief Redraw the curve defined in m_pointArray
*
* @param p painter used for drawing
*/
void redrawCubicBezierCurve( TQPainter &p );
#ifndef NDEBUG
void printRTDebug( int info );
#endif
KoRect getAlignBoundingRect() const;
private:
void picViewOrigHelper(int x, int y);
/**
* @brief Move object by key
*
* @param x The distance to move the objects in x direction
* @param y The distance to move the objects in y direction
*/
void moveObjectsByKey( int x, int y );
/**
* @brief Move object by mouse
*
* @param pos The position of the mouse
* @param keepXorYunchanged if true keep x or y position unchanged
*/
void moveObjectsByMouse( KoPoint &pos, bool keepXorYunchanged );
//---- stuff needed for resizing ----
/// resize the m_resizeObject
void resizeObject( ModifyType _modType, const KoPoint & point, bool keepRatio, bool scaleAroundCenter );
/// create KPrResizeCmd
void finishResizeObject( const TQString &name, bool layout = true );
/**
* @brief Display object above the other objects in editiong mode
*
* This is used to bring a single slected object to front, so it is easier
* to modify.
*
* @param object which should be displayed above the other objects
*/
void raiseObject( KPrObject *object );
/**
* @brief Don't display an object above the others
*/
void lowerObject();
/**
* @brief Get the list of objects in the order they should be displayed.
*
* This takes into acount the object set in raiseObject so that it is
* the last one in the list returned (the one that is displayed above all
* the others).
*
* @return List of objects
*/
const TQPtrList<KPrObject> displayObjectList() const;
/**
* This is used in automatic presentation mode.
* If it is set to true and we are in automatic presentation
* mode the timer of the page will be activated after the last
* effect has been shown.
*/
bool m_setPageTimer;
/// Helper function to draw a polygon
void drawPolygon( TQPainter &p, const KoRect &rect );
/// Helper function to draw a pie/arc/chord
void drawPieObject( TQPainter *p, const KoRect &rect );
TQPoint limitOfPoint(const TQPoint& _point) const;
/**
* Return true if object is a header/footer which is hidden.
*/
bool objectIsAHeaderFooterHidden(KPrObject *obj) const;
KPrTextObject* textUnderMouse( const TQPoint & point );
bool checkCurrentTextEdit( KPrTextObject * textObj );
/**
* @brief Snap @p pos to grid and guide lines.
*
* This method looks if the @p pos has to be snapped to a guide or grid or both.
* If so it returns the position it has snapped to.
*
* @param pos the point which should be snapped
* @param repaintSnapping true if the guides should be repainted.
* @param repaintSnapping false when the guides should not be repainted.
* You have to call repaint by yourself.
*
* @return the position of the snapped point
*/
KoPoint snapPoint( KoPoint &pos, bool repaintSnapping = true );
/**
* @brief Find the next grid in distance
*
* Allways the top left corner is snapped to the grid.
*
* @param rect The rect which should be snapped to the grid.
* @param diffx The range in x distance in which the grid has to be.
* @param diffy The range in y distance in which the grid has to be.
*
* @return the distance to the guide or ( 0, 0 ) if there is no guide to snap to.
*/
KoPoint diffGrid( KoRect &rect, double diffx, double diffy );
void recalcAutoGuides( );
/**
* @brief Calculate the points in distance to the top left corner
*
* @param pointArray the points in coordinate position
*/
KoPointArray getObjectPoints( const KoPointArray &pointArray );
/**
* @brief Update m_insertRect
*
* This will set the bottom right corner of the insert rect to
* the given point. If the AltButton is pressed the insert rect
* is moved with its bottom right to the given point.
*
* @param point the bottom right point of the inserted object
* @param The state of the mouse and modifier buttons
*
*/
void updateInsertRect( const KoPoint &point, TQt::ButtonState state );
/**
* @brief Popup context menu
*
* Popup context menu for current active or selected object,
* otherwise popup context menu for page.
*/
void popupContextMenu();
private slots:
void toFontChanged( const TQFont &font ) { emit fontChanged( font ); }
void toColorChanged( const TQColor &color ) { emit colorChanged( color ); }
void toAlignChanged( int a ) { emit alignChanged( a ); }
/**
* Switch to drawing mode. In drawing mode it is possible to draw on the
* current slide.
* Only to be used in presentation mode.
*/
void setDrawingMode();
/**
* Set switching mode. This ends drawing mode and goes back to
* stepping between the pages.
* If continueTimer is true the autoPres timer is continued
* Only to be used in presentation mode.
*/
void setSwitchingMode( bool continueTimer = true );
void slotGotoPage();
void slotExitPres();
void terminateEditing( KPrTextObject * );
/**
* Do the next step of the object effect.
* This restarts the effect tmer. If the effects are
* completed the timer is disconnected and the effect handler
* deleted.
*/
void slotDoEffect();
void slotDoPageEffect();
/**
* Scroll canvas when receiving this signal
*/
void slotAutoScroll(const TQPoint &scrollDist);
/**
* Speak the text object under the mouse. This slot is normally
* connected to the kospeaker customSpeakWidget signal.
*/
void speakTextUnderMouse(TQWidget* w, const TQPoint& p, uint flags);
private:
/// Distance for snapping to guide line with mouse
static const int MOUSE_SNAP_DISTANCE;
/// Distance for snapping to guide line with key
static const int KEY_SNAP_DISTANCE;
// variables
/// Popup menu used in presentation mode.
TDEPopupMenu *m_presMenu;
bool showingLastSlide;
bool mousePressed;
bool drawContour;
ModifyType modType;
/// text or part object when it is edited
KPrObject * m_editObject;
bool fillBlack;
KPrView *m_view;
bool editMode, goingBack;
/**
* True when we are in drawing mode.
* False when we are in switching mode.
*/
bool m_drawMode;
/**
* True if the a line should be drawn.
* Used in drawing mode.
*/
bool m_drawLineInDrawMode;
/**
* Save the lines drawed in drawMode.
* This is used for paint events.
* Used in drawing mode.
*/
TQValueVector<TQPointArray> m_drawModeLines;
/**
* Index into the TQPointArray for the next point of the line in draw mode.
* Used in drawing mode.
*/
int m_drawModeLineIndex;
bool mouseSelectedObject;
/// information about current step of the presentation
PresStep m_step;
float _presFakt;
int m_showOnlyPage; // 1-based (-1 = all)
/// list of all effect steps occuring on the active page
TQValueList<int> m_pageEffectSteps;
/// List of the slides used in the presentation
TQValueList<int> m_presentationSlides;
/// Iterator over the slides of a presentation
TQValueList<int>::Iterator m_presentationSlidesIterator;
/// KPrEffectHandler for object effects
KPrEffectHandler *m_effectHandler;
KPrPageEffects *m_pageEffect;
/// EffectTimer
TQTimer m_effectTimer;
TQTimer m_pageEffectTimer;
/// menu identifier for draw mode
int PM_DM;
int delPageId;
bool drawRubber;
/// rect for drawing rubber
KoRect m_rubber;
//---- stuff needed for resizing ----
/// object which gets resized
KPrObject *m_resizeObject;
/// size of the object at when resizing is started
KoRect m_rectBeforeResize;
/// ratio of the object ( width / height )
double m_ratio;
bool m_isResizing;
//---- stuff needed for moving ----
bool m_isMoving;
KoPoint m_moveStartPoint;
//---- stuff needed for rotating ----
/// object which gets rotated
KPrObject *m_rotateObject;
/// center of the rotated object
KoPoint m_rotateCenter;
/// start point for rotation
KoPoint m_rotateStart;
/// angle of the object at start of rotate
double m_angleBeforeRotate;
ToolEditMode toolEditMode;
/// The rect of the object during insert.
KoRect m_insertRect;
KoDocumentEntry partEntry;
TQString autoform;
TQPixmap buffer;
KPrTextView *m_currentTextObjectView;
KPrSoundPlayer *soundPlayer;
KoPointArray m_pointArray, m_oldCubicBezierPointArray;
TQPoint m_dragStartPoint, m_dragEndPoint, m_dragSymmetricEndPoint;
/// The start position of an insert for line objects
KoPoint m_startPoint;
/// The end position of an insert for line objects
KoPoint m_endPoint;
KoPoint m_symmetricEndPoint;
KoPoint m_CubicBezierSecondPoint, m_CubicBezierThirdPoint;
int m_indexPointArray;
bool m_drawPolyline;
bool m_drawCubicBezierCurve;
bool m_drawLineWithCubicBezierCurve;
bool m_zoomRubberDraw;
KPrPage *m_activePage;
int m_xOffset, m_yOffset;
int m_xOffsetSaved, m_yOffsetSaved; // saved when going fullscreen
/// Start position for move with mouse
KoPoint m_moveStartPosMouse;
/// This holds the distance it an object was snapped to a guide
KoPoint m_moveSnapDiff;
/// Set to true if snapping should be disabled (by pressing shift during move)
bool m_disableSnapping;
/// The last position of the mouse during moving
KoPoint m_origMousePos;
/// start position for move with key
KoPoint m_moveStartPosKey;
KPrPage * m_activePageBeforePresentation;
int m_zoomBeforePresentation;
bool m_keyPressEvent;
bool m_drawSymetricObject;
/// guides
KoGuides m_gl;
/// true if we are in guide move state, false otherwise
bool m_paintGuides;
/// object which is selected and should be shown above all the other objects
KPrObject * m_objectDisplayAbove;
/// Previously spoken text object.
KPrTextObject *m_prevSpokenTO;
};
#endif // __KPRCANVAS__
|