1
/***************************************************************************
2
* Copyright (C) 2003 by Stephen Allewell *
3
* stephen@mirramar.fsnet.co.uk *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
***************************************************************************/
13
#include <qpaintdevicemetrics.h>
16
#include <kapplication.h>
18
#include "kxstitchview.h"
19
#include "kxstitchdoc.h"
22
#include "paletteview.h"
25
KXStitchView::KXStitchView(QWidget *parent, const char *name)
26
: QSplitter(parent, "ParentSplitter")
28
setBackgroundMode(PaletteBase);
29
QSplitter *child = new QSplitter(Vertical, this, "ChildSplitter");
30
m_preview = new PreView(getDocument(),child);
31
m_palette = new PaletteView(getDocument(),child);
32
m_editor = new EditView(getDocument(),this);
33
QValueList<int> initSizes;
34
KConfig *conf = kapp->config();
35
conf->setGroup("General Options");
36
initSizes = conf->readIntListEntry("ChildSplitter");
37
child->setSizes(initSizes);
38
initSizes = conf->readIntListEntry("ParentSplitter");
41
/** initialise the connections between the editor, palette and preview windows */
42
connect(m_preview, SIGNAL(clicked(QPoint)), m_editor, SLOT(slotSetCenter(QPoint)));
43
connect(m_editor, SIGNAL(changedVisibleCells(QRect)), m_preview, SLOT(setVisibleCells(QRect)));
46
KXStitchView::~KXStitchView()
50
KXStitchDoc *KXStitchView::getDocument() const
52
KXStitchApp *theApp=(KXStitchApp *) parentWidget();
53
return theApp->getDocument();
56
void KXStitchView::configure()
58
m_palette->configure();
59
m_editor->configure(false);
62
void KXStitchView::resetView()
64
m_preview->repaint(true);
65
m_palette->repaint(true);
66
m_editor->resizeGrid();
67
m_editor->repaint(true);
68
m_editor->viewport()->repaint(true);
71
void KXStitchView::print(KPrinter* printer)
73
QPainter printPainter;
74
printPainter.begin(printer);
75
QPaintDeviceMetrics printerMetrics(printer);
76
int width = printerMetrics.width();
77
int height = printerMetrics.height();
80
if (printer->option("kde-kxstitch-frontpage") == "true")
81
page = m_preview->print(printer, &printPainter, width, height, pages);
82
if (printer->option("kde-kxstitch-colorkey") == "true")
89
page = m_palette->print(printer, &printPainter, width, height, pages);
91
if (printer->option("kde-kxstitch-pattern") == "true")
98
pages = m_editor->print(printer, &printPainter, width, height, pages);