author | llornkcor <llornkcor> | 2003-06-14 18:02:08 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-14 18:02:08 (UTC) |
commit | 4f3517efd69b1b4a016799e3875b6c72e9fb1a3b (patch) (unidiff) | |
tree | 35b0d98c887e4939c1334d388cea094572efc5b5 | |
parent | e2a1c237211e4009ce2b76d3adc3860fbb255732 (diff) | |
download | opie-4f3517efd69b1b4a016799e3875b6c72e9fb1a3b.zip opie-4f3517efd69b1b4a016799e3875b6c72e9fb1a3b.tar.gz opie-4f3517efd69b1b4a016799e3875b6c72e9fb1a3b.tar.bz2 |
in libopie
-rw-r--r-- | noncore/apps/tinykate/libkate/libkate.pro | 93 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/qcolordialog.cpp | 1631 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/qcolordialog.h | 84 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/xmltree.cc | 322 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/xmltree.h | 117 |
5 files changed, 44 insertions, 2203 deletions
diff --git a/noncore/apps/tinykate/libkate/libkate.pro b/noncore/apps/tinykate/libkate/libkate.pro index 2fcced7..5cb0b14 100644 --- a/noncore/apps/tinykate/libkate/libkate.pro +++ b/noncore/apps/tinykate/libkate/libkate.pro | |||
@@ -1,5 +1,5 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE = lib |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = microkde/kapplication.h \ | 3 | HEADERS = microkde/kapplication.h \ |
4 | kateconfig.h \ | 4 | kateconfig.h \ |
5 | microkde/kdebug.h \ | 5 | microkde/kdebug.h \ |
@@ -26,23 +26,21 @@ HEADERS = microkde/kapplication.h \ | |||
26 | microkde/kglobalsettings.h \ | 26 | microkde/kglobalsettings.h \ |
27 | microkde/kcolorbtn.h \ | 27 | microkde/kcolorbtn.h \ |
28 | microkde/xmltree.h \ | 28 | qt3back/qregexp3.h \ |
29 | microkde/qcolordialog.h \ | 29 | microkde/ksharedptr.h \ |
30 | qt3back/qregexp3.h \ | 30 | document/katebuffer.h document/katedialogs.h \ |
31 | microkde/ksharedptr.h \ | 31 | document/katetextline.h \ |
32 | document/katebuffer.h document/katedialogs.h \ | 32 | document/katecmd.h \ |
33 | document/katetextline.h \ | 33 | document/katehighlight.h \ |
34 | document/katecmd.h \ | 34 | document/katecmds.h document/katedocument.h \ |
35 | document/katehighlight.h \ | 35 | document/katesyntaxdocument.h \ |
36 | document/katecmds.h document/katedocument.h \ | 36 | view/kateundohistory.h \ |
37 | document/katesyntaxdocument.h \ | 37 | view/kateview.h \ |
38 | view/kateundohistory.h \ | 38 | view/kateviewdialog.h \ |
39 | view/kateview.h \ | 39 | interfaces/view.h \ |
40 | view/kateviewdialog.h \ | 40 | interfaces/document.h \ |
41 | interfaces/view.h \ | 41 | ktexteditor/ktexteditor.h |
42 | interfaces/document.h \ | ||
43 | ktexteditor/ktexteditor.h | ||
44 | 42 | ||
45 | SOURCES = microkde/kapplication.cpp \ | 43 | SOURCES = microkde/kapplication.cpp \ |
46 | microkde/kdialogbase.cpp \ | 44 | microkde/kdialogbase.cpp \ |
47 | kateconfig.cpp \ | 45 | kateconfig.cpp \ |
48 | microkde/klocale.cpp \ | 46 | microkde/klocale.cpp \ |
@@ -53,3 +51,2 @@ SOURCES = microkde/kapplication.cpp \ | |||
53 | microkde/kurlrequester.cpp \ | 51 | microkde/kurlrequester.cpp \ |
54 | # microkde/kcolordialog.cpp \ | ||
55 | microkde/kfontdialog.cpp \ | 52 | microkde/kfontdialog.cpp \ |
@@ -59,29 +56,27 @@ SOURCES = microkde/kapplication.cpp \ | |||
59 | microkde/kglobalsettings.cpp \ | 56 | microkde/kglobalsettings.cpp \ |
60 | microkde/kcolorbtn.cpp \ | 57 | microkde/kcolorbtn.cpp \ |
61 | microkde/xmltree.cc \ | 58 | qt3back/qregexp3.cpp \ |
62 | microkde/qcolordialog.cpp \ | 59 | ktexteditor/ktexteditor.cpp \ |
63 | qt3back/qregexp3.cpp \ | 60 | document/katebuffer.cpp document/katedialogs.cpp \ |
64 | ktexteditor/ktexteditor.cpp \ | 61 | document/katehighlight.cpp \ |
65 | document/katebuffer.cpp document/katedialogs.cpp \ | 62 | document/katecmd.cpp \ |
66 | document/katehighlight.cpp \ | 63 | document/katesyntaxdocument.cpp document/katecmds.cpp \ |
67 | document/katecmd.cpp \ | 64 | document/katedocument.cpp document/katetextline.cpp \ |
68 | document/katesyntaxdocument.cpp document/katecmds.cpp \ | 65 | view/kateundohistory.cpp \ |
69 | document/katedocument.cpp document/katetextline.cpp \ | 66 | view/kateview.cpp \ |
70 | view/kateundohistory.cpp \ | 67 | view/kateviewdialog.cpp \ |
71 | view/kateview.cpp \ | 68 | interfaces/interfaces.cpp |
72 | view/kateviewdialog.cpp \ | ||
73 | interfaces/interfaces.cpp | ||
74 | 69 | ||
75 | INTERFACES= | 70 | INTERFACES = |
76 | INCLUDEPATH+= $(OPIEDIR)/include \ | 71 | INCLUDEPATH += $(OPIEDIR)/include \ |
77 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ | 72 | $(OPIEDIR)/noncore/apps/tinykate/libkate \ |
78 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ | 73 | $(OPIEDIR)/noncore/apps/tinykate/libkate/microkde \ |
79 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ | 74 | $(OPIEDIR)/noncore/apps/tinykate/libkate/document \ |
80 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ | 75 | $(OPIEDIR)/noncore/apps/tinykate/libkate/view \ |
81 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ | 76 | $(OPIEDIR)/noncore/apps/tinykate/libkate/interfaces \ |
82 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ | 77 | $(OPIEDIR)/noncore/apps/tinykate/libkate/ktexteditor \ |
83 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back | 78 | $(OPIEDIR)/noncore/apps/tinykate/libkate/qt3back |
84 | DEPENDPATH+= $(OPIEDIR)/include | 79 | DEPENDPATH += $(OPIEDIR)/include |
85 | LIBS += -lqpe -lopie | 80 | LIBS += -lqpe -lopie |
86 | TARGET = tinykate | 81 | TARGET = tinykate |
87 | 82 | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/qcolordialog.cpp b/noncore/apps/tinykate/libkate/microkde/qcolordialog.cpp deleted file mode 100644 index fe999b6..0000000 --- a/noncore/apps/tinykate/libkate/microkde/qcolordialog.cpp +++ b/dev/null | |||
@@ -1,1631 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Implementation of KColorDialog class | ||
5 | ** | ||
6 | ** Created : 990222 | ||
7 | ** | ||
8 | ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
22 | ** licenses may use this file in accordance with the Qt Commercial License | ||
23 | ** Agreement provided with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #include "qcolordialog.h" | ||
39 | |||
40 | #include <qpainter.h> | ||
41 | #include <qlayout.h> | ||
42 | #include <qlabel.h> | ||
43 | #include <qpushbutton.h> | ||
44 | #include <qlineedit.h> | ||
45 | #include <qimage.h> | ||
46 | #include <qpixmap.h> | ||
47 | #include <qdrawutil.h> | ||
48 | #include <qvalidator.h> | ||
49 | #include <qdragobject.h> | ||
50 | #include <qapplication.h> | ||
51 | #include <qdragobject.h> | ||
52 | |||
53 | //////////// QWellArray BEGIN | ||
54 | |||
55 | #include <qobjectdict.h> | ||
56 | |||
57 | // | ||
58 | // W A R N I N G | ||
59 | // ------------- | ||
60 | // | ||
61 | // This file is not part of the Qt API. It exists for the convenience | ||
62 | // of qwellarray.cpp and qcolordialog.cpp. | ||
63 | // This header file may change from version to version without notice, | ||
64 | // or even be removed. | ||
65 | // | ||
66 | // | ||
67 | |||
68 | |||
69 | #include <qtableview.h> | ||
70 | |||
71 | |||
72 | struct QWellArrayData; | ||
73 | |||
74 | class QWellArray : public QTableView | ||
75 | { | ||
76 | Q_OBJECT | ||
77 | Q_PROPERTY( int numCols READ numCols ) | ||
78 | Q_PROPERTY( int numRows READ numRows ) | ||
79 | Q_PROPERTY( int selectedColumn READ selectedColumn ) | ||
80 | Q_PROPERTY( int selectedRow READ selectedRow ) | ||
81 | |||
82 | public: | ||
83 | QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); | ||
84 | |||
85 | ~QWellArray() {} | ||
86 | QString cellContent( int row, int col ) const; | ||
87 | // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); | ||
88 | |||
89 | // ##### Obsolete since not const | ||
90 | int numCols() { return nCols; } | ||
91 | int numRows() { return nRows; } | ||
92 | |||
93 | int numCols() const { return nCols; } | ||
94 | int numRows() const { return nRows; } | ||
95 | |||
96 | // ##### Obsolete since not const | ||
97 | int selectedColumn() { return selCol; } | ||
98 | int selectedRow() { return selRow; } | ||
99 | |||
100 | int selectedColumn() const { return selCol; } | ||
101 | int selectedRow() const { return selRow; } | ||
102 | |||
103 | virtual void setSelected( int row, int col ); | ||
104 | |||
105 | void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } | ||
106 | |||
107 | QSize sizeHint() const; | ||
108 | |||
109 | virtual void setDimension( int rows, int cols ); | ||
110 | virtual void setCellBrush( int row, int col, const QBrush & ); | ||
111 | QBrush cellBrush( int row, int col ); | ||
112 | |||
113 | signals: | ||
114 | void selected( int row, int col ); | ||
115 | |||
116 | protected: | ||
117 | virtual void setCurrent( int row, int col ); | ||
118 | |||
119 | virtual void drawContents( QPainter *, int row, int col, const QRect& ); | ||
120 | void drawContents( QPainter * ); | ||
121 | |||
122 | void paintCell( QPainter*, int row, int col ); | ||
123 | void mousePressEvent( QMouseEvent* ); | ||
124 | void mouseReleaseEvent( QMouseEvent* ); | ||
125 | void mouseMoveEvent( QMouseEvent* ); | ||
126 | void keyPressEvent( QKeyEvent* ); | ||
127 | void focusInEvent( QFocusEvent* ); | ||
128 | void focusOutEvent( QFocusEvent* ); | ||
129 | |||
130 | private: | ||
131 | int curRow; | ||
132 | int curCol; | ||
133 | int selRow; | ||
134 | int selCol; | ||
135 | int nCols; | ||
136 | int nRows; | ||
137 | bool smallStyle; | ||
138 | QWellArrayData *d; | ||
139 | |||
140 | private:// Disabled copy constructor and operator= | ||
141 | #if defined(Q_DISABLE_COPY) | ||
142 | QWellArray( const QWellArray & ); | ||
143 | QWellArray& operator=( const QWellArray & ); | ||
144 | #endif | ||
145 | }; | ||
146 | |||
147 | |||
148 | |||
149 | // non-interface ... | ||
150 | |||
151 | |||
152 | |||
153 | struct QWellArrayData { | ||
154 | QBrush *brush; | ||
155 | }; | ||
156 | |||
157 | // NOT REVISED | ||
158 | /* WARNING, NOT | ||
159 | \class QWellArray qwellarray_p.h | ||
160 | \brief .... | ||
161 | |||
162 | .... | ||
163 | |||
164 | \ingroup advanced | ||
165 | */ | ||
166 | |||
167 | QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) | ||
168 | : QTableView( parent, name, | ||
169 | popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) | ||
170 | { | ||
171 | d = 0; | ||
172 | setFocusPolicy( StrongFocus ); | ||
173 | setBackgroundMode( PaletteButton ); | ||
174 | nCols = 7; | ||
175 | nRows = 7; | ||
176 | int w = 24; // cell width | ||
177 | int h = 21; // cell height | ||
178 | smallStyle = popup; | ||
179 | |||
180 | if ( popup ) { | ||
181 | w = h = 18; | ||
182 | if ( style() == WindowsStyle ) | ||
183 | setFrameStyle( QFrame::WinPanel | QFrame::Raised ); | ||
184 | else | ||
185 | setFrameStyle( QFrame::Panel | QFrame::Raised ); | ||
186 | setMargin( 1 ); | ||
187 | setLineWidth( 2 ); | ||
188 | } | ||
189 | setNumCols( nCols ); | ||
190 | setNumRows( nRows ); | ||
191 | setCellWidth( w ); | ||
192 | setCellHeight( h ); | ||
193 | curCol = 0; | ||
194 | curRow = 0; | ||
195 | selCol = -1; | ||
196 | selRow = -1; | ||
197 | |||
198 | if ( smallStyle ) | ||
199 | setMouseTracking( TRUE ); | ||
200 | setOffset( 5 , 10 ); | ||
201 | |||
202 | resize( sizeHint() ); | ||
203 | |||
204 | } | ||
205 | |||
206 | |||
207 | QSize QWellArray::sizeHint() const | ||
208 | { | ||
209 | constPolish(); | ||
210 | int f = frameWidth() * 2; | ||
211 | int w = nCols * cellWidth() + f; | ||
212 | int h = nRows * cellHeight() + f; | ||
213 | return QSize( w, h ); | ||
214 | } | ||
215 | |||
216 | |||
217 | void QWellArray::paintCell( QPainter* p, int row, int col ) | ||
218 | { | ||
219 | int w = cellWidth( col ); // width of cell in pixels | ||
220 | int h = cellHeight( row ); // height of cell in pixels | ||
221 | int b = 1; | ||
222 | |||
223 | if ( !smallStyle ) | ||
224 | b = 3; | ||
225 | |||
226 | const QColorGroup & g = colorGroup(); | ||
227 | p->setPen( QPen( black, 0, SolidLine ) ); | ||
228 | if ( !smallStyle && row ==selRow && col == selCol && | ||
229 | style() != MotifStyle ) { | ||
230 | int n = 2; | ||
231 | p->drawRect( n, n, w-2*n, h-2*n ); | ||
232 | } | ||
233 | |||
234 | |||
235 | if ( style() == WindowsStyle ) { | ||
236 | qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, | ||
237 | g, TRUE ); | ||
238 | b += 2; | ||
239 | } else { | ||
240 | if ( smallStyle ) { | ||
241 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | ||
242 | g, TRUE, 2 ); | ||
243 | b += 2; | ||
244 | } else { | ||
245 | int t = ( row == selRow && col == selCol ) ? 2 : 0; | ||
246 | b -= t; | ||
247 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | ||
248 | g, TRUE, 2 ); | ||
249 | b += 2 + t; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | |||
254 | if ( (row == curRow) && (col == curCol) ) { | ||
255 | if ( smallStyle ) { | ||
256 | p->setPen ( white ); | ||
257 | p->drawRect( 1, 1, w-2, h-2 ); | ||
258 | p->setPen ( black ); | ||
259 | p->drawRect( 0, 0, w, h ); | ||
260 | p->drawRect( 2, 2, w-4, h-4 ); | ||
261 | b = 3; | ||
262 | } else if ( hasFocus() ) { | ||
263 | style().drawFocusRect(p, QRect(0,0,w,h), g ); | ||
264 | } | ||
265 | } | ||
266 | drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); | ||
267 | } | ||
268 | |||
269 | /*! | ||
270 | Pass-through to QTableView::drawContents() to avoid hiding. | ||
271 | */ | ||
272 | void QWellArray::drawContents( QPainter *p ) | ||
273 | { | ||
274 | QTableView::drawContents(p); | ||
275 | } | ||
276 | |||
277 | /*! | ||
278 | Reimplement this function to change the contents of the well array. | ||
279 | */ | ||
280 | void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) | ||
281 | { | ||
282 | |||
283 | if ( d ) { | ||
284 | p->fillRect( r, d->brush[row*nCols+col] ); | ||
285 | } else { | ||
286 | p->fillRect( r, white ); | ||
287 | p->setPen( black ); | ||
288 | p->drawLine( r.topLeft(), r.bottomRight() ); | ||
289 | p->drawLine( r.topRight(), r.bottomLeft() ); | ||
290 | } | ||
291 | } | ||
292 | |||
293 | |||
294 | /*\reimp | ||
295 | */ | ||
296 | void QWellArray::mousePressEvent( QMouseEvent* e ) | ||
297 | { | ||
298 | // The current cell marker is set to the cell the mouse is pressed | ||
299 | // in. | ||
300 | QPoint pos = e->pos(); | ||
301 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | ||
302 | } | ||
303 | |||
304 | /*\reimp | ||
305 | */ | ||
306 | void QWellArray::mouseReleaseEvent( QMouseEvent* ) | ||
307 | { | ||
308 | // The current cell marker is set to the cell the mouse is clicked | ||
309 | // in. | ||
310 | setSelected( curRow, curCol ); | ||
311 | } | ||
312 | |||
313 | |||
314 | /*\reimp | ||
315 | */ | ||
316 | void QWellArray::mouseMoveEvent( QMouseEvent* e ) | ||
317 | { | ||
318 | // The current cell marker is set to the cell the mouse is | ||
319 | // clicked in. | ||
320 | if ( smallStyle ) { | ||
321 | QPoint pos = e->pos(); | ||
322 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | ||
323 | } | ||
324 | } | ||
325 | |||
326 | /* | ||
327 | Sets the cell currently having the focus. This is not necessarily | ||
328 | the same as the currently selected cell. | ||
329 | */ | ||
330 | |||
331 | void QWellArray::setCurrent( int row, int col ) | ||
332 | { | ||
333 | |||
334 | if ( (curRow == row) && (curCol == col) ) | ||
335 | return; | ||
336 | |||
337 | if ( row < 0 || col < 0 ) | ||
338 | row = col = -1; | ||
339 | |||
340 | int oldRow = curRow; | ||
341 | int oldCol = curCol; | ||
342 | |||
343 | curRow = row; | ||
344 | curCol = col; | ||
345 | |||
346 | updateCell( oldRow, oldCol ); | ||
347 | updateCell( curRow, curCol ); | ||
348 | } | ||
349 | |||
350 | |||
351 | /*! | ||
352 | Sets the currently selected cell to \a row, \a col. If \a row or \a | ||
353 | col are less than zero, the current cell is unselected. | ||
354 | |||
355 | Does not set the position of the focus indicator. | ||
356 | */ | ||
357 | |||
358 | void QWellArray::setSelected( int row, int col ) | ||
359 | { | ||
360 | if ( (selRow == row) && (selCol == col) ) | ||
361 | return; | ||
362 | |||
363 | int oldRow = selRow; | ||
364 | int oldCol = selCol; | ||
365 | |||
366 | if ( row < 0 || col < 0 ) | ||
367 | row = col = -1; | ||
368 | |||
369 | selCol = col; | ||
370 | selRow = row; | ||
371 | |||
372 | updateCell( oldRow, oldCol ); | ||
373 | updateCell( selRow, selCol ); | ||
374 | if ( row >= 0 ) | ||
375 | emit selected( row, col ); | ||
376 | |||
377 | if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) | ||
378 | parentWidget()->close(); | ||
379 | |||
380 | } | ||
381 | |||
382 | |||
383 | |||
384 | /*!\reimp | ||
385 | */ | ||
386 | void QWellArray::focusInEvent( QFocusEvent* ) | ||
387 | { | ||
388 | updateCell( curRow, curCol ); | ||
389 | } | ||
390 | |||
391 | |||
392 | /*! | ||
393 | Sets the size of the well array to be \c rows cells by \c cols. | ||
394 | Resets any brush info set by setCellBrush(). | ||
395 | |||
396 | Must be called by reimplementors. | ||
397 | */ | ||
398 | void QWellArray::setDimension( int rows, int cols ) | ||
399 | { | ||
400 | nRows = rows; | ||
401 | nCols = cols; | ||
402 | if ( d ) { | ||
403 | if ( d->brush ) | ||
404 | delete[] d->brush; | ||
405 | delete d; | ||
406 | d = 0; | ||
407 | } | ||
408 | setNumCols( nCols ); | ||
409 | setNumRows( nRows ); | ||
410 | } | ||
411 | |||
412 | void QWellArray::setCellBrush( int row, int col, const QBrush &b ) | ||
413 | { | ||
414 | if ( !d ) { | ||
415 | d = new QWellArrayData; | ||
416 | d->brush = new QBrush[nRows*nCols]; | ||
417 | } | ||
418 | if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) | ||
419 | d->brush[row*nCols+col] = b; | ||
420 | #ifdef CHECK_RANGE | ||
421 | else | ||
422 | qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); | ||
423 | #endif | ||
424 | } | ||
425 | |||
426 | |||
427 | |||
428 | /*! | ||
429 | Returns the brush set for the cell at \a row, \a col. If no brush is set, | ||
430 | \c NoBrush is returned. | ||
431 | */ | ||
432 | |||
433 | QBrush QWellArray::cellBrush( int row, int col ) | ||
434 | { | ||
435 | if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) | ||
436 | return d->brush[row*nCols+col]; | ||
437 | return NoBrush; | ||
438 | } | ||
439 | |||
440 | |||
441 | |||
442 | /*!\reimp | ||
443 | */ | ||
444 | |||
445 | void QWellArray::focusOutEvent( QFocusEvent* ) | ||
446 | { | ||
447 | updateCell( curRow, curCol ); | ||
448 | } | ||
449 | |||
450 | /*\reimp | ||
451 | */ | ||
452 | void QWellArray::keyPressEvent( QKeyEvent* e ) | ||
453 | { | ||
454 | switch( e->key() ) { // Look at the key code | ||
455 | case Key_Left: // If 'left arrow'-key, | ||
456 | if( curCol > 0 ) { // and cr't not in leftmost col | ||
457 | setCurrent( curRow, curCol - 1);// set cr't to next left column | ||
458 | int edge = leftCell(); // find left edge | ||
459 | if ( curCol < edge ) // if we have moved off edge, | ||
460 | setLeftCell( edge - 1 );// scroll view to rectify | ||
461 | } | ||
462 | break; | ||
463 | case Key_Right: // Correspondingly... | ||
464 | if( curCol < numCols()-1 ) { | ||
465 | setCurrent( curRow, curCol + 1); | ||
466 | int edge = lastColVisible(); | ||
467 | if ( curCol >= edge ) | ||
468 | setLeftCell( leftCell() + 1 ); | ||
469 | } | ||
470 | break; | ||
471 | case Key_Up: | ||
472 | if( curRow > 0 ) { | ||
473 | setCurrent( curRow - 1, curCol); | ||
474 | int edge = topCell(); | ||
475 | if ( curRow < edge ) | ||
476 | setTopCell( edge - 1 ); | ||
477 | } else if ( smallStyle ) | ||
478 | focusNextPrevChild( FALSE ); | ||
479 | break; | ||
480 | case Key_Down: | ||
481 | if( curRow < numRows()-1 ) { | ||
482 | setCurrent( curRow + 1, curCol); | ||
483 | int edge = lastRowVisible(); | ||
484 | if ( curRow >= edge ) | ||
485 | setTopCell( topCell() + 1 ); | ||
486 | } else if ( smallStyle ) | ||
487 | focusNextPrevChild( TRUE ); | ||
488 | break; | ||
489 | case Key_Space: | ||
490 | case Key_Return: | ||
491 | case Key_Enter: | ||
492 | setSelected( curRow, curCol ); | ||
493 | break; | ||
494 | default: // If not an interesting key, | ||
495 | e->ignore(); // we don't accept the event | ||
496 | return; | ||
497 | } | ||
498 | |||
499 | } | ||
500 | |||
501 | //////////// QWellArray END | ||
502 | |||
503 | static bool initrgb = FALSE; | ||
504 | static QRgb stdrgb[6*8]; | ||
505 | static QRgb cusrgb[2*8]; | ||
506 | |||
507 | |||
508 | static void initRGB() | ||
509 | { | ||
510 | if ( initrgb ) | ||
511 | return; | ||
512 | initrgb = TRUE; | ||
513 | int i = 0; | ||
514 | for ( int g = 0; g < 4; g++ ) | ||
515 | for ( int r = 0; r < 4; r++ ) | ||
516 | for ( int b = 0; b < 3; b++ ) | ||
517 | stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 ); | ||
518 | |||
519 | for ( i = 0; i < 2*8; i++ ) | ||
520 | cusrgb[i] = qRgb(0xff,0xff,0xff); | ||
521 | } | ||
522 | |||
523 | /*! | ||
524 | Returns the number of custom colors supported by | ||
525 | KColorDialog. All color dialogs share the same custom colors. | ||
526 | */ | ||
527 | int KColorDialog::customCount() | ||
528 | { | ||
529 | return 2*8; | ||
530 | } | ||
531 | |||
532 | /*! | ||
533 | Returns custom color number \a i as a QRgb. | ||
534 | */ | ||
535 | QRgb KColorDialog::customColor( int i ) | ||
536 | { | ||
537 | initRGB(); | ||
538 | if ( i < 0 || i >= customCount() ) { | ||
539 | #ifdef CHECK_RANGE | ||
540 | qWarning( "KColorDialog::customColor() index %d out of range", i ); | ||
541 | #endif | ||
542 | i = 0; | ||
543 | } | ||
544 | return cusrgb[i]; | ||
545 | } | ||
546 | |||
547 | /*! | ||
548 | Sets custom color number \a i to the QRgb value \a c. | ||
549 | */ | ||
550 | void KColorDialog::setCustomColor( int i, QRgb c ) | ||
551 | { | ||
552 | initRGB(); | ||
553 | if ( i < 0 || i >= customCount() ) { | ||
554 | #ifdef CHECK_RANGE | ||
555 | qWarning( "KColorDialog::customColor() index %d out of range", i ); | ||
556 | #endif | ||
557 | return; | ||
558 | } | ||
559 | cusrgb[i] = c; | ||
560 | } | ||
561 | |||
562 | static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) | ||
563 | { | ||
564 | QColor c; | ||
565 | c.setRgb( rgb ); | ||
566 | c.getHsv(h,s,v); | ||
567 | } | ||
568 | |||
569 | class QColorWell : public QWellArray | ||
570 | { | ||
571 | public: | ||
572 | QColorWell( QWidget *parent, int r, int c, QRgb *vals ) | ||
573 | :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) | ||
574 | { setDimension(r,c); setWFlags( WResizeNoErase ); } | ||
575 | QSizePolicy sizePolicy() const; | ||
576 | |||
577 | protected: | ||
578 | void drawContents( QPainter *, int row, int col, const QRect& ); | ||
579 | void drawContents( QPainter *p ) { QWellArray::drawContents(p); } | ||
580 | void mousePressEvent( QMouseEvent *e ); | ||
581 | void mouseMoveEvent( QMouseEvent *e ); | ||
582 | void mouseReleaseEvent( QMouseEvent *e ); | ||
583 | #ifndef QT_NO_DRAGANDDROP | ||
584 | void dragEnterEvent( QDragEnterEvent *e ); | ||
585 | void dragLeaveEvent( QDragLeaveEvent *e ); | ||
586 | void dragMoveEvent( QDragMoveEvent *e ); | ||
587 | void dropEvent( QDropEvent *e ); | ||
588 | #endif | ||
589 | |||
590 | private: | ||
591 | QRgb *values; | ||
592 | bool mousePressed; | ||
593 | QPoint pressPos; | ||
594 | QPoint oldCurrent; | ||
595 | |||
596 | }; | ||
597 | |||
598 | QSizePolicy QColorWell::sizePolicy() const | ||
599 | { | ||
600 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | ||
601 | } | ||
602 | |||
603 | void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r ) | ||
604 | { | ||
605 | int i = row + col*numRows(); | ||
606 | p->fillRect( r, QColor( values[i] ) ); | ||
607 | } | ||
608 | |||
609 | void QColorWell::mousePressEvent( QMouseEvent *e ) | ||
610 | { | ||
611 | oldCurrent = QPoint( selectedRow(), selectedColumn() ); | ||
612 | QWellArray::mousePressEvent( e ); | ||
613 | mousePressed = TRUE; | ||
614 | pressPos = e->pos(); | ||
615 | } | ||
616 | |||
617 | void QColorWell::mouseMoveEvent( QMouseEvent *e ) | ||
618 | { | ||
619 | QWellArray::mouseMoveEvent( e ); | ||
620 | #ifndef QT_NO_DRAGANDDROP | ||
621 | if ( !mousePressed ) | ||
622 | return; | ||
623 | if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { | ||
624 | setCurrent( oldCurrent.x(), oldCurrent.y() ); | ||
625 | int i = findRow( e->y() ) + findCol( e->x() ) * numRows(); | ||
626 | QColor col( values[ i ] ); | ||
627 | QColorDrag *drg = new QColorDrag( col, this ); | ||
628 | QPixmap pix( cellWidth(), cellHeight() ); | ||
629 | pix.fill( col ); | ||
630 | QPainter p( &pix ); | ||
631 | p.drawRect( 0, 0, pix.width(), pix.height() ); | ||
632 | p.end(); | ||
633 | drg->setPixmap( pix ); | ||
634 | mousePressed = FALSE; | ||
635 | drg->dragCopy(); | ||
636 | } | ||
637 | #endif | ||
638 | } | ||
639 | |||
640 | #ifndef QT_NO_DRAGANDDROP | ||
641 | void QColorWell::dragEnterEvent( QDragEnterEvent *e ) | ||
642 | { | ||
643 | setFocus(); | ||
644 | if ( QColorDrag::canDecode( e ) ) | ||
645 | e->accept(); | ||
646 | else | ||
647 | e->ignore(); | ||
648 | } | ||
649 | |||
650 | void QColorWell::dragLeaveEvent( QDragLeaveEvent * ) | ||
651 | { | ||
652 | if ( hasFocus() ) | ||
653 | parentWidget()->setFocus(); | ||
654 | } | ||
655 | |||
656 | void QColorWell::dragMoveEvent( QDragMoveEvent *e ) | ||
657 | { | ||
658 | if ( QColorDrag::canDecode( e ) ) { | ||
659 | setCurrent( findRow( e->pos().y() ), findCol( e->pos().x() ) ); | ||
660 | e->accept(); | ||
661 | } else | ||
662 | e->ignore(); | ||
663 | } | ||
664 | |||
665 | void QColorWell::dropEvent( QDropEvent *e ) | ||
666 | { | ||
667 | if ( QColorDrag::canDecode( e ) ) { | ||
668 | int i = findRow( e->pos().y() ) + findCol( e->pos().x() ) * numRows(); | ||
669 | QColor col; | ||
670 | QColorDrag::decode( e, col ); | ||
671 | values[ i ] = col.rgb(); | ||
672 | repaint( FALSE ); | ||
673 | e->accept(); | ||
674 | } else { | ||
675 | e->ignore(); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | #endif // QT_NO_DRAGANDDROP | ||
680 | |||
681 | void QColorWell::mouseReleaseEvent( QMouseEvent *e ) | ||
682 | { | ||
683 | if ( !mousePressed ) | ||
684 | return; | ||
685 | QWellArray::mouseReleaseEvent( e ); | ||
686 | mousePressed = FALSE; | ||
687 | } | ||
688 | |||
689 | class QColorPicker : public QFrame | ||
690 | { | ||
691 | Q_OBJECT | ||
692 | public: | ||
693 | QColorPicker(QWidget* parent=0, const char* name=0); | ||
694 | ~QColorPicker(); | ||
695 | |||
696 | public slots: | ||
697 | void setCol( int h, int s ); | ||
698 | |||
699 | signals: | ||
700 | void newCol( int h, int s ); | ||
701 | |||
702 | protected: | ||
703 | QSize sizeHint() const; | ||
704 | QSizePolicy sizePolicy() const; | ||
705 | void drawContents(QPainter* p); | ||
706 | void mouseMoveEvent( QMouseEvent * ); | ||
707 | void mousePressEvent( QMouseEvent * ); | ||
708 | |||
709 | private: | ||
710 | int hue; | ||
711 | int sat; | ||
712 | |||
713 | QPoint colPt(); | ||
714 | int huePt( const QPoint &pt ); | ||
715 | int satPt( const QPoint &pt ); | ||
716 | void setCol( const QPoint &pt ); | ||
717 | |||
718 | QPixmap *pix; | ||
719 | }; | ||
720 | |||
721 | static int pWidth = 200; | ||
722 | static int pHeight = 200; | ||
723 | |||
724 | class QColorLuminancePicker : public QWidget | ||
725 | { | ||
726 | Q_OBJECT | ||
727 | public: | ||
728 | QColorLuminancePicker(QWidget* parent=0, const char* name=0); | ||
729 | ~QColorLuminancePicker(); | ||
730 | |||
731 | public slots: | ||
732 | void setCol( int h, int s, int v ); | ||
733 | void setCol( int h, int s ); | ||
734 | |||
735 | signals: | ||
736 | void newHsv( int h, int s, int v ); | ||
737 | |||
738 | protected: | ||
739 | // QSize sizeHint() const; | ||
740 | // QSizePolicy sizePolicy() const; | ||
741 | void paintEvent( QPaintEvent*); | ||
742 | void mouseMoveEvent( QMouseEvent * ); | ||
743 | void mousePressEvent( QMouseEvent * ); | ||
744 | |||
745 | private: | ||
746 | enum { foff = 3, coff = 4 }; //frame and contents offset | ||
747 | int val; | ||
748 | int hue; | ||
749 | int sat; | ||
750 | |||
751 | int y2val( int y ); | ||
752 | int val2y( int val ); | ||
753 | void setVal( int v ); | ||
754 | |||
755 | QPixmap *pix; | ||
756 | }; | ||
757 | |||
758 | |||
759 | int QColorLuminancePicker::y2val( int y ) | ||
760 | { | ||
761 | int d = height() - 2*coff - 1; | ||
762 | return 255 - (y - coff)*255/d; | ||
763 | } | ||
764 | |||
765 | int QColorLuminancePicker::val2y( int v ) | ||
766 | { | ||
767 | int d = height() - 2*coff - 1; | ||
768 | return coff + (255-v)*d/255; | ||
769 | } | ||
770 | |||
771 | QColorLuminancePicker::QColorLuminancePicker(QWidget* parent, | ||
772 | const char* name) | ||
773 | :QWidget( parent, name ) | ||
774 | { | ||
775 | hue = 100; val = 100; sat = 100; | ||
776 | pix = 0; | ||
777 | // setBackgroundMode( NoBackground ); | ||
778 | } | ||
779 | |||
780 | QColorLuminancePicker::~QColorLuminancePicker() | ||
781 | { | ||
782 | delete pix; | ||
783 | } | ||
784 | |||
785 | void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m ) | ||
786 | { | ||
787 | setVal( y2val(m->y()) ); | ||
788 | } | ||
789 | void QColorLuminancePicker::mousePressEvent( QMouseEvent *m ) | ||
790 | { | ||
791 | setVal( y2val(m->y()) ); | ||
792 | } | ||
793 | |||
794 | void QColorLuminancePicker::setVal( int v ) | ||
795 | { | ||
796 | if ( val == v ) | ||
797 | return; | ||
798 | val = QMAX( 0, QMIN(v,255)); | ||
799 | delete pix; pix=0; | ||
800 | repaint( FALSE ); //### | ||
801 | emit newHsv( hue, sat, val ); | ||
802 | } | ||
803 | |||
804 | //receives from a hue,sat chooser and relays. | ||
805 | void QColorLuminancePicker::setCol( int h, int s ) | ||
806 | { | ||
807 | setCol( h, s, val ); | ||
808 | emit newHsv( h, s, val ); | ||
809 | } | ||
810 | |||
811 | void QColorLuminancePicker::paintEvent( QPaintEvent * ) | ||
812 | { | ||
813 | int w = width() - 5; | ||
814 | |||
815 | QRect r( 0, foff, w, height() - 2*foff ); | ||
816 | int wi = r.width() - 2; | ||
817 | int hi = r.height() - 2; | ||
818 | if ( !pix || pix->height() != hi || pix->width() != wi ) { | ||
819 | delete pix; | ||
820 | QImage img( wi, hi, 32 ); | ||
821 | int y; | ||
822 | for ( y = 0; y < hi; y++ ) { | ||
823 | QColor c( hue, sat, y2val(y+coff), QColor::Hsv ); | ||
824 | QRgb r = c.rgb(); | ||
825 | int x; | ||
826 | for ( x = 0; x < wi; x++ ) | ||
827 | img.setPixel( x, y, r ); | ||
828 | } | ||
829 | pix = new QPixmap; | ||
830 | pix->convertFromImage(img); | ||
831 | } | ||
832 | QPainter p(this); | ||
833 | p.drawPixmap( 1, coff, *pix ); | ||
834 | QColorGroup g = colorGroup(); | ||
835 | qDrawShadePanel( &p, r, g, TRUE ); | ||
836 | p.setPen( g.foreground() ); | ||
837 | p.setBrush( g.foreground() ); | ||
838 | QPointArray a; | ||
839 | int y = val2y(val); | ||
840 | a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 ); | ||
841 | erase( w, 0, 5, height() ); | ||
842 | p.drawPolygon( a ); | ||
843 | } | ||
844 | |||
845 | void QColorLuminancePicker::setCol( int h, int s , int v ) | ||
846 | { | ||
847 | val = v; | ||
848 | hue = h; | ||
849 | sat = s; | ||
850 | delete pix; pix=0; | ||
851 | repaint( FALSE );//#### | ||
852 | } | ||
853 | |||
854 | QPoint QColorPicker::colPt() | ||
855 | { return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); } | ||
856 | int QColorPicker::huePt( const QPoint &pt ) | ||
857 | { return 360 - pt.x()*360/(pWidth-1); } | ||
858 | int QColorPicker::satPt( const QPoint &pt ) | ||
859 | { return 255 - pt.y()*255/(pHeight-1) ; } | ||
860 | void QColorPicker::setCol( const QPoint &pt ) | ||
861 | { setCol( huePt(pt), satPt(pt) ); } | ||
862 | |||
863 | QColorPicker::QColorPicker(QWidget* parent, const char* name ) | ||
864 | : QFrame( parent, name ) | ||
865 | { | ||
866 | hue = 0; sat = 0; | ||
867 | setCol( 150, 255 ); | ||
868 | |||
869 | QImage img( pWidth, pHeight, 32 ); | ||
870 | int x,y; | ||
871 | for ( y = 0; y < pHeight; y++ ) | ||
872 | for ( x = 0; x < pWidth; x++ ) { | ||
873 | QPoint p( x, y ); | ||
874 | img.setPixel( x, y, QColor(huePt(p), satPt(p), | ||
875 | 200, QColor::Hsv).rgb() ); | ||
876 | } | ||
877 | pix = new QPixmap; | ||
878 | pix->convertFromImage(img); | ||
879 | setBackgroundMode( NoBackground ); | ||
880 | } | ||
881 | |||
882 | QColorPicker::~QColorPicker() | ||
883 | { | ||
884 | delete pix; | ||
885 | } | ||
886 | |||
887 | QSize QColorPicker::sizeHint() const | ||
888 | { | ||
889 | return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() ); | ||
890 | } | ||
891 | |||
892 | QSizePolicy QColorPicker::sizePolicy() const | ||
893 | { | ||
894 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); | ||
895 | } | ||
896 | |||
897 | void QColorPicker::setCol( int h, int s ) | ||
898 | { | ||
899 | int nhue = QMIN( QMAX(0,h), 360 ); | ||
900 | int nsat = QMIN( QMAX(0,s), 255); | ||
901 | if ( nhue == hue && nsat == sat ) | ||
902 | return; | ||
903 | QRect r( colPt(), QSize(20,20) ); | ||
904 | hue = nhue; sat = nsat; | ||
905 | r = r.unite( QRect( colPt(), QSize(20,20) ) ); | ||
906 | r.moveBy( contentsRect().x()-9, contentsRect().y()-9 ); | ||
907 | // update( r ); | ||
908 | repaint( r, FALSE ); | ||
909 | } | ||
910 | |||
911 | void QColorPicker::mouseMoveEvent( QMouseEvent *m ) | ||
912 | { | ||
913 | QPoint p = m->pos() - contentsRect().topLeft(); | ||
914 | setCol( p ); | ||
915 | emit newCol( hue, sat ); | ||
916 | } | ||
917 | |||
918 | void QColorPicker::mousePressEvent( QMouseEvent *m ) | ||
919 | { | ||
920 | QPoint p = m->pos() - contentsRect().topLeft(); | ||
921 | setCol( p ); | ||
922 | emit newCol( hue, sat ); | ||
923 | } | ||
924 | |||
925 | void QColorPicker::drawContents(QPainter* p) | ||
926 | { | ||
927 | QRect r = contentsRect(); | ||
928 | |||
929 | p->drawPixmap( r.topLeft(), *pix ); | ||
930 | QPoint pt = colPt() + r.topLeft(); | ||
931 | p->setPen( QPen(black) ); | ||
932 | |||
933 | p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); | ||
934 | p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); | ||
935 | |||
936 | } | ||
937 | |||
938 | class QColorShowLabel; | ||
939 | |||
940 | |||
941 | |||
942 | class QColIntValidator: public QIntValidator | ||
943 | { | ||
944 | public: | ||
945 | QColIntValidator( int bottom, int top, | ||
946 | QWidget * parent, const char *name = 0 ) | ||
947 | :QIntValidator( bottom, top, parent, name ) {} | ||
948 | |||
949 | QValidator::State validate( QString &, int & ) const; | ||
950 | }; | ||
951 | |||
952 | QValidator::State QColIntValidator::validate( QString &s, int &pos ) const | ||
953 | { | ||
954 | State state = QIntValidator::validate(s,pos); | ||
955 | if ( state == Valid ) { | ||
956 | long int val = s.toLong(); | ||
957 | // This is not a general solution, assumes that top() > 0 and | ||
958 | // bottom >= 0 | ||
959 | if ( val < 0 ) { | ||
960 | s = "0"; | ||
961 | pos = 1; | ||
962 | } else if ( val > top() ) { | ||
963 | s.setNum( top() ); | ||
964 | pos = s.length(); | ||
965 | } | ||
966 | } | ||
967 | return state; | ||
968 | } | ||
969 | |||
970 | |||
971 | |||
972 | class QColNumLineEdit : public QLineEdit | ||
973 | { | ||
974 | public: | ||
975 | QColNumLineEdit( QWidget *parent, const char* name = 0 ) | ||
976 | : QLineEdit( parent, name ) { setMaxLength( 3 );} | ||
977 | QSize sizeHint() const { | ||
978 | return QSize( 30, //##### | ||
979 | QLineEdit::sizeHint().height() ); } | ||
980 | void setNum( int i ) { | ||
981 | QString s; | ||
982 | s.setNum(i); | ||
983 | bool block = signalsBlocked(); | ||
984 | blockSignals(TRUE); | ||
985 | setText( s ); | ||
986 | blockSignals(block); | ||
987 | } | ||
988 | int val() const { return text().toInt(); } | ||
989 | }; | ||
990 | |||
991 | |||
992 | class QColorShower : public QWidget | ||
993 | { | ||
994 | Q_OBJECT | ||
995 | public: | ||
996 | QColorShower( QWidget *parent, const char *name = 0 ); | ||
997 | |||
998 | //things that don't emit signals | ||
999 | void setHsv( int h, int s, int v ); | ||
1000 | |||
1001 | int currentAlpha() const { return alphaEd->val(); } | ||
1002 | void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } | ||
1003 | void showAlpha( bool b ); | ||
1004 | |||
1005 | |||
1006 | QRgb currentColor() const { return curCol; } | ||
1007 | |||
1008 | public slots: | ||
1009 | void setRgb( QRgb rgb ); | ||
1010 | |||
1011 | signals: | ||
1012 | void newCol( QRgb rgb ); | ||
1013 | private slots: | ||
1014 | void rgbEd(); | ||
1015 | void hsvEd(); | ||
1016 | private: | ||
1017 | void showCurrentColor(); | ||
1018 | int hue, sat, val; | ||
1019 | QRgb curCol; | ||
1020 | QColNumLineEdit *hEd; | ||
1021 | QColNumLineEdit *sEd; | ||
1022 | QColNumLineEdit *vEd; | ||
1023 | QColNumLineEdit *rEd; | ||
1024 | QColNumLineEdit *gEd; | ||
1025 | QColNumLineEdit *bEd; | ||
1026 | QColNumLineEdit *alphaEd; | ||
1027 | QLabel *alphaLab; | ||
1028 | QColorShowLabel *lab; | ||
1029 | bool rgbOriginal; | ||
1030 | }; | ||
1031 | |||
1032 | class QColorShowLabel : public QFrame | ||
1033 | { | ||
1034 | Q_OBJECT | ||
1035 | |||
1036 | public: | ||
1037 | QColorShowLabel( QWidget *parent ) :QFrame( parent ) { | ||
1038 | setFrameStyle( QFrame::Panel|QFrame::Sunken ); | ||
1039 | setBackgroundMode( PaletteBackground ); | ||
1040 | setAcceptDrops( TRUE ); | ||
1041 | mousePressed = FALSE; | ||
1042 | } | ||
1043 | void setColor( QColor c ) { col = c; } | ||
1044 | |||
1045 | signals: | ||
1046 | void colorDropped( QRgb ); | ||
1047 | |||
1048 | protected: | ||
1049 | void drawContents( QPainter *p ); | ||
1050 | void mousePressEvent( QMouseEvent *e ); | ||
1051 | void mouseMoveEvent( QMouseEvent *e ); | ||
1052 | void mouseReleaseEvent( QMouseEvent *e ); | ||
1053 | #ifndef QT_NO_DRAGANDDROP | ||
1054 | void dragEnterEvent( QDragEnterEvent *e ); | ||
1055 | void dragLeaveEvent( QDragLeaveEvent *e ); | ||
1056 | void dropEvent( QDropEvent *e ); | ||
1057 | #endif | ||
1058 | |||
1059 | private: | ||
1060 | QColor col; | ||
1061 | bool mousePressed; | ||
1062 | QPoint pressPos; | ||
1063 | |||
1064 | }; | ||
1065 | |||
1066 | void QColorShowLabel::drawContents( QPainter *p ) | ||
1067 | { | ||
1068 | p->fillRect( contentsRect(), col ); | ||
1069 | } | ||
1070 | |||
1071 | void QColorShower::showAlpha( bool b ) | ||
1072 | { | ||
1073 | if ( b ) { | ||
1074 | alphaLab->show(); | ||
1075 | alphaEd->show(); | ||
1076 | } else { | ||
1077 | alphaLab->hide(); | ||
1078 | alphaEd->hide(); | ||
1079 | } | ||
1080 | } | ||
1081 | |||
1082 | void QColorShowLabel::mousePressEvent( QMouseEvent *e ) | ||
1083 | { | ||
1084 | mousePressed = TRUE; | ||
1085 | pressPos = e->pos(); | ||
1086 | } | ||
1087 | |||
1088 | void QColorShowLabel::mouseMoveEvent( QMouseEvent *e ) | ||
1089 | { | ||
1090 | #ifndef QT_NO_DRAGANDDROP | ||
1091 | if ( !mousePressed ) | ||
1092 | return; | ||
1093 | if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { | ||
1094 | QColorDrag *drg = new QColorDrag( col, this ); | ||
1095 | QPixmap pix( 30, 20 ); | ||
1096 | pix.fill( col ); | ||
1097 | QPainter p( &pix ); | ||
1098 | p.drawRect( 0, 0, pix.width(), pix.height() ); | ||
1099 | p.end(); | ||
1100 | drg->setPixmap( pix ); | ||
1101 | mousePressed = FALSE; | ||
1102 | drg->dragCopy(); | ||
1103 | } | ||
1104 | #endif | ||
1105 | } | ||
1106 | |||
1107 | #ifndef QT_NO_DRAGANDDROP | ||
1108 | void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e ) | ||
1109 | { | ||
1110 | if ( QColorDrag::canDecode( e ) ) | ||
1111 | e->accept(); | ||
1112 | else | ||
1113 | e->ignore(); | ||
1114 | } | ||
1115 | |||
1116 | void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * ) | ||
1117 | { | ||
1118 | } | ||
1119 | |||
1120 | void QColorShowLabel::dropEvent( QDropEvent *e ) | ||
1121 | { | ||
1122 | if ( QColorDrag::canDecode( e ) ) { | ||
1123 | QColorDrag::decode( e, col ); | ||
1124 | repaint( FALSE ); | ||
1125 | emit colorDropped( col.rgb() ); | ||
1126 | e->accept(); | ||
1127 | } else { | ||
1128 | e->ignore(); | ||
1129 | } | ||
1130 | } | ||
1131 | #endif // QT_NO_DRAGANDDROP | ||
1132 | |||
1133 | void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) | ||
1134 | { | ||
1135 | if ( !mousePressed ) | ||
1136 | return; | ||
1137 | mousePressed = FALSE; | ||
1138 | } | ||
1139 | |||
1140 | QColorShower::QColorShower( QWidget *parent, const char *name ) | ||
1141 | :QWidget( parent, name) | ||
1142 | { | ||
1143 | curCol = qRgb( -1, -1, -1 ); | ||
1144 | QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); | ||
1145 | QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); | ||
1146 | |||
1147 | QGridLayout *gl = new QGridLayout( this, 1, 1, 6 ); | ||
1148 | lab = new QColorShowLabel( this ); | ||
1149 | lab->setMinimumWidth( 60 ); //### | ||
1150 | gl->addMultiCellWidget(lab, 0,-1,0,0); | ||
1151 | connect( lab, SIGNAL( colorDropped( QRgb ) ), | ||
1152 | this, SIGNAL( newCol( QRgb ) ) ); | ||
1153 | connect( lab, SIGNAL( colorDropped( QRgb ) ), | ||
1154 | this, SLOT( setRgb( QRgb ) ) ); | ||
1155 | |||
1156 | hEd = new QColNumLineEdit( this ); | ||
1157 | hEd->setValidator( val360 ); | ||
1158 | QLabel *l = new QLabel( hEd, KColorDialog::tr("Hu&e:"), this ); | ||
1159 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1160 | gl->addWidget( l, 0, 1 ); | ||
1161 | gl->addWidget( hEd, 0, 2 ); | ||
1162 | |||
1163 | sEd = new QColNumLineEdit( this ); | ||
1164 | sEd->setValidator( val256 ); | ||
1165 | l = new QLabel( sEd, KColorDialog::tr("&Sat:"), this ); | ||
1166 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1167 | gl->addWidget( l, 1, 1 ); | ||
1168 | gl->addWidget( sEd, 1, 2 ); | ||
1169 | |||
1170 | vEd = new QColNumLineEdit( this ); | ||
1171 | vEd->setValidator( val256 ); | ||
1172 | l = new QLabel( vEd, KColorDialog::tr("&Val:"), this ); | ||
1173 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1174 | gl->addWidget( l, 2, 1 ); | ||
1175 | gl->addWidget( vEd, 2, 2 ); | ||
1176 | |||
1177 | rEd = new QColNumLineEdit( this ); | ||
1178 | rEd->setValidator( val256 ); | ||
1179 | l = new QLabel( rEd, KColorDialog::tr("&Red:"), this ); | ||
1180 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1181 | gl->addWidget( l, 0, 3 ); | ||
1182 | gl->addWidget( rEd, 0, 4 ); | ||
1183 | |||
1184 | gEd = new QColNumLineEdit( this ); | ||
1185 | gEd->setValidator( val256 ); | ||
1186 | l = new QLabel( gEd, KColorDialog::tr("&Green:"), this ); | ||
1187 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1188 | gl->addWidget( l, 1, 3 ); | ||
1189 | gl->addWidget( gEd, 1, 4 ); | ||
1190 | |||
1191 | bEd = new QColNumLineEdit( this ); | ||
1192 | bEd->setValidator( val256 ); | ||
1193 | l = new QLabel( bEd, KColorDialog::tr("Bl&ue:"), this ); | ||
1194 | l->setAlignment( AlignRight|AlignVCenter ); | ||
1195 | gl->addWidget( l, 2, 3 ); | ||
1196 | gl->addWidget( bEd, 2, 4 ); | ||
1197 | |||
1198 | alphaEd = new QColNumLineEdit( this ); | ||
1199 | alphaEd->setValidator( val256 ); | ||
1200 | alphaLab = new QLabel( alphaEd, KColorDialog::tr("A&lpha channel:"), this ); | ||
1201 | alphaLab->setAlignment( AlignRight|AlignVCenter ); | ||
1202 | gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); | ||
1203 | gl->addWidget( alphaEd, 3, 4 ); | ||
1204 | alphaEd->hide(); | ||
1205 | alphaLab->hide(); | ||
1206 | |||
1207 | connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | ||
1208 | connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | ||
1209 | connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); | ||
1210 | |||
1211 | connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | ||
1212 | connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | ||
1213 | connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); | ||
1214 | } | ||
1215 | |||
1216 | void QColorShower::showCurrentColor() | ||
1217 | { | ||
1218 | lab->setColor( currentColor() ); | ||
1219 | lab->repaint(FALSE); //### | ||
1220 | } | ||
1221 | |||
1222 | void QColorShower::rgbEd() | ||
1223 | { | ||
1224 | rgbOriginal = TRUE; | ||
1225 | curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); | ||
1226 | rgb2hsv(currentColor(), hue, sat, val ); | ||
1227 | |||
1228 | hEd->setNum( hue ); | ||
1229 | sEd->setNum( sat ); | ||
1230 | vEd->setNum( val ); | ||
1231 | |||
1232 | showCurrentColor(); | ||
1233 | emit newCol( currentColor() ); | ||
1234 | } | ||
1235 | |||
1236 | void QColorShower::hsvEd() | ||
1237 | { | ||
1238 | rgbOriginal = FALSE; | ||
1239 | hue = hEd->val(); | ||
1240 | sat = sEd->val(); | ||
1241 | val = vEd->val(); | ||
1242 | |||
1243 | curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); | ||
1244 | |||
1245 | rEd->setNum( qRed(currentColor()) ); | ||
1246 | gEd->setNum( qGreen(currentColor()) ); | ||
1247 | bEd->setNum( qBlue(currentColor()) ); | ||
1248 | |||
1249 | showCurrentColor(); | ||
1250 | emit newCol( currentColor() ); | ||
1251 | } | ||
1252 | |||
1253 | void QColorShower::setRgb( QRgb rgb ) | ||
1254 | { | ||
1255 | rgbOriginal = TRUE; | ||
1256 | curCol = rgb; | ||
1257 | |||
1258 | rgb2hsv( currentColor(), hue, sat, val ); | ||
1259 | |||
1260 | hEd->setNum( hue ); | ||
1261 | sEd->setNum( sat ); | ||
1262 | vEd->setNum( val ); | ||
1263 | |||
1264 | rEd->setNum( qRed(currentColor()) ); | ||
1265 | gEd->setNum( qGreen(currentColor()) ); | ||
1266 | bEd->setNum( qBlue(currentColor()) ); | ||
1267 | |||
1268 | showCurrentColor(); | ||
1269 | } | ||
1270 | |||
1271 | void QColorShower::setHsv( int h, int s, int v ) | ||
1272 | { | ||
1273 | rgbOriginal = FALSE; | ||
1274 | hue = h; val = v; sat = s; //Range check### | ||
1275 | curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); | ||
1276 | |||
1277 | hEd->setNum( hue ); | ||
1278 | sEd->setNum( sat ); | ||
1279 | vEd->setNum( val ); | ||
1280 | |||
1281 | rEd->setNum( qRed(currentColor()) ); | ||
1282 | gEd->setNum( qGreen(currentColor()) ); | ||
1283 | bEd->setNum( qBlue(currentColor()) ); | ||
1284 | |||
1285 | |||
1286 | showCurrentColor(); | ||
1287 | } | ||
1288 | |||
1289 | class KColorDialogPrivate : public QObject | ||
1290 | { | ||
1291 | Q_OBJECT | ||
1292 | public: | ||
1293 | KColorDialogPrivate( KColorDialog *p ); | ||
1294 | QRgb currentColor() const { return cs->currentColor(); } | ||
1295 | void setCurrentColor( QRgb rgb ); | ||
1296 | |||
1297 | int currentAlpha() const { return cs->currentAlpha(); } | ||
1298 | void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } | ||
1299 | void showAlpha( bool b ) { cs->showAlpha( b ); } | ||
1300 | |||
1301 | private slots: | ||
1302 | void addCustom(); | ||
1303 | |||
1304 | void newHsv( int h, int s, int v ); | ||
1305 | void newColorTypedIn( QRgb rgb ); | ||
1306 | void newCustom( int, int ); | ||
1307 | void newStandard( int, int ); | ||
1308 | private: | ||
1309 | QColorPicker *cp; | ||
1310 | QColorLuminancePicker *lp; | ||
1311 | QWellArray *custom; | ||
1312 | QWellArray *standard; | ||
1313 | QColorShower *cs; | ||
1314 | int nextCust; | ||
1315 | bool compact; | ||
1316 | }; | ||
1317 | |||
1318 | //sets all widgets to display h,s,v | ||
1319 | void KColorDialogPrivate::newHsv( int h, int s, int v ) | ||
1320 | { | ||
1321 | cs->setHsv( h, s, v ); | ||
1322 | cp->setCol( h, s ); | ||
1323 | lp->setCol( h, s, v ); | ||
1324 | } | ||
1325 | |||
1326 | //sets all widgets to display rgb | ||
1327 | void KColorDialogPrivate::setCurrentColor( QRgb rgb ) | ||
1328 | { | ||
1329 | cs->setRgb( rgb ); | ||
1330 | newColorTypedIn( rgb ); | ||
1331 | } | ||
1332 | |||
1333 | //sets all widgets exept cs to display rgb | ||
1334 | void KColorDialogPrivate::newColorTypedIn( QRgb rgb ) | ||
1335 | { | ||
1336 | int h, s, v; | ||
1337 | rgb2hsv(rgb, h, s, v ); | ||
1338 | cp->setCol( h, s ); | ||
1339 | lp->setCol( h, s, v); | ||
1340 | } | ||
1341 | |||
1342 | void KColorDialogPrivate::newCustom( int r, int c ) | ||
1343 | { | ||
1344 | int i = r+2*c; | ||
1345 | setCurrentColor( cusrgb[i] ); | ||
1346 | nextCust = i; | ||
1347 | standard->setSelected(-1,-1); | ||
1348 | } | ||
1349 | |||
1350 | void KColorDialogPrivate::newStandard( int r, int c ) | ||
1351 | { | ||
1352 | setCurrentColor( stdrgb[r+c*6] ); | ||
1353 | custom->setSelected(-1,-1); | ||
1354 | } | ||
1355 | |||
1356 | KColorDialogPrivate::KColorDialogPrivate( KColorDialog *dialog ) : | ||
1357 | QObject(dialog) | ||
1358 | { | ||
1359 | compact = FALSE; | ||
1360 | // small displays (e.g. PDAs cannot fit the full color dialog, | ||
1361 | // so just use the color picker. | ||
1362 | if ( qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350 ) | ||
1363 | compact = TRUE; | ||
1364 | |||
1365 | nextCust = 0; | ||
1366 | const int lumSpace = 3; | ||
1367 | int border = 12; | ||
1368 | if ( compact ) | ||
1369 | border = 6; | ||
1370 | QHBoxLayout *topLay = new QHBoxLayout( dialog, border, 6 ); | ||
1371 | QVBoxLayout *leftLay = 0; | ||
1372 | |||
1373 | if ( !compact ) | ||
1374 | leftLay = new QVBoxLayout( topLay ); | ||
1375 | |||
1376 | initRGB(); | ||
1377 | |||
1378 | if ( !compact ) { | ||
1379 | standard = new QColorWell( dialog, 6, 8, stdrgb ); | ||
1380 | standard->setCellSize( 28, 24 ); | ||
1381 | QLabel * lab = new QLabel( standard, | ||
1382 | KColorDialog::tr( "&Basic colors"), dialog ); | ||
1383 | connect( standard, SIGNAL(selected(int,int)), SLOT(newStandard(int,int))); | ||
1384 | leftLay->addWidget( lab ); | ||
1385 | leftLay->addWidget( standard ); | ||
1386 | |||
1387 | |||
1388 | leftLay->addStretch(); | ||
1389 | |||
1390 | custom = new QColorWell( dialog, 2, 8, cusrgb ); | ||
1391 | custom->setCellSize( 28, 24 ); | ||
1392 | custom->setAcceptDrops( TRUE ); | ||
1393 | |||
1394 | connect( custom, SIGNAL(selected(int,int)), SLOT(newCustom(int,int))); | ||
1395 | lab = new QLabel( custom, KColorDialog::tr( "&Custom colors") , dialog ); | ||
1396 | leftLay->addWidget( lab ); | ||
1397 | leftLay->addWidget( custom ); | ||
1398 | |||
1399 | QPushButton *custbut = | ||
1400 | new QPushButton( KColorDialog::tr("&Define Custom Colors >>"), | ||
1401 | dialog ); | ||
1402 | custbut->setEnabled( FALSE ); | ||
1403 | leftLay->addWidget( custbut ); | ||
1404 | } else { | ||
1405 | // better color picker size for small displays | ||
1406 | pWidth = 150; | ||
1407 | pHeight = 100; | ||
1408 | } | ||
1409 | |||
1410 | QVBoxLayout *rightLay = new QVBoxLayout( topLay ); | ||
1411 | |||
1412 | QHBoxLayout *pickLay = new QHBoxLayout( rightLay ); | ||
1413 | |||
1414 | |||
1415 | QVBoxLayout *cLay = new QVBoxLayout( pickLay ); | ||
1416 | cp = new QColorPicker( dialog ); | ||
1417 | cp->setFrameStyle( QFrame::Panel + QFrame::Sunken ); | ||
1418 | cLay->addSpacing( lumSpace ); | ||
1419 | cLay->addWidget( cp ); | ||
1420 | cLay->addSpacing( lumSpace ); | ||
1421 | |||
1422 | lp = new QColorLuminancePicker( dialog ); | ||
1423 | lp->setFixedWidth( 20 ); //### | ||
1424 | pickLay->addWidget( lp ); | ||
1425 | |||
1426 | connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) ); | ||
1427 | connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) ); | ||
1428 | |||
1429 | rightLay->addStretch(); | ||
1430 | |||
1431 | cs = new QColorShower( dialog ); | ||
1432 | connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb))); | ||
1433 | rightLay->addWidget( cs ); | ||
1434 | |||
1435 | QHBoxLayout *buttons; | ||
1436 | if ( compact ) | ||
1437 | buttons = new QHBoxLayout( rightLay ); | ||
1438 | else | ||
1439 | buttons = new QHBoxLayout( leftLay ); | ||
1440 | |||
1441 | QPushButton *ok, *cancel; | ||
1442 | ok = new QPushButton( KColorDialog::tr("OK"), dialog ); | ||
1443 | connect( ok, SIGNAL(clicked()), dialog, SLOT(accept()) ); | ||
1444 | ok->setDefault(TRUE); | ||
1445 | cancel = new QPushButton( KColorDialog::tr("Cancel"), dialog ); | ||
1446 | connect( cancel, SIGNAL(clicked()), dialog, SLOT(reject()) ); | ||
1447 | buttons->addWidget( ok ); | ||
1448 | buttons->addWidget( cancel ); | ||
1449 | buttons->addStretch(); | ||
1450 | |||
1451 | if ( !compact ) { | ||
1452 | QPushButton *addCusBt = new QPushButton( | ||
1453 | KColorDialog::tr("&Add To Custom Colors"), | ||
1454 | dialog ); | ||
1455 | rightLay->addWidget( addCusBt ); | ||
1456 | connect( addCusBt, SIGNAL(clicked()), this, SLOT(addCustom()) ); | ||
1457 | } | ||
1458 | } | ||
1459 | |||
1460 | void KColorDialogPrivate::addCustom() | ||
1461 | { | ||
1462 | cusrgb[nextCust] = cs->currentColor(); | ||
1463 | custom->repaint( FALSE ); //### | ||
1464 | nextCust = (nextCust+1) % 16; | ||
1465 | } | ||
1466 | |||
1467 | |||
1468 | // BEING REVISED: jo | ||
1469 | /*! | ||
1470 | \class KColorDialog qcolordialog.h | ||
1471 | \brief The KColorDialog class provides a dialog widget for specifying colors. | ||
1472 | \ingroup dialogs | ||
1473 | |||
1474 | The color dialog's function is to allow users to choose colors - | ||
1475 | for instance, you might use this in a drawing program to allow the | ||
1476 | user to set the brush color. | ||
1477 | |||
1478 | This version of Qt only provides modal color dialogs. The static | ||
1479 | getColor() function shows the dialog and allows the user to specify a color, | ||
1480 | while getRgba() does the same but allows the user to specify a color with an | ||
1481 | alpha channel (transparency) value. | ||
1482 | |||
1483 | The user can store customCount() different custom colors. The custom | ||
1484 | colors are shared by all color dialogs, and remembered during the | ||
1485 | execution of the program. Use setCustomColor() to set the | ||
1486 | custom colors, and customColor() to get them. | ||
1487 | |||
1488 | <img src=qcolordlg-m.png> <img src=qcolordlg-w.png> | ||
1489 | */ | ||
1490 | |||
1491 | /*! | ||
1492 | Constructs a default color dialog. Use setColor() for setting an initial value. | ||
1493 | |||
1494 | \sa getColor() | ||
1495 | */ | ||
1496 | |||
1497 | KColorDialog::KColorDialog(QWidget* parent, const char* name, bool modal) : | ||
1498 | QDialog(parent, name, modal ) | ||
1499 | { | ||
1500 | setSizeGripEnabled( TRUE ); | ||
1501 | d = new KColorDialogPrivate( this ); | ||
1502 | } | ||
1503 | |||
1504 | |||
1505 | /*! | ||
1506 | Pops up a modal color dialog letting the user choose a color and returns | ||
1507 | that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels | ||
1508 | the dialog. All colors allocated by the dialog will be deallocated | ||
1509 | before this function returns. | ||
1510 | */ | ||
1511 | |||
1512 | QColor KColorDialog::getColor( QColor initial, QWidget *parent, | ||
1513 | const char *name ) | ||
1514 | { | ||
1515 | int allocContext = QColor::enterAllocContext(); | ||
1516 | KColorDialog *dlg = new KColorDialog( parent, name, TRUE ); //modal | ||
1517 | if ( parent && parent->icon() && !parent->icon()->isNull() ) | ||
1518 | dlg->setIcon( *parent->icon() ); | ||
1519 | else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) | ||
1520 | dlg->setIcon( *qApp->mainWidget()->icon() ); | ||
1521 | |||
1522 | dlg->setCaption( KColorDialog::tr( "Select color" ) ); | ||
1523 | dlg->setColor( initial ); | ||
1524 | int resultCode = dlg->exec(); | ||
1525 | QColor::leaveAllocContext(); | ||
1526 | QColor result; | ||
1527 | if ( resultCode == QDialog::Accepted ) | ||
1528 | result = dlg->color(); | ||
1529 | QColor::destroyAllocContext(allocContext); | ||
1530 | delete dlg; | ||
1531 | return result; | ||
1532 | } | ||
1533 | |||
1534 | |||
1535 | /*! | ||
1536 | Pops up a modal color dialog, letting the user choose a color and an | ||
1537 | alpha channel value. The color+alpha is initially set to \a initial. | ||
1538 | |||
1539 | If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, | ||
1540 | and FALSE if the user clicked Cancel. | ||
1541 | |||
1542 | If the user clicks Cancel the \a initial value is returned. | ||
1543 | */ | ||
1544 | |||
1545 | QRgb KColorDialog::getRgba( QRgb initial, bool *ok, | ||
1546 | QWidget *parent, const char* name ) | ||
1547 | { | ||
1548 | int allocContext = QColor::enterAllocContext(); | ||
1549 | KColorDialog *dlg = new KColorDialog( parent, name, TRUE ); //modal | ||
1550 | dlg->setColor( initial ); | ||
1551 | dlg->setSelectedAlpha( qAlpha(initial) ); | ||
1552 | int resultCode = dlg->exec(); | ||
1553 | QColor::leaveAllocContext(); | ||
1554 | QRgb result = initial; | ||
1555 | if ( resultCode == QDialog::Accepted ) { | ||
1556 | QRgb c = dlg->color().rgb(); | ||
1557 | int alpha = dlg->selectedAlpha(); | ||
1558 | result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); | ||
1559 | } | ||
1560 | if ( ok ) | ||
1561 | *ok = resultCode == QDialog::Accepted; | ||
1562 | |||
1563 | QColor::destroyAllocContext(allocContext); | ||
1564 | delete dlg; | ||
1565 | return result; | ||
1566 | } | ||
1567 | |||
1568 | |||
1569 | |||
1570 | |||
1571 | |||
1572 | /*! | ||
1573 | Returns the color currently selected in the dialog. | ||
1574 | |||
1575 | \sa setColor() | ||
1576 | */ | ||
1577 | |||
1578 | QColor KColorDialog::color() const | ||
1579 | { | ||
1580 | return QColor(d->currentColor()); | ||
1581 | } | ||
1582 | |||
1583 | |||
1584 | /*! Destructs the dialog and frees any memory it allocated. | ||
1585 | |||
1586 | */ | ||
1587 | |||
1588 | KColorDialog::~KColorDialog() | ||
1589 | { | ||
1590 | //d inherits QObject, so it is deleted by Qt. | ||
1591 | } | ||
1592 | |||
1593 | |||
1594 | /*! | ||
1595 | Sets the color shown in the dialog to \a c. | ||
1596 | |||
1597 | \sa color() | ||
1598 | */ | ||
1599 | |||
1600 | void KColorDialog::setColor( QColor c ) | ||
1601 | { | ||
1602 | d->setCurrentColor( c.rgb() ); | ||
1603 | } | ||
1604 | |||
1605 | |||
1606 | |||
1607 | |||
1608 | /*! | ||
1609 | Sets the initial alpha channel value to \a a, and show the alpha channel | ||
1610 | entry box. | ||
1611 | */ | ||
1612 | |||
1613 | void KColorDialog::setSelectedAlpha( int a ) | ||
1614 | { | ||
1615 | d->showAlpha( TRUE ); | ||
1616 | d->setCurrentAlpha( a ); | ||
1617 | } | ||
1618 | |||
1619 | |||
1620 | /*! | ||
1621 | Returns the value selected for the alpha channel. | ||
1622 | */ | ||
1623 | |||
1624 | int KColorDialog::selectedAlpha() const | ||
1625 | { | ||
1626 | return d->currentAlpha(); | ||
1627 | } | ||
1628 | |||
1629 | |||
1630 | #include "qcolordialog.moc" | ||
1631 | |||
diff --git a/noncore/apps/tinykate/libkate/microkde/qcolordialog.h b/noncore/apps/tinykate/libkate/microkde/qcolordialog.h deleted file mode 100644 index c55dcf4..0000000 --- a/noncore/apps/tinykate/libkate/microkde/qcolordialog.h +++ b/dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of KColorDialog class | ||
5 | ** | ||
6 | ** Created : 990222 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
22 | ** licenses may use this file in accordance with the Qt Commercial License | ||
23 | ** Agreement provided with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #ifndef KColorDialog_H | ||
39 | #define KColorDialog_H | ||
40 | |||
41 | #ifndef QT_H | ||
42 | #include <qdialog.h> | ||
43 | #endif // QT_H | ||
44 | |||
45 | class KColorDialogPrivate; | ||
46 | |||
47 | class Q_EXPORT KColorDialog : public QDialog | ||
48 | { | ||
49 | Q_OBJECT | ||
50 | |||
51 | public: | ||
52 | static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor& | ||
53 | static QRgb getRgba( QRgb, bool* ok = 0, | ||
54 | QWidget *parent=0, const char* name=0 ); | ||
55 | |||
56 | |||
57 | static int customCount(); | ||
58 | static QRgb customColor( int ); | ||
59 | static void setCustomColor( int, QRgb ); | ||
60 | |||
61 | private: | ||
62 | ~KColorDialog(); | ||
63 | |||
64 | KColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE ); | ||
65 | void setColor( QColor ); // ### 3.0: make const QColor& | ||
66 | QColor color() const; | ||
67 | |||
68 | private: | ||
69 | void setSelectedAlpha( int ); | ||
70 | int selectedAlpha() const; | ||
71 | |||
72 | void showCustom( bool=TRUE ); | ||
73 | private: | ||
74 | KColorDialogPrivate *d; | ||
75 | friend class KColorDialogPrivate; | ||
76 | |||
77 | private:// Disabled copy constructor and operator= | ||
78 | #if defined(Q_DISABLE_COPY) | ||
79 | KColorDialog( const KColorDialog & ); | ||
80 | KColorDialog& operator=( const KColorDialog & ); | ||
81 | #endif | ||
82 | }; | ||
83 | |||
84 | #endif //KColorDialog_H | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/xmltree.cc b/noncore/apps/tinykate/libkate/microkde/xmltree.cc deleted file mode 100644 index 27db5b3..0000000 --- a/noncore/apps/tinykate/libkate/microkde/xmltree.cc +++ b/dev/null | |||
@@ -1,322 +0,0 @@ | |||
1 | /* This file is part of the KDE project | ||
2 | Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #include <qpe/stringutil.h> | ||
21 | #include <opie/xmltree.h> | ||
22 | |||
23 | #include <qxml.h> | ||
24 | |||
25 | #include <assert.h> | ||
26 | |||
27 | using namespace Opie; | ||
28 | |||
29 | XMLElement::XMLElement() | ||
30 | : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 ) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | XMLElement::~XMLElement() | ||
35 | { | ||
36 | XMLElement *n = m_first; | ||
37 | |||
38 | while ( n ) | ||
39 | { | ||
40 | XMLElement *tmp = n; | ||
41 | n = n->m_next; | ||
42 | delete tmp; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void XMLElement::appendChild( XMLElement *child ) | ||
47 | { | ||
48 | if ( child->m_parent ) | ||
49 | child->m_parent->removeChild( child ); | ||
50 | |||
51 | child->m_parent = this; | ||
52 | |||
53 | if ( m_last ) | ||
54 | m_last->m_next = child; | ||
55 | |||
56 | child->m_prev = m_last; | ||
57 | |||
58 | if ( !m_first ) | ||
59 | m_first = child; | ||
60 | |||
61 | m_last = child; | ||
62 | } | ||
63 | |||
64 | void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild ) | ||
65 | { | ||
66 | assert( newChild != refChild ); | ||
67 | |||
68 | if ( refChild == m_last ) | ||
69 | { | ||
70 | appendChild( newChild ); | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | assert( refChild ); | ||
75 | assert( refChild->m_parent ); | ||
76 | assert( refChild->m_parent == this ); | ||
77 | |||
78 | if ( newChild->m_parent && newChild != refChild ) | ||
79 | newChild->m_parent->removeChild( newChild ); | ||
80 | |||
81 | newChild->m_parent = this; | ||
82 | |||
83 | XMLElement *next = refChild->m_next; | ||
84 | |||
85 | refChild->m_next = newChild; | ||
86 | |||
87 | newChild->m_prev = refChild; | ||
88 | newChild->m_next = next; | ||
89 | |||
90 | if ( next ) | ||
91 | next->m_prev = newChild; | ||
92 | } | ||
93 | |||
94 | QString XMLElement::attribute( const QString &attr ) const | ||
95 | { | ||
96 | AttributeMap::ConstIterator it = m_attributes.find( attr ); | ||
97 | if ( it == m_attributes.end() ) | ||
98 | return QString::null; | ||
99 | return it.data(); | ||
100 | } | ||
101 | |||
102 | void XMLElement::setAttribute( const QString &attr, const QString &value ) | ||
103 | { | ||
104 | m_attributes.replace( attr, value ); | ||
105 | } | ||
106 | |||
107 | void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) | ||
108 | { | ||
109 | assert( refChild ); | ||
110 | assert( refChild->m_parent ); | ||
111 | assert( refChild->m_parent == this ); | ||
112 | assert( newChild != refChild ); | ||
113 | |||
114 | if ( newChild->m_parent && newChild != refChild ) | ||
115 | newChild->m_parent->removeChild( newChild ); | ||
116 | |||
117 | newChild->m_parent = this; | ||
118 | |||
119 | XMLElement *prev = refChild->m_prev; | ||
120 | |||
121 | refChild->m_prev = newChild; | ||
122 | |||
123 | newChild->m_prev = prev; | ||
124 | newChild->m_next = refChild; | ||
125 | |||
126 | if ( prev ) | ||
127 | prev->m_next = newChild; | ||
128 | |||
129 | if ( refChild == m_first ) | ||
130 | m_first = newChild; | ||
131 | } | ||
132 | |||
133 | void XMLElement::removeChild( XMLElement *child ) | ||
134 | { | ||
135 | if ( child->m_parent != this ) | ||
136 | return; | ||
137 | |||
138 | if ( m_first == child ) | ||
139 | m_first = child->m_next; | ||
140 | |||
141 | if ( m_last == child ) | ||
142 | m_last = child->m_prev; | ||
143 | |||
144 | if ( child->m_prev ) | ||
145 | child->m_prev->m_next = child->m_next; | ||
146 | |||
147 | if ( child->m_next ) | ||
148 | child->m_next->m_prev = child->m_prev; | ||
149 | |||
150 | child->m_parent = 0; | ||
151 | child->m_prev = 0; | ||
152 | child->m_next = 0; | ||
153 | } | ||
154 | |||
155 | void XMLElement::save( QTextStream &s, uint indent ) | ||
156 | { | ||
157 | if ( !m_value.isEmpty() ) | ||
158 | { | ||
159 | s << Qtopia::escapeString( m_value ); | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | for ( uint i = 0; i < indent; ++i ) | ||
164 | s << " "; | ||
165 | |||
166 | s << "<" << m_tag; | ||
167 | |||
168 | if ( !m_attributes.isEmpty() ) | ||
169 | { | ||
170 | s << " "; | ||
171 | AttributeMap::ConstIterator it = m_attributes.begin(); | ||
172 | AttributeMap::ConstIterator end = m_attributes.end(); | ||
173 | for (; it != end; ++it ) | ||
174 | { | ||
175 | s << it.key() << "=\"" << Qtopia::escapeString( it.data() ) << "\""; | ||
176 | s << " "; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | if ( m_last ) | ||
181 | { | ||
182 | if ( ( m_first && !m_first->value().isEmpty() ) || !m_parent ) | ||
183 | s << ">"; | ||
184 | else | ||
185 | s << ">" << endl; | ||
186 | |||
187 | int newIndent = indent; | ||
188 | if ( m_parent ) | ||
189 | newIndent++; | ||
190 | |||
191 | XMLElement *n = m_first; | ||
192 | while ( n ) | ||
193 | { | ||
194 | n->save( s, newIndent ); | ||
195 | n = n->nextChild(); | ||
196 | } | ||
197 | |||
198 | if ( m_last && m_last->value().isEmpty() && m_parent ) | ||
199 | for ( uint i = 0; i < indent; ++i ) | ||
200 | s << " "; | ||
201 | |||
202 | if ( m_parent ) | ||
203 | s << "</" << m_tag << ">" << endl; | ||
204 | } | ||
205 | else | ||
206 | s << "/>" << endl; | ||
207 | } | ||
208 | |||
209 | class Handler : public QXmlDefaultHandler | ||
210 | { | ||
211 | public: | ||
212 | Handler() : m_node( 0 ), m_root( 0 ) {} | ||
213 | |||
214 | XMLElement *root() const { return m_root; } | ||
215 | |||
216 | virtual bool startDocument(); | ||
217 | virtual bool endDocument(); | ||
218 | virtual bool startElement( const QString &ns, const QString &ln, const QString &qName, | ||
219 | const QXmlAttributes &attr ); | ||
220 | virtual bool endElement( const QString &ns, const QString &ln, const QString &qName ); | ||
221 | virtual bool characters( const QString &ch ); | ||
222 | |||
223 | private: | ||
224 | XMLElement *m_node; | ||
225 | XMLElement *m_root; | ||
226 | }; | ||
227 | |||
228 | bool Handler::startDocument() | ||
229 | { | ||
230 | m_root = m_node = new XMLElement; | ||
231 | |||
232 | return true; | ||
233 | } | ||
234 | |||
235 | bool Handler::endDocument() | ||
236 | { | ||
237 | return m_root == m_node; | ||
238 | } | ||
239 | |||
240 | bool Handler::startElement( const QString &, const QString &, const QString &qName, | ||
241 | const QXmlAttributes &attr ) | ||
242 | { | ||
243 | XMLElement *bm = new XMLElement; | ||
244 | |||
245 | XMLElement::AttributeMap attributes; | ||
246 | for ( int i = 0; i < attr.length(); ++i ) | ||
247 | attributes[ attr.qName( i ) ] = attr.value( i ); | ||
248 | |||
249 | bm->setAttributes( attributes ); | ||
250 | |||
251 | bm->setTagName( qName ); | ||
252 | |||
253 | m_node->appendChild( bm ); | ||
254 | m_node = bm; | ||
255 | |||
256 | return true; | ||
257 | } | ||
258 | |||
259 | bool Handler::endElement( const QString &, const QString &, const QString & ) | ||
260 | { | ||
261 | if ( m_node == m_root ) | ||
262 | return false; | ||
263 | |||
264 | m_node = m_node->parent(); | ||
265 | return true; | ||
266 | } | ||
267 | |||
268 | bool Handler::characters( const QString &ch ) | ||
269 | { | ||
270 | XMLElement *textNode = new XMLElement; | ||
271 | textNode->setValue( ch ); | ||
272 | m_node->appendChild( textNode ); | ||
273 | return true; | ||
274 | } | ||
275 | |||
276 | XMLElement *XMLElement::namedItem( const QString &name ) | ||
277 | { | ||
278 | XMLElement *e = m_first; | ||
279 | |||
280 | for (; e; e = e->nextChild() ) | ||
281 | if ( e->tagName() == name ) | ||
282 | return e; | ||
283 | |||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | XMLElement *XMLElement::clone() const | ||
288 | { | ||
289 | XMLElement *res = new XMLElement; | ||
290 | |||
291 | res->setTagName( m_tag ); | ||
292 | res->setValue( m_value ); | ||
293 | res->setAttributes( m_attributes ); | ||
294 | |||
295 | XMLElement *e = m_first; | ||
296 | for (; e; e = e->m_next ) | ||
297 | res->appendChild( e->clone() ); | ||
298 | |||
299 | return res; | ||
300 | } | ||
301 | |||
302 | XMLElement *XMLElement::load( const QString &fileName ) | ||
303 | { | ||
304 | QFile f( fileName ); | ||
305 | if ( !f.open( IO_ReadOnly ) ) | ||
306 | return 0; | ||
307 | |||
308 | QTextStream stream( &f ); | ||
309 | stream.setEncoding( QTextStream::UnicodeUTF8 ); | ||
310 | QXmlInputSource src( stream ); | ||
311 | QXmlSimpleReader reader; | ||
312 | Handler handler; | ||
313 | |||
314 | reader.setFeature( "http://trolltech.com/xml/features/report-whitespace-only-CharData", false ); | ||
315 | reader.setContentHandler( &handler ); | ||
316 | reader.parse( src ); | ||
317 | |||
318 | return handler.root();; | ||
319 | } | ||
320 | |||
321 | /* vim: et sw=4 | ||
322 | */ | ||
diff --git a/noncore/apps/tinykate/libkate/microkde/xmltree.h b/noncore/apps/tinykate/libkate/microkde/xmltree.h deleted file mode 100644 index 4a6b6d9..0000000 --- a/noncore/apps/tinykate/libkate/microkde/xmltree.h +++ b/dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /* This file is part of the KDE project | ||
2 | Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library 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 GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #ifndef __bookmarks_h__ | ||
22 | #define __bookmarks_h__ | ||
23 | |||
24 | #include <qstring.h> | ||
25 | #include <qmap.h> | ||
26 | #include <qtextstream.h> | ||
27 | |||
28 | namespace Opie | ||
29 | { | ||
30 | |||
31 | /** | ||
32 | * A small xml lib written by Simon Hausmann. | ||
33 | */ | ||
34 | class XMLElement | ||
35 | { | ||
36 | public: | ||
37 | typedef QMap<QString, QString> AttributeMap; | ||
38 | |||
39 | /** | ||
40 | * The constructor of XMLElement | ||
41 | */ | ||
42 | XMLElement(); | ||
43 | ~XMLElement(); | ||
44 | |||
45 | /** appendChild appends a child to the XMLElement behind the last element. | ||
46 | * The ownership of the child get's transfered to the | ||
47 | * this XMLElement. | ||
48 | * If child is already the child of another parent | ||
49 | * it's get removed from the other parent first. | ||
50 | */ | ||
51 | void appendChild( XMLElement *child ); | ||
52 | |||
53 | /** inserts newChild after refChild. If newChild is the child | ||
54 | * of another parent the child will get removed. | ||
55 | * The ownership of child gets transfered. | ||
56 | * | ||
57 | */ | ||
58 | void insertAfter( XMLElement *newChild, XMLElement *refChild ); | ||
59 | |||
60 | /** same as insertAfter but the element get's inserted before refChild. | ||
61 | * | ||
62 | */ | ||
63 | void insertBefore( XMLElement *newChild, XMLElement *refChild ); | ||
64 | |||
65 | /** removeChild removes the child from the XMLElement. | ||
66 | * The ownership gets dropped. You need to delete the | ||
67 | * child yourself. | ||
68 | */ | ||
69 | void removeChild( XMLElement *child ); | ||
70 | |||
71 | /** parent() returns the parent of this XMLElement | ||
72 | * If there is no parent 0l gets returned | ||
73 | */ | ||
74 | XMLElement *parent() const { return m_parent; } | ||
75 | XMLElement *firstChild() const { return m_first; } | ||
76 | XMLElement *nextChild() const { return m_next; } | ||
77 | XMLElement *prevChild() const { return m_prev; } | ||
78 | XMLElement *lastChild() const { return m_last; } | ||
79 | |||
80 | void setTagName( const QString &tag ) { m_tag = tag; } | ||
81 | QString tagName() const { return m_tag; } | ||
82 | |||
83 | void setValue( const QString &val ) { m_value = val; } | ||
84 | QString value() const { return m_value; } | ||
85 | |||
86 | void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; } | ||
87 | AttributeMap attributes() const { return m_attributes; } | ||
88 | AttributeMap &attributes() { return m_attributes; } | ||
89 | |||
90 | QString attribute( const QString & ) const; | ||
91 | void setAttribute( const QString &attr, const QString &value ); | ||
92 | void save( QTextStream &stream, uint indent = 0 ); | ||
93 | |||
94 | XMLElement *namedItem( const QString &name ); | ||
95 | |||
96 | XMLElement *clone() const; | ||
97 | |||
98 | static XMLElement *load( const QString &fileName ); | ||
99 | |||
100 | private: | ||
101 | QString m_tag; | ||
102 | QString m_value; | ||
103 | AttributeMap m_attributes; | ||
104 | |||
105 | XMLElement *m_parent; | ||
106 | XMLElement *m_next; | ||
107 | XMLElement *m_prev; | ||
108 | XMLElement *m_first; | ||
109 | XMLElement *m_last; | ||
110 | |||
111 | XMLElement( const XMLElement &rhs ); | ||
112 | XMLElement &operator=( const XMLElement &rhs ); | ||
113 | }; | ||
114 | |||
115 | } // namespace Opie | ||
116 | |||
117 | #endif | ||