KWQPainter.h 6.53 KB
Newer Older
gramps's avatar
gramps committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright (C) 2001 Apple Computer, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
gramps's avatar
gramps committed
24
 */
gramps's avatar
gramps committed
25 26 27 28

#ifndef QPAINTER_H_
#define QPAINTER_H_

29 30 31 32
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

33 34 35 36 37 38 39 40 41 42
#include <qnamespace.h>
#include <qpaintdevice.h>
#include <qcolor.h>
#include <qpen.h>
#include <qbrush.h>
#include <qrect.h>
#include <qregion.h>
#include <qpoint.h>
#include <qstring.h>
#include <qfontmetrics.h>
43 44 45

class QFont;
class QPixmap;
rjw's avatar
rjw committed
46
class QWidget;
47

48 49
// class QWMatrix ==============================================================

gramps's avatar
gramps committed
50
class QWMatrix {
rjw's avatar
rjw committed
51
friend QPainter;
gramps's avatar
gramps committed
52
public:
53 54 55 56 57 58 59 60 61 62

    // typedefs ----------------------------------------------------------------
    // enums -------------------------------------------------------------------
    // constants ---------------------------------------------------------------
    // static member functions -------------------------------------------------
    
    // constructors, copy constructors, and destructors ------------------------
    
    QWMatrix();
    
63 64 65 66
// add no-op destructor
#ifdef _KWQ_PEDANTIC_
    ~QWMatrix() {}
#endif
67 68 69

    // member functions --------------------------------------------------------

gramps's avatar
gramps committed
70
    QWMatrix &scale(double, double);
71 72 73 74 75 76

    // operators ---------------------------------------------------------------

// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------

77 78 79 80 81 82 83 84
private:

// add copy constructor
// this private declaration prevents copying
#ifdef _KWQ_PEDANTIC_
    QWMatrix(const QWMatrix &);
#endif

rjw's avatar
rjw committed
85 86 87 88
#ifdef _KWQ_
    bool empty;
    double sx;
    double sy;
89 90
#endif

91 92 93 94
}; // class QWMatrix ===========================================================


// class QPainter ==============================================================
gramps's avatar
gramps committed
95

96
class QPainter : public Qt {
97
public:
98 99 100 101 102 103 104 105

    // typedefs ----------------------------------------------------------------
    // enums -------------------------------------------------------------------
    // constants ---------------------------------------------------------------
    // static member functions -------------------------------------------------

    // constructors, copy constructors, and destructors ------------------------

106
    QPainter();
rjw's avatar
rjw committed
107 108
    
    // We may be able to remove this constructor and remove QPaintDevice.
109
    QPainter(const QPaintDevice *);
rjw's avatar
rjw committed
110 111 112 113 114
    
#ifdef _KWQ_
    QPainter(QWidget *);
#endif

115 116 117 118
    ~QPainter();
    
    // member functions --------------------------------------------------------

119
    const QFont &font() const;
120 121
    void setFont(const QFont &);
    QFontMetrics fontMetrics() const;
122 123
    const QPen &pen() const;
    void setPen(const QPen &);
124
    void setPen(PenStyle);
125
    void setBrush(const QBrush &);
126
    void setBrush(BrushStyle);
127

128 129
    QRect xForm(const QRect &) const;

130 131 132
    void save();
    void restore();
    
gramps's avatar
gramps committed
133
    void drawRect(int, int, int, int);
134
    void drawLine(int, int, int, int);
135 136
    void drawEllipse(int, int, int, int);
    void drawArc(int, int, int, int, int, int);
137 138 139
    void drawPolyline(const QPointArray &, int index=0, int npoints=-1);
    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0,
        int npoints=-1);
gramps's avatar
gramps committed
140 141
    void drawPixmap(const QPoint &, const QPixmap &);
    void drawPixmap(const QPoint &, const QPixmap &, const QRect &);
rjw's avatar
rjw committed
142 143 144
    void drawPixmap( int x, int y, const QPixmap &,
			    int sx=0, int sy=0, int sw=-1, int sh=-1 );
    void drawTiledPixmap(int, int, int, int, const QPixmap &, int sx=0, int sy=0);
145 146 147 148
    void drawText(int x, int y, const QString &, int len=-1);
    void drawText(int, int, int, int, int flags, const QString&, int len=-1, 
        QRect *br=0, char **internal=0);
    void fillRect(int, int, int, int, const QBrush &);
149

150 151
    void setClipping(bool);
    void setClipRegion(const QRegion &);
152 153
    void setClipRect(const QRect &);
    void setClipRect(int,int,int,int);
154 155
    const QRegion &clipRegion() const;
    bool hasClipping() const;
156 157
    RasterOp rasterOp() const;
    void setRasterOp(RasterOp);
158

159 160 161 162 163 164 165 166
    void translate(double dx, double dy);
    void scale(double dx, double dy);

    bool begin(const QPaintDevice *);
    bool end();

    QPaintDevice *device() const;

167 168 169 170 171 172 173 174
    // operators ---------------------------------------------------------------

// protected -------------------------------------------------------------------

// private ---------------------------------------------------------------------

private:
    // no copying or assignment
175
    // note that these are "standard" (no pendantic stuff needed)
176 177 178
    QPainter(const QPainter &);
    QPainter &operator=(const QPainter &);

rjw's avatar
rjw committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
#ifdef _KWQ_
    void _lockFocus();
    void _unlockFocus();

    void _setColorFromBrush();
    void _setColorFromPen();

    void _initialize(QWidget *widget);
    void _drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill);

    struct KWQPainterData {	// QPainter data.
        QWidget *widget;	// Has a reference to a KWQView.
	QFont qfont;
	QBrush qbrush;
	QPen qpen;
	uint isFocusLocked:1;
        void *ps_stack;
rjw's avatar
rjw committed
196
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
rjw's avatar
rjw committed
197
        NSCompositingOperation compositingOperation;
rjw's avatar
rjw committed
198 199 200
#else
        uint compositingOperation;
#endif
rjw's avatar
rjw committed
201 202
    } *data;
#endif
203 204 205
}; // end class QPainter

// =============================================================================
206

gramps's avatar
gramps committed
207
#endif