1 | /* Copyright (C) 1997 Mathias Mueller <in5y158@public.uni-hamburg.de> |
2 | * Copyright (C) 2006 Mauricio Piacentini <mauricio@tabuleiro.com> |
3 | * |
4 | * Kmahjongg is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
17 | |
18 | #ifndef EDITOR_H |
19 | #define EDITOR_H |
20 | |
21 | |
22 | #include "kmahjonggtileset.h" |
23 | #include "kmahjonggbackground.h" |
24 | #include "BoardLayout.h" |
25 | #include "FrameImage.h" |
26 | |
27 | #include <qframe.h> |
28 | |
29 | #include <kdialog.h> |
30 | #include <ktoolbar.h> |
31 | #include <kstatusbar.h> |
32 | #include <kfiledialog.h> |
33 | |
34 | |
35 | class QLabel; |
36 | class KActionCollection; |
37 | class QLabel; |
38 | |
39 | /** |
40 | * @short This class implements |
41 | * |
42 | * longer description |
43 | * |
44 | * @author Mauricio Piacentini <mauricio@tabuleiro.com> |
45 | */ |
46 | class Editor: public KDialog |
47 | { |
48 | Q_OBJECT |
49 | |
50 | public: |
51 | /** |
52 | * Constructor Description |
53 | * |
54 | * @param parent */ |
55 | explicit Editor (QWidget *parent = 0); |
56 | |
57 | /** |
58 | * Default Destructor */ |
59 | virtual ~Editor(); |
60 | |
61 | /** |
62 | * Return the tileset that is actually set. */ |
63 | const QString getTileset() const; |
64 | |
65 | /** |
66 | * Set a new tileset. */ |
67 | void setTileset(const QString tileset); |
68 | |
69 | public slots: |
70 | /** |
71 | * Load the settings from prefs. */ |
72 | void setTilesetFromSettings(); |
73 | |
74 | protected slots: |
75 | /** |
76 | * Slot Description */ |
77 | void drawFrameMousePressEvent ( QMouseEvent* ); |
78 | |
79 | /** |
80 | * Slot Description */ |
81 | void drawFrameMouseMovedEvent ( QMouseEvent *); |
82 | |
83 | /** |
84 | * Slot Description */ |
85 | void loadBoard(); |
86 | |
87 | /** |
88 | * Slot Description |
89 | * |
90 | * @return @c true if ... |
91 | * @return @c false if ... */ |
92 | bool saveBoard(); |
93 | |
94 | /** |
95 | * Slot Description */ |
96 | void newBoard(); |
97 | |
98 | /** |
99 | * Slot Description */ |
100 | void slotShiftLeft(); |
101 | |
102 | /** |
103 | * Slot Description */ |
104 | void slotShiftRight(); |
105 | |
106 | /** |
107 | * Slot Description */ |
108 | void slotShiftUp(); |
109 | |
110 | /** |
111 | * Slot Description */ |
112 | void slotShiftDown(); |
113 | |
114 | /** |
115 | * Slot Description */ |
116 | void slotModeChanged(QAction*); |
117 | |
118 | /** |
119 | * Slot Description */ |
120 | |
121 | protected: |
122 | /** |
123 | * Method Description */ |
124 | void resizeEvent(QResizeEvent *event); |
125 | |
126 | /** |
127 | * Method Description */ |
128 | void paintEvent(QPaintEvent *pa); |
129 | |
130 | /** |
131 | * Method Description */ |
132 | void setupToolbar(); |
133 | |
134 | /** |
135 | * Method Description */ |
136 | void drawBackground(QPixmap *to); |
137 | |
138 | /** |
139 | * Method Description |
140 | * |
141 | * @param to destination QPixmap to draw to */ |
142 | void drawTiles(QPixmap *to); |
143 | |
144 | /** |
145 | * Method Description |
146 | * |
147 | * @return @c true if |
148 | * @return @c false if */ |
149 | bool testSave(); |
150 | |
151 | /** |
152 | * Method Description */ |
153 | void transformPointToPosition(const QPoint&, POSITION&, bool align); |
154 | |
155 | /** |
156 | * Method Description |
157 | * |
158 | * @param p @ref pos |
159 | * @param visible */ |
160 | void drawCursor(POSITION &p, bool visible); |
161 | |
162 | /** |
163 | * Method Description |
164 | * |
165 | * @param p @ref pos |
166 | * @return @c true if |
167 | * @return @c false if */ |
168 | bool canInsert(POSITION &p); |
169 | |
170 | /** |
171 | * Method Description */ |
172 | void statusChanged(); |
173 | |
174 | /** |
175 | * Method Description |
176 | * |
177 | * @return status description */ |
178 | QString statusText(); |
179 | |
180 | /** |
181 | * Override the closeEvent(...) method of kdialog..qdialog. */ |
182 | void closeEvent(QCloseEvent *e); |
183 | |
184 | /** |
185 | * Update the tile size. */ |
186 | void updateTileSize(const QSize size); |
187 | |
188 | private: |
189 | /** |
190 | * @short Describe enum */ |
191 | enum { |
192 | remove = 98, |
193 | insert = 99, |
194 | move = 100 |
195 | }; |
196 | |
197 | QString mTileset; |
198 | |
199 | int borderLeft; |
200 | int borderTop; |
201 | int mode; |
202 | int numTiles; |
203 | bool clean; |
204 | |
205 | FrameImage *drawFrame; |
206 | KMahjonggTileset tiles; |
207 | BoardLayout theBoard; |
208 | POSITION currPos; |
209 | |
210 | QLabel *theLabel; |
211 | |
212 | KToolBar *topToolbar; |
213 | KActionCollection *actionCollection; |
214 | }; |
215 | |
216 | |
217 | #endif |
218 | |