~ubuntu-branches/ubuntu/karmic/icewm/karmic

« back to all changes in this revision

Viewing changes to src/ypaint.h

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2009-06-05 23:39:03 UTC
  • mfrom: (1.2.12 upstream) (3.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090605233903-an40kzzm9pdp0zue
Tags: 1.2.37+1.3.4pre2-2ubuntu1
* Merge from debian unstable, remaining changes:
 - debian/rules: call dh_icons

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
#include "base.h"
5
5
#include "ref.h"
 
6
#include "ypixmap.h"
 
7
#include "yimage.h"
 
8
#include "mstring.h"
 
9
#if 0
6
10
#include "ypixbuf.h"
 
11
#endif
7
12
 
8
13
#include <X11/Xlib.h>
9
14
 
36
41
#endif // CONFIG_GRADIENTS -----------------------------------------------------
37
42
 
38
43
class YWindow;
39
 
class YPixbuf;
40
44
class YIcon;
41
45
 
42
46
#ifdef SHAPE
47
51
    Up, Left, Down, Right
48
52
};
49
53
 
 
54
class YImage;
 
55
 
50
56
/******************************************************************************/
51
57
/******************************************************************************/
52
58
 
96
102
 
97
103
class YFont: public virtual refcounted {
98
104
public:
99
 
    static ref<YFont> getFont(char const *name, const char *xftFont, bool antialias = true);
 
105
    static ref<YFont> getFont(ustring name, ustring xftFont, bool antialias = true);
100
106
 
101
107
    virtual ~YFont() {}
102
108
 
104
110
    virtual int height() const { return ascent() + descent(); }
105
111
    virtual int descent() const = 0;
106
112
    virtual int ascent() const = 0;
 
113
    virtual int textWidth(const ustring &s) const = 0;
107
114
    virtual int textWidth(char const * str, int len) const = 0;
108
115
 
109
116
    virtual void drawGlyphs(class Graphics & graphics, int x, int y, 
112
119
    int textWidth(char const * str) const;
113
120
    int multilineTabPos(char const * str) const;
114
121
    YDimension multilineAlloc(char const * str) const;
115
 
 
116
 
    static char * getNameElement(char const * pattern, unsigned const element);
117
 
};
118
 
 
119
 
/******************************************************************************/
120
 
/******************************************************************************/
121
 
 
122
 
class YPixmap: public virtual refcounted {
123
 
public:
124
 
//    YPixmap(YPixmap const &pixmap);
125
 
#ifdef CONFIG_ANTIALIASING
126
 
    YPixmap(YPixbuf & pixbuf);
127
 
#endif
128
 
 
129
 
    YPixmap(char const * fileName);
130
 
#if 0
131
 
    YPixmap(char const * fileName, int w, int h);
132
 
#endif
133
 
    YPixmap(int w, int h, bool mask = false);
134
 
    YPixmap(Pixmap pixmap, Pixmap mask, int w, int h);
135
 
#ifdef CONFIG_IMLIB
136
 
    YPixmap(Pixmap pixmap, Pixmap mask, int w, int h, int wScaled, int hScaled);
137
 
    void scaleImage(Pixmap pixmap, Pixmap mask, int x, int y, int w, int h, int nw, int nh);
138
 
#endif
139
 
    ~YPixmap();
140
 
 
141
 
private:
142
 
    YPixmap(const ref<YPixmap> &pixmap, int newWidth, int newHeight);
143
 
public:
144
 
    static ref<YPixmap> scale(ref<YPixmap> source, int const width, int const height);
145
 
 
146
 
    Pixmap pixmap() const { return fPixmap; }
147
 
    Pixmap mask() const { return fMask; }
148
 
    int width() const { return fWidth; }
149
 
    int height() const { return fHeight; }
150
 
    
151
 
    bool valid() const { return (fPixmap != None); }
152
 
 
153
 
    void replicate(bool horiz, bool copyMask);
154
 
 
155
 
    static Pixmap createPixmap(int w, int h);
156
 
    static Pixmap createPixmap(int w, int h, int depth);
157
 
    static Pixmap createMask(int w, int h);
158
 
 
159
 
private:
160
 
    Pixmap fPixmap;
161
 
    Pixmap fMask;
162
 
    unsigned int fWidth, fHeight;
163
 
    bool fOwned;
164
 
};
 
122
    YDimension multilineAlloc(const ustring &str) const;
 
123
};
 
124
 
 
125
/******************************************************************************/
 
126
/******************************************************************************/
165
127
 
166
128
struct YSurface {
167
129
#ifdef CONFIG_GRADIENTS
168
130
    YSurface(class YColor * color, ref<YPixmap> pixmap,
169
 
             ref<YPixbuf> gradient):
 
131
             ref<YImage> gradient):
170
132
    color(color), pixmap(pixmap), gradient(gradient) {}
171
133
#else
172
134
    YSurface(class YColor * color, ref<YPixmap> pixmap):
176
138
    class YColor * color;
177
139
    ref<YPixmap> pixmap;
178
140
#ifdef CONFIG_GRADIENTS
179
 
    ref<YPixbuf> gradient;
 
141
    ref<YImage> gradient;
180
142
#endif
181
143
};
182
144
 
183
 
#ifdef CONFIG_ANTIALIASING
184
 
typedef YPixbuf YIconImage;
185
 
#else    
186
 
typedef YPixmap YIconImage;
187
 
#endif
188
 
 
189
145
class Graphics {
190
146
public:
191
147
    Graphics(YWindow & window, unsigned long vmask, XGCValues * gcv);
199
155
                  const int dx, const int dy);
200
156
    void copyDrawable(const Drawable d, const int x, const int y, 
201
157
                      const int w, const int h, const int dx, const int dy);
 
158
#if 0
202
159
    void copyImage(XImage * im, const int x, const int y, 
203
160
                   const int w, const int h, const int dx, const int dy);
204
161
    void copyImage(XImage * im, const int x, const int y) {
205
162
        copyImage(im, 0, 0, im->width, im->height, x, y);
206
163
    }
 
164
#endif
207
165
    void copyPixmap(const ref<YPixmap> &p, const int x, const int y,
208
 
                    const int w, const int h, const int dx, const int dy)
 
166
                     const int w, const int h, const int dx, const int dy)
209
167
    {
210
168
        if (p != null)
211
169
            copyDrawable(p->pixmap(), x, y, w, h, dx, dy);
212
170
    }
 
171
#if 0
213
172
#ifdef CONFIG_ANTIALIASING
214
173
    void copyPixbuf(class YPixbuf & pixbuf, const int x, const int y,
215
174
                    const int w, const int h, const int dx, const int dy,
217
176
    void copyAlphaMask(class YPixbuf & pixbuf, const int x, const int y,
218
177
                       const int w, const int h, const int dx, const int dy);
219
178
#endif
 
179
#endif
220
180
 
221
181
    void drawPoint(int x, int y);
222
182
    void drawLine(int x1, int y1, int x2, int y2);
227
187
    void drawArc(int x, int y, int width, int height, int a1, int a2);
228
188
    void drawArrow(YDirection direction, int x, int y, int size, bool pressed = false);
229
189
 
 
190
    void drawChars(const ustring &s, int x, int y);
230
191
    void drawChars(char const * data, int offset, int len, int x, int y);
231
192
    void drawCharUnderline(int x, int y, char const * str, int charPos);
232
193
 
 
194
    void drawCharUnderline(int x, int y, const ustring &str, int charPos);
 
195
 
233
196
    void drawString(int x, int y, char const * str);
234
197
    void drawStringEllipsis(int x, int y, char const * str, int maxWidth);
 
198
    void drawStringEllipsis(int x, int y, const ustring &str, int maxWidth);
235
199
    void drawStringMultiline(int x, int y, char const * str);
 
200
    void drawStringMultiline(int x, int y, const ustring &str);
236
201
 
237
 
    void drawImage(const ref<YIconImage> &img, int const x, int const y);
238
202
    void drawPixmap(const ref<YPixmap> &pix, int const x, int const y);
 
203
    void drawImage(const ref<YImage> &pix, int const x, int const y);
 
204
    void drawImage(const ref<YImage> &pix, int const x, int const y, int w, int h, int dx, int dy);
 
205
    void compositeImage(const ref<YImage> &pix, int const x, int const y, int w, int h, int dx, int dy);
239
206
    void drawMask(const ref<YPixmap> &pix, int const x, int const y);
240
207
    void drawClippedPixmap(Pixmap pix, Pixmap clip,
241
208
                           int x, int y, int w, int h, int toX, int toY);
252
219
    void setLineWidth(int width);
253
220
    void setPenStyle(bool dotLine = false); ///!!!hack
254
221
    void setFunction(int function = GXcopy);
255
 
    
 
222
 
256
223
    void draw3DRect(int x, int y, int w, int h, bool raised);
257
224
    void drawBorderW(int x, int y, int w, int h, bool raised);
258
225
    void drawBorderM(int x, int y, int w, int h, bool raised);
271
238
    }
272
239
 
273
240
#ifdef CONFIG_GRADIENTS
274
 
    void drawGradient(const ref<YPixbuf> &pixbuf,
 
241
    void drawGradient(const ref<YImage> &gradient,
275
242
                      int const x, int const y, const int w, const int h,
276
243
                      int const gx, int const gy, const int gw, const int gh);
277
 
    void drawGradient(const ref<YPixbuf> &pixbuf,
 
244
    void drawGradient(const ref<YImage> &gradient,
278
245
                      int const x, int const y, const int w, const int h) {
279
 
        drawGradient(pixbuf, x, y, w, h, 0, 0, w, h);
 
246
        drawGradient(gradient, x, y, w, h, 0, 0, w, h);
280
247
    }
281
248
#endif
282
249
 
301
268
    int function() const;
302
269
    int xorigin() const { return xOrigin; }
303
270
    int yorigin() const { return yOrigin; }
 
271
    int rwidth() const { return rWidth; }
 
272
    int rheight() const { return rHeight; }
304
273
 
305
274
    void setClipRectangles(XRectangle *rect, int count);
306
275
    void setClipMask(Pixmap mask = None);