~ubuntu-branches/debian/sid/kxstitch/sid

« back to all changes in this revision

Viewing changes to kxstitch/kxstitchview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): eric pareja
  • Date: 2005-02-19 12:37:22 UTC
  • Revision ID: james.westby@ubuntu.com-20050219123722-kt3ru1nqvllietee
Tags: upstream-0.6
ImportĀ upstreamĀ versionĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2003 by Stephen Allewell                                *
 
3
 *   stephen@mirramar.fsnet.co.uk                                          *
 
4
 *                                                                         *
 
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
 ***************************************************************************/
 
10
 
 
11
#include <qpainter.h>
 
12
#include <qpoint.h>
 
13
#include <qpaintdevicemetrics.h>
 
14
#include <kprinter.h>
 
15
#include <kdebug.h>
 
16
#include <kapplication.h>
 
17
#include <kconfig.h>
 
18
#include "kxstitchview.h"
 
19
#include "kxstitchdoc.h"
 
20
#include "kxstitch.h"
 
21
#include "preview.h"
 
22
#include "paletteview.h"
 
23
#include "editview.h"
 
24
 
 
25
KXStitchView::KXStitchView(QWidget *parent, const char *name)
 
26
  : QSplitter(parent, "ParentSplitter")
 
27
{
 
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");
 
39
  setSizes(initSizes);
 
40
 
 
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)));
 
44
}
 
45
 
 
46
KXStitchView::~KXStitchView()
 
47
{
 
48
}
 
49
 
 
50
KXStitchDoc *KXStitchView::getDocument() const
 
51
{
 
52
  KXStitchApp *theApp=(KXStitchApp *) parentWidget();
 
53
  return theApp->getDocument();
 
54
}
 
55
 
 
56
void KXStitchView::configure()
 
57
{
 
58
  m_palette->configure();
 
59
  m_editor->configure(false);
 
60
}
 
61
 
 
62
void KXStitchView::resetView()
 
63
{
 
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);
 
69
}
 
70
 
 
71
void KXStitchView::print(KPrinter* printer)
 
72
{
 
73
  QPainter printPainter;
 
74
  printPainter.begin(printer);
 
75
  QPaintDeviceMetrics printerMetrics(printer);
 
76
  int width = printerMetrics.width();
 
77
  int height = printerMetrics.height();
 
78
  int pages = 0;
 
79
  int page = 0;
 
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")
 
83
  {
 
84
    if (page > pages)
 
85
    {
 
86
      printer->newPage();
 
87
      pages = page;
 
88
    }
 
89
    page = m_palette->print(printer, &printPainter, width, height, pages);
 
90
  }
 
91
  if (printer->option("kde-kxstitch-pattern") == "true")
 
92
  {
 
93
    if (page > pages)
 
94
    {
 
95
      printer->newPage();
 
96
      pages = page;
 
97
    }
 
98
    pages = m_editor->print(printer, &printPainter, width, height, pages);
 
99
  }
 
100
  printPainter.end();
 
101
}