File: tileedit.h

package info (click to toggle)
slashem 0.0.7E7F3-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 24,312 kB
  • ctags: 23,514
  • sloc: ansic: 263,201; cpp: 7,180; yacc: 2,154; sh: 739; lex: 440; awk: 97; makefile: 61; sed: 11
file content (128 lines) | stat: -rw-r--r-- 2,592 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*	SCCS Id: @(#)tileedit.h	3.4	1999/11/19	*/
/* Copyright (c) Warwick Allison, 1999. */
/* NetHack may be freely redistributed.  See license for details. */
#ifndef QNHTILEEDIT_H
#define QNHTILEEDIT_H

#include <qtabwidget.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qvbox.h>

class TilePickerTab : public QWidget {
    Q_OBJECT
public:
    TilePickerTab(const char* basename, int id, QWidget* parent);

    bool save();
    int numTiles();

signals:
    void pick(const QImage&);
    void pickName(const QString&);

public slots:
    void setCurrent(const QImage&);

protected:
    void paintEvent( QPaintEvent* );
    QSize sizeHint() const;
    void mousePressEvent(QMouseEvent*);

private:
    QString filename;
    int id;
    int last_pick;
    int num;
    QPixmap pixmap;
    QImage image;
};

class TilePicker : public QTabWidget {
    Q_OBJECT
public:
    TilePicker(QWidget* parent);

    void setTile(int tilenum, const QImage&);

signals:
    void pick(const QImage&);
    void pickName(const QString&);

public slots:
    void setCurrent(const QImage&);
    void save();
};

class TrivialTileEditor : public QWidget {
    Q_OBJECT
public:
    TrivialTileEditor( QWidget* parent );
    const QImage& image() const;

signals:
    void edited(const QImage&);
    void pick(QRgb);

public slots:
    void setColor(QRgb);
    void setImage( const QImage& );

protected:
    void paintEvent( QPaintEvent* );
    void mousePressEvent(QMouseEvent*);
    void mouseReleaseEvent(QMouseEvent*);
    void mouseMoveEvent(QMouseEvent*);
    QSize sizeHint() const;
    QSize sizeForWidth(int) const;
    QSizePolicy sizePolicy() const;

private:
    void fill(QPainter& painter, QPoint p, uchar from);
    QImage img;
    QColor pen;
    int penpixel;
    void paintPoint(QPainter& painter, QPoint p);
    QPoint screenPoint(QPoint) const;
    QPoint imagePoint(QPoint) const;
};

class TilePalette : public QWidget {
    Q_OBJECT
public:
    TilePalette( QWidget* parent );
    ~TilePalette();
    void setFromImage( const QImage& );
protected:
    void paintEvent( QPaintEvent* );
    void mousePressEvent(QMouseEvent*);
    QSize sizeHint() const;
    QSizePolicy sizePolicy() const;
signals:
    void pick(QRgb);
public slots:
    void setColor(QRgb);
private:
    int num;
    QRgb *rgb;
};

class TileEditor : public QVBox {
    Q_OBJECT
public:
    TileEditor(QWidget* parent);

    const QImage& image() const;

signals:
    void edited(const QImage&);

public slots:
    void edit(const QImage&);

private:
    TrivialTileEditor editor;
    TilePalette palette;
};

#endif