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

« back to all changes in this revision

Viewing changes to kxstitch/paletteview.h

  • 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
#ifndef PALETTEVIEW_H
 
12
#define PALETTEVIEW_H
 
13
 
 
14
#include <qframe.h>
 
15
#include <qtooltip.h>
 
16
#include <qvaluevector.h>
 
17
 
 
18
class KAction;
 
19
class KPrinter;
 
20
class KXStitchDoc;
 
21
 
 
22
/** Display the colors from the patterns floss list.
 
23
    @author Stephen Allewell
 
24
  */
 
25
class PaletteView : public QFrame, public QToolTip
 
26
{
 
27
  Q_OBJECT
 
28
public:
 
29
/** Constructor
 
30
    @param doc A pointer to the document object.
 
31
    @param parent A pointer to the parent widget.
 
32
  */
 
33
  PaletteView(KXStitchDoc* doc,QWidget *parent);
 
34
/** Destructor
 
35
  */
 
36
  virtual ~PaletteView();
 
37
 
 
38
/** Print the floss palette to a printer
 
39
    @return The number of pages printed so far
 
40
    @param printer Pointer to the KPrinter object being printed to
 
41
    @param painter Pointer to the QPainter object that is to be drawn on
 
42
    @param width Width of the page (from the device metrics)
 
43
    @param height Height of the page (from the device metrics)
 
44
    @param page The number of pages printed so far
 
45
  */
 
46
  int print(KPrinter *printer, QPainter *painter, int width, int height, int page);
 
47
/** Set the current color to the color index specified.
 
48
    @param i Index into the document color palette.
 
49
  */
 
50
  void setCurrentColor(int);
 
51
/** Reconfigure the view in response to the users configuration
 
52
  */
 
53
  void configure();
 
54
 
 
55
protected:
 
56
/** Reimplemented from the base class.
 
57
    Draw the palette.
 
58
    @param p Pointer to the QPainter to use.
 
59
  */
 
60
  virtual void drawContents(QPainter *p);
 
61
/** Reimplemented from the base class.
 
62
    Display the context menu for the paletteView
 
63
    @param e QContextMouseEvent describing the mouse action
 
64
  */
 
65
  virtual void contextMenuEvent(QContextMenuEvent* e);
 
66
/** Reimplemented from the base class.
 
67
    Check if the left mouse button was pressed on a displayed color, and if so,
 
68
    set the current color.
 
69
    @param e QMouseEvent describing the mouse action.
 
70
  */
 
71
  virtual void mousePressEvent(QMouseEvent *e);
 
72
/** Reimplemented from the base class.
 
73
    Checks if the mouse is over a displayed color, and if so, display a tooltip
 
74
    describing details about the color.
 
75
    @param p QPoint defining the position of the mouse.
 
76
  */
 
77
  virtual void maybeTip(const QPoint &p);
 
78
 
 
79
private slots:
 
80
/** Save the palette to a scheme
 
81
  */
 
82
  void slotSavePalette();
 
83
/** Load a scheme to the palette
 
84
  */
 
85
  void slotLoadPalette();
 
86
/** Create a new palette
 
87
  */
 
88
  void slotCreatePalette();
 
89
/** Toggle the show symbols flag and repaint the view.
 
90
  */
 
91
  void slotShowSymbols();
 
92
/** Set the flag to indicate that a color swap is to be done. Will change the cursor
 
93
    to indicate that color swap is in progress.
 
94
  */
 
95
  void slotPrepareToSwap();
 
96
/** Set the flag to indicate that a color replace is to be done. Will change the cursor
 
97
    to indicate that color replace is in progress.
 
98
  */
 
99
  void slotPrepareToReplace();
 
100
/** Add colour to palette
 
101
  */
 
102
  void slotAddColor();
 
103
/** remove colors from the palette
 
104
  */
 
105
  void slotRemoveColors();
 
106
/** clear the unused colors from the palette
 
107
  */
 
108
  void slotClearUnused();
 
109
 
 
110
private:
 
111
  KAction*          m_savePalette;
 
112
  KAction*          m_loadPalette;
 
113
  KAction*          m_createPalette;
 
114
  KXStitchDoc*      m_doc;
 
115
  bool              m_waitingToSwap;
 
116
  bool              m_waitingToReplace;
 
117
  int               m_rows;
 
118
  int               m_cols;
 
119
  int               m_cellWidth;
 
120
  int               m_cellHeight;
 
121
  bool              m_symbols;
 
122
  QValueVector<int> m_flosses;
 
123
};
 
124
 
 
125
#endif