kword

KWViewMode.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001-2005 David Faure <faure@kde.org>
3 Copyright (C) 2005 Thomas Zander <zander@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "KWViewMode.h"
22#include "KWCanvas.h"
23#include "KWView.h"
24#include "KWDocument.h"
25#include "KWTextFrameSet.h"
26#include "KWFrameSet.h"
27#include "KWTableFrameSet.h"
28#include "KWPageManager.h"
29#include "KWPage.h"
30#include "KWFrameViewManager.h"
31#include "KWFrameView.h"
32#include <tqapplication.h>
33#include <kdebug.h>
34
35const unsigned short KWViewMode::s_shadowOffset = 3;
36
38{
39 KWFrame* frame = textfs->frameIterator().getLast();
40 return m_doc->zoomSize( KoSize( frame->innerWidth(), frame->internalY() + frame->innerHeight() ) );
41
42}
43
44void KWViewMode::drawOnePageBorder( TQPainter * painter, const TQRect & crect, const TQRect & _pageRect,
45 const TQRegion & emptySpaceRegion )
46{
47 if ( !crect.intersects( _pageRect ) )
48 return;
49
50 TQRect pageRect( _pageRect );
51 //kdDebug() << "KWViewMode::drawOnePageBorder drawing page rect " << pageRect << endl;
52 painter->drawRect( pageRect );
53 // Exclude page border line, to get the page contents rect (avoids flicker)
54 pageRect.rLeft() += 1;
55 pageRect.rTop() += 1;
56 pageRect.rRight() -= 1;
57 pageRect.rBottom() -= 1;
58 // The empty space to clear up inside this page
59 TQRect pagecrect = pageRect.intersect( crect );
60 if ( !pagecrect.isEmpty() )
61 {
62 //kdDebug() << "KWViewMode::drawOnePageBorder : pagecrect=" << pagecrect << " emptySpaceRegion: " << emptySpaceRegion << endl;
63 TQRegion pageEmptyRegion = emptySpaceRegion.intersect( pagecrect );
64 //kdDebug() << "RESULT: pageEmptyRegion: " << pageEmptyRegion << endl;
65 if ( !pageEmptyRegion.isEmpty() )
66 m_doc->eraseEmptySpace( painter, pageEmptyRegion, TQApplication::palette().active().brush( TQColorGroup::Base ) );
67 }
68}
69
70TQRect KWViewMode::drawRightShadow( TQPainter * painter, const TQRect & crect, const TQRect & pageRect, int topOffset )
71{
72 TQRect shadowRect( pageRect.right() + 1, pageRect.top() + topOffset, s_shadowOffset, pageRect.height() - topOffset );
73 shadowRect &= crect; // intersect
74 if ( !shadowRect.isEmpty() )
75 {
76 painter->fillRect( shadowRect,
77 TQApplication::palette().active().brush( TQColorGroup::Shadow ) );
78 }
79 return shadowRect;
80}
81
82TQRect KWViewMode::drawBottomShadow( TQPainter * painter, const TQRect & crect, const TQRect & pageRect, int leftOffset )
83{
84 TQRect shadowRect( pageRect.left() + leftOffset, pageRect.bottom() + 1, pageRect.width(), s_shadowOffset );
85 shadowRect &= crect; // intersect
86 if ( !shadowRect.isEmpty() )
87 painter->fillRect( shadowRect,
88 TQApplication::palette().active().brush( TQColorGroup::Shadow ) );
89 return shadowRect;
90}
91
93{
94 // Same code as KWView::slotUpdateRuler
95 KWFrame * frame = 0L;
96 // Use the currently edited (fallback: the first selected) frame
97 if( m_canvas->currentFrameSetEdit() && m_canvas->currentFrameSetEdit()->currentFrame() )
98 frame = m_canvas->currentFrameSetEdit()->currentFrame();
99 else {
100 KWFrameView *view = m_canvas->frameViewManager()->selectedFrame();
101 frame = view == 0 ? 0 : view->frame();
102 }
103
104 int pageNum = 0;
105 if ( frame )
106 pageNum = frame->pageNumber();
107 TQPoint nPoint( 0, m_doc->pageTop(pageNum) + 1 );
108 TQPoint cPoint( normalToView( nPoint ) );
109 /*kdDebug() << "KWViewMode::pageCorner frame=" << frame << " pagenum=" << pageNum
110 << " nPoint=" << nPoint.x() << "," << nPoint.y()
111 << " cPoint=" << cPoint.x() << "," << cPoint.y() << endl;*/
112 return cPoint;
113}
114
116{
117 // Set the "frame start" in the ruler (tabs are relative to that position)
118 KWFrameSetEdit * edit = m_canvas->currentFrameSetEdit();
119 KWFrame * frame = 0L;
120 // Use the currently edited (fallback: the first selected) frame
121 if ( edit && edit->currentFrame() )
122 frame = edit->currentFrame();
123 else {
124 KWFrameView *view = m_canvas->frameViewManager()->selectedFrame();
125 frame = view == 0 ? 0 : view->frame();
126 }
127 if( !frame) {
128 KWFrameSet *fs= m_doc->frameSet(0);
129 if(fs) frame=fs->frame(0);
130 }
131 if ( frame )
132 {
133 TQRect r = normalToView( m_doc->zoomRect( frame->innerRect() ) );
134
135 // Calculate page corner (see pageCorner above)
136 int pageNum = frame->pageNumber();
137 TQPoint nPoint( 0, m_doc->pageTop(pageNum) + 1 );
138 TQPoint cPoint( normalToView( nPoint ) );
139
140 // Frame start/end is relative to page corner.
141 r.moveBy( -cPoint.x(), -cPoint.y() );
142 return r;
143 }
144 return TQRect();
145}
146
147void KWViewMode::setPageLayout( KoRuler* hRuler, KoRuler* vRuler, const KoPageLayout& layout )
148{
149 hRuler->setPageLayout( layout );
150 vRuler->setPageLayout( layout );
151}
152
153// static
154KWViewMode * KWViewMode::create( const TQString & viewModeType, KWDocument *doc, KWCanvas* canvas )
155{
156 Q_ASSERT(doc);
157 if(viewModeType=="ModeNormal")
158 {
159 return new KWViewModeNormal( doc, canvas, doc->viewFrameBorders() );
160 }
161 else if(viewModeType=="ModeEmbedded")
162 {
163 return new KWViewModeEmbedded( doc, canvas );
164 }
165 else if(viewModeType=="ModePreview")
166 {
167 return new KWViewModePreview( doc, canvas, doc->viewFrameBorders(), doc->nbPagePerRow() );
168 }
169 else if(viewModeType=="ModeText")
170 {
171 KWTextFrameSet* fs = KWViewModeText::determineTextFrameSet( doc ); // could be 0
172 return new KWViewModeText( doc, canvas, fs );
173 }
174 else
175 {
176 kdDebug() << viewModeType << " mode type is unknown\n";
177 return 0;
178 }
179}
180
182
184{
185 return TQSize( m_doc->paperWidth(m_doc->startPage()),
186 m_doc->zoomItY( m_doc->pageManager()->bottomOfPage(m_doc->lastPage()) ) );
187}
188
190{
191 KWPage* page = m_doc->pageManager()->page( pgNum );
192 TQRect r = page->zoomedRect( m_doc );
193 r.moveBy( xOffset( page ), 0 );
194 return r;
195}
196
197TQPoint KWViewModeNormal::normalToView( const TQPoint & nPoint )
198{
199 double unzoomedY = m_doc->unzoomItY( nPoint.y() );
200 KWPage *page = m_doc->pageManager()->page(unzoomedY); // quotient
201 if( !page) {
202 kdWarning(31001) << "KWViewModeNormal::normalToView request for conversion out of the document! Check your input data.. ("<< nPoint << ")" << endl;
203 return TQPoint(0,0);
204 }
205 Q_ASSERT(canvas());
206 return TQPoint( xOffset(page) + nPoint.x(), nPoint.y() );
207}
208
209TQPoint KWViewModeNormal::viewToNormal( const TQPoint & vPoint )
210{
211 // Opposite of the above
212 // The Y is unchanged by the centering so we can use it to get the page.
213 double unzoomedY = m_doc->unzoomItY( vPoint.y() );
214 KWPage *page = m_doc->pageManager()->page(unzoomedY); // quotient
215 if( !page) {
216 kdWarning(31001) << "KWViewModeNormal::normalToView request for conversion out of the document! Check your input data.. ("<< vPoint << ")" << endl;
217 return TQPoint(-1,-1); // yes this is an ugly way to mark this as an excetional state...
218 }
219 Q_ASSERT(canvas());
220 return TQPoint( vPoint.x() - xOffset(page), vPoint.y() );
221}
222
223int KWViewModeNormal::xOffset(KWPage *page, int canvasWidth /* = -1 */) {
224 // Center horizontally
225 if(canvasWidth < 0)
226 canvasWidth = canvas()->visibleWidth();
227 return kMax( 0, ( canvasWidth - m_doc->zoomItX( page->width() ) ) / 2 );
228}
229
230void KWViewModeNormal::drawPageBorders( TQPainter * painter, const TQRect & crect, const TQRegion & emptySpaceRegion )
231{
232 painter->save();
233 painter->setPen( TQApplication::palette().active().color( TQColorGroup::Dark ) );
234 painter->setBrush( TQt::NoBrush );
235 TQRect pageRect;
236
237 int lastPage = m_doc->lastPage();
238 Q_ASSERT(canvas());
239 const int canvasWidth = canvas()->visibleWidth();
240 double pagePosPt = 0;
241 int topOfPage = 0; // in pixels
242 for ( int pageNr = m_doc->startPage(); pageNr <= lastPage; pageNr++ )
243 {
244 KWPage *page = m_doc->pageManager()->page(pageNr);
245
246 int pageWidth = m_doc->zoomItX( page->width() );
247 int pageHeight = m_doc->zoomItY( pagePosPt + page->height() ) - topOfPage;
248 if ( crect.bottom() < topOfPage )
249 break;
250 // Center horizontally
251 int x = xOffset(page, canvasWidth);
252 // Draw page border (and erase empty area inside page)
253 pageRect = TQRect( x, topOfPage, pageWidth, pageHeight );
254 drawOnePageBorder( painter, crect, pageRect, emptySpaceRegion );
255
256 // The area on the left of the page
257 TQRect leftArea( 0, topOfPage, x, pageHeight );
258 leftArea &= crect;
259 if ( !leftArea.isEmpty() ) {
260 painter->fillRect( leftArea,
261 TQApplication::palette().active().brush( TQColorGroup::Mid ) );
262 }
263
264 // The area on the right of the page
265 TQRect rightArea( x + pageWidth, topOfPage, crect.right() - pageWidth + 1, pageHeight );
266 rightArea &= crect;
267 if ( !rightArea.isEmpty() )
268 {
269 painter->fillRect( rightArea,
270 TQApplication::palette().active().brush( TQColorGroup::Mid ) );
271
272 // Draw a shadow
273 int topOffset = ( page==0 ) ? s_shadowOffset : 0; // leave a few pixels on top, only for first page
274 drawRightShadow( painter, crect, pageRect, topOffset );
275 }
276 pagePosPt += page->height(); // for next page already..
277 topOfPage += pageHeight;
278 }
279 // Take care of the area at the bottom of the last page
280 if ( crect.bottom() > topOfPage )
281 {
282 TQRect bottomArea( 0, topOfPage, crect.right() + 1, crect.bottom() - topOfPage + 1 );
283 TQRect repaintRect = bottomArea.intersect( crect );
284 if ( !repaintRect.isEmpty() )
285 {
286 painter->fillRect( repaintRect,
287 TQApplication::palette().active().brush( TQColorGroup::Mid ) );
288 // Draw a shadow
289 drawBottomShadow( painter, crect, pageRect, s_shadowOffset );
290 }
291 }
292 painter->restore();
293}
294
296
298{
299 // Only one page makes sense in embedded mode though
300 return m_doc->pageManager()->page( pgNum )->zoomedRect( m_doc );
301}
302
304
305KWViewModePreview::KWViewModePreview( KWDocument * doc, KWCanvas* canvas,
306 bool drawFrameBorders, int _nbPagePerRow )
307 : KWViewMode( doc, canvas, drawFrameBorders ),
308 m_pagesPerRow(_nbPagePerRow),
309 m_spacing(10)
310{}
311
313{
314 if ( canvas() )
315 {
316 int pagesPerRow;
317 if ( m_doc->pageCount() < m_pagesPerRow )
318 pagesPerRow = m_doc->pageCount();
319 else
320 pagesPerRow = m_pagesPerRow;
321
322 int pagesWidth = ( m_spacing + ( m_doc->paperWidth(m_doc->startPage()) + m_spacing ) * pagesPerRow );
323 if ( pagesWidth < canvas()->visibleWidth() )
324 return ( m_spacing + ( canvas()->visibleWidth() / 2 ) - ( pagesWidth / 2 ) );
325 }
326 return m_spacing;
327}
328
330{
331 if ( canvas() )
332 {
333 int pagesHeight = ( m_spacing + ( m_doc->paperHeight(m_doc->startPage()) + m_spacing ) * numRows() );
334 if ( pagesHeight < canvas()->visibleHeight() )
335 return ( m_spacing + ( canvas()->visibleHeight() / 2 ) - ( pagesHeight / 2 ) );
336 }
337 return m_spacing;
338}
339
340int KWViewModePreview::numRows() const
341{
342 return ( m_doc->pageCount() ) / m_pagesPerRow + 1;
343}
344
346{
347 int pages = m_doc->pageCount();
348 int rows = (pages-1) / m_pagesPerRow + 1;
349 int hPages = rows > 1 ? m_pagesPerRow : pages;
350 return TQSize( m_spacing + hPages * ( m_doc->paperWidth(m_doc->startPage()) + m_spacing ),
351 m_spacing + rows * ( m_doc->paperHeight(m_doc->startPage()) + m_spacing ) /* bottom of last row */ );
352}
353
354TQPoint KWViewModePreview::normalToView( const TQPoint & nPoint )
355{
356 // Can't use nPoint.y() / m_doc->paperHeight() since this would be a rounding problem
357 double unzoomedY = m_doc->unzoomItY( nPoint.y() );
358 KWPage *page = m_doc->pageManager()->page(unzoomedY); // quotient
359 if( !page) {
360 kdWarning(31001) << "KWViewModePreview::normalToView request for conversion out of the document! Check your input data.. ("<< nPoint << ")" << endl;
361 return TQPoint(0,0);
362 }
363
364 double yInPagePt = unzoomedY - page->offsetInDocument();// and rest
365 int row = (page->pageNumber() - m_doc->startPage()) / m_pagesPerRow;
366 int col = (page->pageNumber() - m_doc->startPage()) % m_pagesPerRow;
367 /*kdDebug() << "KWViewModePreview::normalToView nPoint=" << nPoint
368 << " unzoomedY=" << unzoomedY
369 << " page=" << page->pageNumber() << " row=" << row << " col=" << col
370 << " yInPagePt=" << yInPagePt << endl;*/
371 return TQPoint( leftSpacing() + col * ( m_doc->paperWidth(page->pageNumber()) +
372 m_spacing ) + nPoint.x(),
373 topSpacing() + row * ( m_doc->paperHeight(page->pageNumber()) +
374 m_spacing ) + m_doc->zoomItY( yInPagePt ) );
375}
376
378{
379 int row = (pgNum - m_doc->startPage()) / m_pagesPerRow;
380 int col = (pgNum - m_doc->startPage()) % m_pagesPerRow;
381 const int paperWidth = m_doc->paperWidth( pgNum );
382 const int paperHeight = m_doc->paperHeight( pgNum );
383 return TQRect( leftSpacing() + col * ( paperWidth + m_spacing ),
384 topSpacing() + row * ( paperHeight + m_spacing ),
385 paperWidth,
386 paperHeight );
387}
388
389TQPoint KWViewModePreview::viewToNormal( const TQPoint & vPoint )
390{
391 // Well, just the opposite of the above.... hmm.... headache....
392 int paperWidth = m_doc->paperWidth(m_doc->startPage());
393 int paperHeight = m_doc->paperHeight(m_doc->startPage());
394 TQPoint p( vPoint.x() - leftSpacing(), vPoint.y() - topSpacing() );
395 int col = static_cast<int>( p.x() / ( paperWidth + m_spacing ) );
396 int xInPage = p.x() - col * ( paperWidth + m_spacing );
397 int row = static_cast<int>( p.y() / ( paperHeight + m_spacing ) );
398 int yInPage = p.y() - row * ( paperHeight + m_spacing );
399 int page = row * m_pagesPerRow + col + m_doc->startPage();
400 if ( page > m_doc->lastPage() ) // [this happens when moving frames around and going out of the pages]
401 return TQPoint( paperWidth, m_doc->pageTop( m_doc->lastPage() ) );
402 else // normal case
403 return TQPoint( xInPage, yInPage + m_doc->pageTop( page ) );
404}
405
406void KWViewModePreview::drawPageBorders( TQPainter * painter, const TQRect & crect, const TQRegion & emptySpaceRegion )
407{
408 painter->save();
409 painter->setPen( TQApplication::palette().active().color( TQColorGroup::Dark ) );
410 painter->setBrush( TQt::NoBrush );
411 //kdDebug() << "KWViewModePreview::drawPageBorders crect=" << DEBUGRECT( crect ) << endl;
412 TQRegion grayRegion( crect );
413 int pageCount = m_doc->pageCount();
414 for ( int counter = 0; counter < pageCount; counter++ )
415 {
416 int row = counter / m_pagesPerRow;
417 int col = counter % m_pagesPerRow;
418 int page = m_doc->startPage() + counter;
419 int paperWidth = m_doc->paperWidth(page);
420 int paperHeight = m_doc->paperHeight(page);
421 TQRect pageRect( leftSpacing() + col * ( paperWidth + m_spacing ),
422 topSpacing() + row * ( paperHeight + m_spacing ),
423 paperWidth, paperHeight );
424 drawOnePageBorder( painter, crect, pageRect, emptySpaceRegion );
425 if( pageRect.top() > crect.bottom())
426 break;
427 if ( pageRect.intersects( crect ) )
428 grayRegion -= pageRect;
429 TQRect rightShadow = drawRightShadow( painter, crect, pageRect, s_shadowOffset );
430 if ( !rightShadow.isEmpty() )
431 grayRegion -= rightShadow;
432 TQRect bottomShadow = drawBottomShadow( painter, crect, pageRect, s_shadowOffset );
433 if ( !bottomShadow.isEmpty() )
434 grayRegion -= bottomShadow;
435
436 //kdDebug() << "KWViewModePreview::drawPageBorders grayRegion is now : " << endl;
437 //DEBUGREGION( grayRegion );
438 }
439 if ( !grayRegion.isEmpty() )
440 {
441 //kdDebug() << "KWViewModePreview::drawPageBorders grayRegion's bounding Rect = " << DEBUGRECT( grayRegion.boundingRect() ) << endl;
442 m_doc->eraseEmptySpace( painter, grayRegion, TQApplication::palette().active().brush( TQColorGroup::Mid ) );
443 }
444 painter->restore();
445}
446
448
449KWViewModeText::KWViewModeText( KWDocument * doc, KWCanvas* canvas, KWTextFrameSet* fs )
450 : KWViewMode( doc, canvas, false )
451{
452 m_textFrameSet = fs;
453}
454
455KWTextFrameSet * KWViewModeText::textFrameSet() const
456{
457 if ( !m_textFrameSet ) // e.g. when we set this mode before we had any frames (doc not loaded yet)
458 m_textFrameSet = determineTextFrameSet( m_doc );
459 return m_textFrameSet;
460}
461
463{
464 KWTextFrameSet* fs = 0L;
465
466 if(!doc->getAllViews().empty()) { // try the one that is selected
467 KWView *view = doc->getAllViews()[0];
468 KWFrameView *fv = view->getGUI()->canvasWidget()->frameViewManager()->selectedFrame();
469 KWFrame *f = fv == 0 ? 0 : fv->frame();
470 if(f)
471 fs = dynamic_cast<KWTextFrameSet *>( f->frameSet() );
472
473 if (!fs) { // try the one I am editing
474 KWFrameSetEdit *fse = view->getGUI()->canvasWidget()->currentFrameSetEdit();
475 if(fse)
476 fs = dynamic_cast<KWTextFrameSet *>( fse->frameSet() );
477 }
478 }
479
480 if (!fs || fs->isHeaderOrFooter() || fs->isFootEndNote())
481 // if not a textFS, or header/footer/footnote: fallback to fs 0
482 if ( doc->frameSetCount() > 0 && doc->frameSet( 0 )->isVisible() )
483 fs = dynamic_cast<KWTextFrameSet *>( doc->frameSet( 0 ) );
484
485 return fs;
486}
487
488TQPoint KWViewModeText::normalToView( const TQPoint & nPoint )
489{
490 TQPoint r (nPoint);
491 r.setX(r.x() + OFFSET);
492 return r;
493}
494
495TQPoint KWViewModeText::viewToNormal( const TQPoint & vPoint )
496{
497 TQPoint r (vPoint);
498 r.setX(r.x() - OFFSET);
499 return r;
500}
501
503{
504 if (!textFrameSet())
505 return TQSize();
506
507 // The actual contents only depend on the amount of text.
508 // The width is the one from the text, so that the placement of tabs makes a bit of sense, etc.
509 // The minimum height is the one of a normal page though.
510
511 int width = m_doc->layoutUnitToPixelX( m_textFrameSet->textDocument()->width() );
512
513 int height = TQMAX((int)m_doc->paperHeight(m_doc->startPage()),
514 m_doc->layoutUnitToPixelY( m_textFrameSet->textDocument()->height() ) );
515 //kdDebug() << "KWViewModeText::contentsSize " << width << "x" << height << endl;
516 return TQSize( width, height );
517}
518
520{
521 return contentsSize();
522}
523
525{
526 if(fs==NULL) return false; // assertion
527 if(fs==textFrameSet()) return true;
528
529 const KWFrameSet* parentFrameset = fs->groupmanager() ? fs->groupmanager() : fs;
530 while ( parentFrameset->isFloating() ) {
531 parentFrameset = parentFrameset->anchorFrameset();
532 if ( parentFrameset == m_textFrameSet )
533 return true;
534 }
535 return false;
536}
537
538void KWViewModeText::drawPageBorders( TQPainter * painter, const TQRect & crect,
539 const TQRegion & /*emptySpaceRegion*/ )
540{
541 painter->save();
542 TQRegion grayRegion( crect );
543 //kdDebug() << "KWViewModeText::drawPageBorders crect=" << grayRegion << endl;
544 painter->setPen( TQApplication::palette().active().color( TQColorGroup::Dark ) );
545 TQSize cSize = contentsSize();
546 // Draw a line on the right -- ## or a shadow?
547 // +1 to be out of the contents, and +1 for TQRect
548 TQRect frameRect( OFFSET, 0, cSize.width() + 2, cSize.height() );
549 //kdDebug() << "KWViewModeText::drawPageBorders right line: " << frameRect.topRight() << " " << frameRect.bottomRight()<< endl;
550 painter->drawLine( frameRect.topRight(), frameRect.bottomRight() );
551 if ( frameRect.intersects( crect ) )
552 grayRegion -= frameRect;
553
554 //kdDebug() << "KWViewModeText::drawPageBorders grayRegion is now " << grayRegion << endl;
555 if ( crect.bottom() >= cSize.height() )
556 {
557 // And draw a line at the bottom -- ## or a shadow?
558 painter->drawLine( 0, cSize.height(),
559 cSize.width(), cSize.height() );
560 grayRegion -= TQRect( 0, cSize.height(),
561 cSize.width(), cSize.height() );
562 }
563 //kdDebug() << "KWViewModeText::drawPageBorders erasing grayRegion " << grayRegion << endl;
564 if ( !grayRegion.isEmpty() )
565 m_doc->eraseEmptySpace( painter, grayRegion, TQApplication::palette().active().brush( TQColorGroup::Mid ) );
566 painter->restore();
567}
568
570{
571 return TQRect( TQPoint(OFFSET, 0), contentsSize() );
572}
573
574void KWViewModeText::setPageLayout( KoRuler* hRuler, KoRuler* vRuler, const KoPageLayout& /*layout*/ )
575{
576 // Create a dummy page-layout, as if we had a single page englobing the whole text.
577 KoPageLayout layout;
578 layout.format = PG_CUSTOM;
579 layout.orientation = PG_PORTRAIT;
580 TQSize cSize = contentsSize();
581 layout.ptWidth = m_doc->unzoomItX( cSize.width() );
582 layout.ptHeight = m_doc->unzoomItY( cSize.height() );
583 //kdDebug() << "KWViewModeText::setPageLayout layout size " << layout.ptWidth << "x" << layout.ptHeight << endl;
584 layout.ptLeft = OFFSET;
585 layout.ptRight = 0;
586 layout.ptTop = 0;
587 layout.ptBottom = 0;
588 layout.ptBindingSide = 0;
589 layout.ptPageEdge = 0;
590 hRuler->setPageLayout( layout );
591 vRuler->setPageLayout( layout );
592}
593
595 return fs == textFrameSet();
596}
597
598
599int KWViewModePrint::xOffset(KWPage *page, int canvasWidth) {
600 Q_UNUSED(page);
601 Q_UNUSED(canvasWidth);
602 return 0;
603}
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
Definition KWCanvas.h:61
This object is created to edit a particular frameset in a particular view The view's canvas creates i...
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
Definition KWFrameSet.h:62
const TQPtrList< KWFrame > & frameIterator() const
Iterator over the child frames.
Definition KWFrameSet.h:159
bool isFloating() const
Return true if this frameset is floating (inline), false if it's fixed.
Definition KWFrameSet.h:372
KWTableFrameSet * groupmanager() const
returns the groupManager this frameset belongs to.
Definition KWFrameSet.h:408
KWTextFrameSet * anchorFrameset() const
Return the frameset in which our anchor is - assuming isFloating()
Definition KWFrameSet.h:374
KWFrame * frame(unsigned int _num) const
get a frame by number
KWFrameView * selectedFrame() const
Returns the first selected frame.
an instance of a KWFrameView represents the view in the MVC model of a frame; there can be multiple K...
Definition KWFrameView.h:82
KWFrame * frame() const
returns the frame this frameView represents
This class represents a single frame.
Definition KWFrame.h:68
KWFrameSet * frameSet() const
Data stucture methods.
Definition KWFrame.h:143
int pageNumber() const
The page on which this frame is.
Definition KWFrame.cpp:116
This class represents a printed page of the document.
Definition KWPage.h:30
double height() const
return the height of this page (in pt)
Definition KWPage.cpp:44
int pageNumber() const
returns the number of this page as it will be shown to the user.
Definition KWPage.h:102
double width() const
return the width of this page (in pt)
Definition KWPage.cpp:38
double offsetInDocument() const
All Pages are in a document-wide coordinate system that simply puts every page under the next page an...
Definition KWPage.cpp:128
TQRect zoomedRect(KoZoomHandler *zoomHandler)
return a TQRect with the size of this page in pixels.
Definition KWPage.cpp:132
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
The 'embedded' view mode (usually a single page, no selections)
Definition KWViewMode.h:189
virtual TQRect viewPageRect(int pgNum)
Return view coord for page rect.
The 'normal' view mode (pages below one another)
Definition KWViewMode.h:156
virtual TQPoint viewToNormal(const TQPoint &vPoint)
View coord -> normal coord.
virtual TQSize contentsSize()
Size of the contents area, in pixels.
virtual TQRect viewPageRect(int pgNum)
Return view coord for page rect.
virtual TQPoint normalToView(const TQPoint &nPoint)
Normal coord -> view coord.
A mode for previewing the overall document Pages are organized in a grid (mostly useful when zooming ...
Definition KWViewMode.h:223
int leftSpacing()
Return the spacing between the left border of the canvas and the page.
virtual TQRect viewPageRect(int pgNum)
Return view coord for page rect.
int topSpacing()
Return the spacing between the top border of the canvas and the page.
virtual TQPoint normalToView(const TQPoint &nPoint)
Normal coord -> view coord.
virtual TQPoint viewToNormal(const TQPoint &vPoint)
View coord -> normal coord.
virtual TQSize contentsSize()
Size of the contents area, in pixels.
The 'edit only one text frameset' view mode.
Definition KWViewMode.h:253
virtual TQSize contentsSize()
Size of the contents area, in pixels.
virtual TQRect rulerFrameRect()
The result of this is passed to setFrameStartEnd for both rulers (after adjustement with pageCorner()...
static KWTextFrameSet * determineTextFrameSet(KWDocument *doc)
Return a text frameset that the user has either selected or is currently editing, returning the main ...
virtual bool isFrameSetVisible(const KWFrameSet *fs)
Should this frameset be visible in this viewmode? True by default, all are shown.
virtual void setPageLayout(KoRuler *hRuler, KoRuler *vRuler, const KoPageLayout &layout)
Called when the page layout is set, or changes.
virtual TQPoint viewToNormal(const TQPoint &vPoint)
View coord -> normal coord.
virtual TQPoint normalToView(const TQPoint &nPoint)
Normal coord -> view coord.
static const int OFFSET
hardcoded distance from the left side this viewmode starts its rendering
Definition KWViewMode.h:290
virtual TQSize availableSizeForText(KWTextFrameSet *textfs)
Size (in pixels) of the total area available for text in a given textframeset This is used by KWTextF...
virtual bool isTextModeFrameset(KWFrameSet *fs) const
Answers the question if argument frameset has to be drawn as a text-mode text area if true,...
Abstract base class for KWCanvas's view modes.
Definition KWViewMode.h:48
virtual void setPageLayout(KoRuler *hRuler, KoRuler *vRuler, const KoPageLayout &layout)
Called when the page layout is set, or changes.
virtual TQRect rulerFrameRect()
The result of this is passed to setFrameStartEnd for both rulers (after adjustement with pageCorner()...
virtual TQPoint pageCorner()
"Topleft of current page" - concept used by the rulers.
virtual TQSize availableSizeForText(KWTextFrameSet *textfs)
Size (in pixels) of the total area available for text in a given textframeset This is used by KWTextF...
virtual TQPoint normalToView(const TQPoint &nPoint)=0
Normal coord -> view coord.
void drawOnePageBorder(TQPainter *painter, const TQRect &crect, const TQRect &pageRect, const TQRegion &emptySpaceRegion)
Draw the border around one page, and clear up the empty space in that page.