author | mouse <mouse> | 2004-03-31 13:23:53 (UTC) |
---|---|---|
committer | mouse <mouse> | 2004-03-31 13:23:53 (UTC) |
commit | 859e524e4c55bedc4a73e3208f34a75013cb37f5 (patch) (unidiff) | |
tree | e46dc8a969254869e8a5d3cdc99b2c845f3e59e5 | |
parent | c74a24cbd04cb74d832908eb2b373aed7b3cea71 (diff) | |
download | opie-859e524e4c55bedc4a73e3208f34a75013cb37f5.zip opie-859e524e4c55bedc4a73e3208f34a75013cb37f5.tar.gz opie-859e524e4c55bedc4a73e3208f34a75013cb37f5.tar.bz2 |
added missed include file for QColorDrag
-rw-r--r-- | libqtaux/qcolordialog.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp index 907c2aa..ccef0ad 100644 --- a/libqtaux/qcolordialog.cpp +++ b/libqtaux/qcolordialog.cpp | |||
@@ -1,438 +1,442 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Implementation of QColorDialog class | 4 | ** Implementation of QColorDialog class |
5 | ** | 5 | ** |
6 | ** Created : 990222 | 6 | ** Created : 990222 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. | 10 | ** This file is part of the dialogs module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 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 | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "qcolordialog.h" | 38 | #include "qcolordialog.h" |
39 | 39 | ||
40 | #include "qpainter.h" | 40 | #include "qpainter.h" |
41 | #include "qlayout.h" | 41 | #include "qlayout.h" |
42 | #include "qlabel.h" | 42 | #include "qlabel.h" |
43 | #include "qpushbutton.h" | 43 | #include "qpushbutton.h" |
44 | #include "qlineedit.h" | 44 | #include "qlineedit.h" |
45 | #include "qimage.h" | 45 | #include "qimage.h" |
46 | #include "qpixmap.h" | 46 | #include "qpixmap.h" |
47 | #include "qdrawutil.h" | 47 | #include "qdrawutil.h" |
48 | #include "qvalidator.h" | 48 | #include "qvalidator.h" |
49 | #include "qapplication.h" | 49 | #include "qapplication.h" |
50 | 50 | ||
51 | //////////// QWellArray BEGIN | 51 | //////////// QWellArray BEGIN |
52 | 52 | ||
53 | #include "qobjectdict.h" | 53 | #include "qobjectdict.h" |
54 | 54 | ||
55 | #ifndef QT_NO_DRAGANDDROP | ||
56 | #include "qdragobject.h" | ||
57 | #endif | ||
58 | |||
55 | // | 59 | // |
56 | // W A R N I N G | 60 | // W A R N I N G |
57 | // ------------- | 61 | // ------------- |
58 | // | 62 | // |
59 | // This file is not part of the Qt API. It exists for the convenience | 63 | // This file is not part of the Qt API. It exists for the convenience |
60 | // of qwellarray.cpp and qcolordialog.cpp. | 64 | // of qwellarray.cpp and qcolordialog.cpp. |
61 | // This header file may change from version to version without notice, | 65 | // This header file may change from version to version without notice, |
62 | // or even be removed. | 66 | // or even be removed. |
63 | // | 67 | // |
64 | // | 68 | // |
65 | 69 | ||
66 | 70 | ||
67 | #include "qtableview.h" | 71 | #include "qtableview.h" |
68 | 72 | ||
69 | 73 | ||
70 | struct QWellArrayData; | 74 | struct QWellArrayData; |
71 | 75 | ||
72 | class QWellArray : public QTableView | 76 | class QWellArray : public QTableView |
73 | { | 77 | { |
74 | Q_OBJECT | 78 | Q_OBJECT |
75 | Q_PROPERTY( int numCols READ numCols ) | 79 | Q_PROPERTY( int numCols READ numCols ) |
76 | Q_PROPERTY( int numRows READ numRows ) | 80 | Q_PROPERTY( int numRows READ numRows ) |
77 | Q_PROPERTY( int selectedColumn READ selectedColumn ) | 81 | Q_PROPERTY( int selectedColumn READ selectedColumn ) |
78 | Q_PROPERTY( int selectedRow READ selectedRow ) | 82 | Q_PROPERTY( int selectedRow READ selectedRow ) |
79 | 83 | ||
80 | public: | 84 | public: |
81 | QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); | 85 | QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); |
82 | 86 | ||
83 | ~QWellArray() {} | 87 | ~QWellArray() {} |
84 | QString cellContent( int row, int col ) const; | 88 | QString cellContent( int row, int col ) const; |
85 | // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); | 89 | // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); |
86 | 90 | ||
87 | // ##### Obsolete since not const | 91 | // ##### Obsolete since not const |
88 | int numCols() { return nCols; } | 92 | int numCols() { return nCols; } |
89 | int numRows() { return nRows; } | 93 | int numRows() { return nRows; } |
90 | 94 | ||
91 | int numCols() const { return nCols; } | 95 | int numCols() const { return nCols; } |
92 | int numRows() const { return nRows; } | 96 | int numRows() const { return nRows; } |
93 | 97 | ||
94 | // ##### Obsolete since not const | 98 | // ##### Obsolete since not const |
95 | int selectedColumn() { return selCol; } | 99 | int selectedColumn() { return selCol; } |
96 | int selectedRow() { return selRow; } | 100 | int selectedRow() { return selRow; } |
97 | 101 | ||
98 | int selectedColumn() const { return selCol; } | 102 | int selectedColumn() const { return selCol; } |
99 | int selectedRow() const { return selRow; } | 103 | int selectedRow() const { return selRow; } |
100 | 104 | ||
101 | virtual void setSelected( int row, int col ); | 105 | virtual void setSelected( int row, int col ); |
102 | 106 | ||
103 | void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } | 107 | void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } |
104 | 108 | ||
105 | QSize sizeHint() const; | 109 | QSize sizeHint() const; |
106 | 110 | ||
107 | virtual void setDimension( int rows, int cols ); | 111 | virtual void setDimension( int rows, int cols ); |
108 | virtual void setCellBrush( int row, int col, const QBrush & ); | 112 | virtual void setCellBrush( int row, int col, const QBrush & ); |
109 | QBrush cellBrush( int row, int col ); | 113 | QBrush cellBrush( int row, int col ); |
110 | 114 | ||
111 | signals: | 115 | signals: |
112 | void selected( int row, int col ); | 116 | void selected( int row, int col ); |
113 | 117 | ||
114 | protected: | 118 | protected: |
115 | virtual void setCurrent( int row, int col ); | 119 | virtual void setCurrent( int row, int col ); |
116 | 120 | ||
117 | virtual void drawContents( QPainter *, int row, int col, const QRect& ); | 121 | virtual void drawContents( QPainter *, int row, int col, const QRect& ); |
118 | void drawContents( QPainter * ); | 122 | void drawContents( QPainter * ); |
119 | 123 | ||
120 | void paintCell( QPainter*, int row, int col ); | 124 | void paintCell( QPainter*, int row, int col ); |
121 | void mousePressEvent( QMouseEvent* ); | 125 | void mousePressEvent( QMouseEvent* ); |
122 | void mouseReleaseEvent( QMouseEvent* ); | 126 | void mouseReleaseEvent( QMouseEvent* ); |
123 | void mouseMoveEvent( QMouseEvent* ); | 127 | void mouseMoveEvent( QMouseEvent* ); |
124 | void keyPressEvent( QKeyEvent* ); | 128 | void keyPressEvent( QKeyEvent* ); |
125 | void focusInEvent( QFocusEvent* ); | 129 | void focusInEvent( QFocusEvent* ); |
126 | void focusOutEvent( QFocusEvent* ); | 130 | void focusOutEvent( QFocusEvent* ); |
127 | 131 | ||
128 | private: | 132 | private: |
129 | int curRow; | 133 | int curRow; |
130 | int curCol; | 134 | int curCol; |
131 | int selRow; | 135 | int selRow; |
132 | int selCol; | 136 | int selCol; |
133 | int nCols; | 137 | int nCols; |
134 | int nRows; | 138 | int nRows; |
135 | bool smallStyle; | 139 | bool smallStyle; |
136 | QWellArrayData *d; | 140 | QWellArrayData *d; |
137 | 141 | ||
138 | private:// Disabled copy constructor and operator= | 142 | private:// Disabled copy constructor and operator= |
139 | #if defined(Q_DISABLE_COPY) | 143 | #if defined(Q_DISABLE_COPY) |
140 | QWellArray( const QWellArray & ); | 144 | QWellArray( const QWellArray & ); |
141 | QWellArray& operator=( const QWellArray & ); | 145 | QWellArray& operator=( const QWellArray & ); |
142 | #endif | 146 | #endif |
143 | }; | 147 | }; |
144 | 148 | ||
145 | 149 | ||
146 | 150 | ||
147 | // non-interface ... | 151 | // non-interface ... |
148 | 152 | ||
149 | 153 | ||
150 | 154 | ||
151 | struct QWellArrayData { | 155 | struct QWellArrayData { |
152 | QBrush *brush; | 156 | QBrush *brush; |
153 | }; | 157 | }; |
154 | 158 | ||
155 | // NOT REVISED | 159 | // NOT REVISED |
156 | /* WARNING, NOT | 160 | /* WARNING, NOT |
157 | \class QWellArray qwellarray_p.h | 161 | \class QWellArray qwellarray_p.h |
158 | \brief .... | 162 | \brief .... |
159 | 163 | ||
160 | .... | 164 | .... |
161 | 165 | ||
162 | \ingroup advanced | 166 | \ingroup advanced |
163 | */ | 167 | */ |
164 | 168 | ||
165 | QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) | 169 | QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) |
166 | : QTableView( parent, name, | 170 | : QTableView( parent, name, |
167 | popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) | 171 | popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) |
168 | { | 172 | { |
169 | d = 0; | 173 | d = 0; |
170 | setFocusPolicy( StrongFocus ); | 174 | setFocusPolicy( StrongFocus ); |
171 | setBackgroundMode( PaletteButton ); | 175 | setBackgroundMode( PaletteButton ); |
172 | nCols = 7; | 176 | nCols = 7; |
173 | nRows = 7; | 177 | nRows = 7; |
174 | int w = 24; // cell width | 178 | int w = 24; // cell width |
175 | int h = 21; // cell height | 179 | int h = 21; // cell height |
176 | smallStyle = popup; | 180 | smallStyle = popup; |
177 | 181 | ||
178 | if ( popup ) { | 182 | if ( popup ) { |
179 | w = h = 18; | 183 | w = h = 18; |
180 | if ( style() == WindowsStyle ) | 184 | if ( style() == WindowsStyle ) |
181 | setFrameStyle( QFrame::WinPanel | QFrame::Raised ); | 185 | setFrameStyle( QFrame::WinPanel | QFrame::Raised ); |
182 | else | 186 | else |
183 | setFrameStyle( QFrame::Panel | QFrame::Raised ); | 187 | setFrameStyle( QFrame::Panel | QFrame::Raised ); |
184 | setMargin( 1 ); | 188 | setMargin( 1 ); |
185 | setLineWidth( 2 ); | 189 | setLineWidth( 2 ); |
186 | } | 190 | } |
187 | setNumCols( nCols ); | 191 | setNumCols( nCols ); |
188 | setNumRows( nRows ); | 192 | setNumRows( nRows ); |
189 | setCellWidth( w ); | 193 | setCellWidth( w ); |
190 | setCellHeight( h ); | 194 | setCellHeight( h ); |
191 | curCol = 0; | 195 | curCol = 0; |
192 | curRow = 0; | 196 | curRow = 0; |
193 | selCol = -1; | 197 | selCol = -1; |
194 | selRow = -1; | 198 | selRow = -1; |
195 | 199 | ||
196 | if ( smallStyle ) | 200 | if ( smallStyle ) |
197 | setMouseTracking( TRUE ); | 201 | setMouseTracking( TRUE ); |
198 | setOffset( 5 , 10 ); | 202 | setOffset( 5 , 10 ); |
199 | 203 | ||
200 | resize( sizeHint() ); | 204 | resize( sizeHint() ); |
201 | 205 | ||
202 | } | 206 | } |
203 | 207 | ||
204 | 208 | ||
205 | QSize QWellArray::sizeHint() const | 209 | QSize QWellArray::sizeHint() const |
206 | { | 210 | { |
207 | constPolish(); | 211 | constPolish(); |
208 | int f = frameWidth() * 2; | 212 | int f = frameWidth() * 2; |
209 | int w = nCols * cellWidth() + f; | 213 | int w = nCols * cellWidth() + f; |
210 | int h = nRows * cellHeight() + f; | 214 | int h = nRows * cellHeight() + f; |
211 | return QSize( w, h ); | 215 | return QSize( w, h ); |
212 | } | 216 | } |
213 | 217 | ||
214 | 218 | ||
215 | void QWellArray::paintCell( QPainter* p, int row, int col ) | 219 | void QWellArray::paintCell( QPainter* p, int row, int col ) |
216 | { | 220 | { |
217 | int w = cellWidth( col ); // width of cell in pixels | 221 | int w = cellWidth( col ); // width of cell in pixels |
218 | int h = cellHeight( row ); // height of cell in pixels | 222 | int h = cellHeight( row ); // height of cell in pixels |
219 | int b = 1; | 223 | int b = 1; |
220 | 224 | ||
221 | if ( !smallStyle ) | 225 | if ( !smallStyle ) |
222 | b = 3; | 226 | b = 3; |
223 | 227 | ||
224 | const QColorGroup & g = colorGroup(); | 228 | const QColorGroup & g = colorGroup(); |
225 | p->setPen( QPen( black, 0, SolidLine ) ); | 229 | p->setPen( QPen( black, 0, SolidLine ) ); |
226 | if ( !smallStyle && row ==selRow && col == selCol && | 230 | if ( !smallStyle && row ==selRow && col == selCol && |
227 | style() != MotifStyle ) { | 231 | style() != MotifStyle ) { |
228 | int n = 2; | 232 | int n = 2; |
229 | p->drawRect( n, n, w-2*n, h-2*n ); | 233 | p->drawRect( n, n, w-2*n, h-2*n ); |
230 | } | 234 | } |
231 | 235 | ||
232 | 236 | ||
233 | if ( style() == WindowsStyle ) { | 237 | if ( style() == WindowsStyle ) { |
234 | qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, | 238 | qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, |
235 | g, TRUE ); | 239 | g, TRUE ); |
236 | b += 2; | 240 | b += 2; |
237 | } else { | 241 | } else { |
238 | if ( smallStyle ) { | 242 | if ( smallStyle ) { |
239 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | 243 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, |
240 | g, TRUE, 2 ); | 244 | g, TRUE, 2 ); |
241 | b += 2; | 245 | b += 2; |
242 | } else { | 246 | } else { |
243 | int t = ( row == selRow && col == selCol ) ? 2 : 0; | 247 | int t = ( row == selRow && col == selCol ) ? 2 : 0; |
244 | b -= t; | 248 | b -= t; |
245 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, | 249 | qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, |
246 | g, TRUE, 2 ); | 250 | g, TRUE, 2 ); |
247 | b += 2 + t; | 251 | b += 2 + t; |
248 | } | 252 | } |
249 | } | 253 | } |
250 | 254 | ||
251 | 255 | ||
252 | if ( (row == curRow) && (col == curCol) ) { | 256 | if ( (row == curRow) && (col == curCol) ) { |
253 | if ( smallStyle ) { | 257 | if ( smallStyle ) { |
254 | p->setPen ( white ); | 258 | p->setPen ( white ); |
255 | p->drawRect( 1, 1, w-2, h-2 ); | 259 | p->drawRect( 1, 1, w-2, h-2 ); |
256 | p->setPen ( black ); | 260 | p->setPen ( black ); |
257 | p->drawRect( 0, 0, w, h ); | 261 | p->drawRect( 0, 0, w, h ); |
258 | p->drawRect( 2, 2, w-4, h-4 ); | 262 | p->drawRect( 2, 2, w-4, h-4 ); |
259 | b = 3; | 263 | b = 3; |
260 | } else if ( hasFocus() ) { | 264 | } else if ( hasFocus() ) { |
261 | style().drawFocusRect(p, QRect(0,0,w,h), g ); | 265 | style().drawFocusRect(p, QRect(0,0,w,h), g ); |
262 | } | 266 | } |
263 | } | 267 | } |
264 | drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); | 268 | drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); |
265 | } | 269 | } |
266 | 270 | ||
267 | /*! | 271 | /*! |
268 | Pass-through to QTableView::drawContents() to avoid hiding. | 272 | Pass-through to QTableView::drawContents() to avoid hiding. |
269 | */ | 273 | */ |
270 | void QWellArray::drawContents( QPainter *p ) | 274 | void QWellArray::drawContents( QPainter *p ) |
271 | { | 275 | { |
272 | QTableView::drawContents(p); | 276 | QTableView::drawContents(p); |
273 | } | 277 | } |
274 | 278 | ||
275 | /*! | 279 | /*! |
276 | Reimplement this function to change the contents of the well array. | 280 | Reimplement this function to change the contents of the well array. |
277 | */ | 281 | */ |
278 | void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) | 282 | void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) |
279 | { | 283 | { |
280 | 284 | ||
281 | if ( d ) { | 285 | if ( d ) { |
282 | p->fillRect( r, d->brush[row*nCols+col] ); | 286 | p->fillRect( r, d->brush[row*nCols+col] ); |
283 | } else { | 287 | } else { |
284 | p->fillRect( r, white ); | 288 | p->fillRect( r, white ); |
285 | p->setPen( black ); | 289 | p->setPen( black ); |
286 | p->drawLine( r.topLeft(), r.bottomRight() ); | 290 | p->drawLine( r.topLeft(), r.bottomRight() ); |
287 | p->drawLine( r.topRight(), r.bottomLeft() ); | 291 | p->drawLine( r.topRight(), r.bottomLeft() ); |
288 | } | 292 | } |
289 | } | 293 | } |
290 | 294 | ||
291 | 295 | ||
292 | /*\reimp | 296 | /*\reimp |
293 | */ | 297 | */ |
294 | void QWellArray::mousePressEvent( QMouseEvent* e ) | 298 | void QWellArray::mousePressEvent( QMouseEvent* e ) |
295 | { | 299 | { |
296 | // The current cell marker is set to the cell the mouse is pressed | 300 | // The current cell marker is set to the cell the mouse is pressed |
297 | // in. | 301 | // in. |
298 | QPoint pos = e->pos(); | 302 | QPoint pos = e->pos(); |
299 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | 303 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); |
300 | } | 304 | } |
301 | 305 | ||
302 | /*\reimp | 306 | /*\reimp |
303 | */ | 307 | */ |
304 | void QWellArray::mouseReleaseEvent( QMouseEvent* ) | 308 | void QWellArray::mouseReleaseEvent( QMouseEvent* ) |
305 | { | 309 | { |
306 | // The current cell marker is set to the cell the mouse is clicked | 310 | // The current cell marker is set to the cell the mouse is clicked |
307 | // in. | 311 | // in. |
308 | setSelected( curRow, curCol ); | 312 | setSelected( curRow, curCol ); |
309 | } | 313 | } |
310 | 314 | ||
311 | 315 | ||
312 | /*\reimp | 316 | /*\reimp |
313 | */ | 317 | */ |
314 | void QWellArray::mouseMoveEvent( QMouseEvent* e ) | 318 | void QWellArray::mouseMoveEvent( QMouseEvent* e ) |
315 | { | 319 | { |
316 | // The current cell marker is set to the cell the mouse is | 320 | // The current cell marker is set to the cell the mouse is |
317 | // clicked in. | 321 | // clicked in. |
318 | if ( smallStyle ) { | 322 | if ( smallStyle ) { |
319 | QPoint pos = e->pos(); | 323 | QPoint pos = e->pos(); |
320 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); | 324 | setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); |
321 | } | 325 | } |
322 | } | 326 | } |
323 | 327 | ||
324 | /* | 328 | /* |
325 | Sets the cell currently having the focus. This is not necessarily | 329 | Sets the cell currently having the focus. This is not necessarily |
326 | the same as the currently selected cell. | 330 | the same as the currently selected cell. |
327 | */ | 331 | */ |
328 | 332 | ||
329 | void QWellArray::setCurrent( int row, int col ) | 333 | void QWellArray::setCurrent( int row, int col ) |
330 | { | 334 | { |
331 | 335 | ||
332 | if ( (curRow == row) && (curCol == col) ) | 336 | if ( (curRow == row) && (curCol == col) ) |
333 | return; | 337 | return; |
334 | 338 | ||
335 | if ( row < 0 || col < 0 ) | 339 | if ( row < 0 || col < 0 ) |
336 | row = col = -1; | 340 | row = col = -1; |
337 | 341 | ||
338 | int oldRow = curRow; | 342 | int oldRow = curRow; |
339 | int oldCol = curCol; | 343 | int oldCol = curCol; |
340 | 344 | ||
341 | curRow = row; | 345 | curRow = row; |
342 | curCol = col; | 346 | curCol = col; |
343 | 347 | ||
344 | updateCell( oldRow, oldCol ); | 348 | updateCell( oldRow, oldCol ); |
345 | updateCell( curRow, curCol ); | 349 | updateCell( curRow, curCol ); |
346 | } | 350 | } |
347 | 351 | ||
348 | 352 | ||
349 | /*! | 353 | /*! |
350 | Sets the currently selected cell to \a row, \a col. If \a row or \a | 354 | Sets the currently selected cell to \a row, \a col. If \a row or \a |
351 | col are less than zero, the current cell is unselected. | 355 | col are less than zero, the current cell is unselected. |
352 | 356 | ||
353 | Does not set the position of the focus indicator. | 357 | Does not set the position of the focus indicator. |
354 | */ | 358 | */ |
355 | 359 | ||
356 | void QWellArray::setSelected( int row, int col ) | 360 | void QWellArray::setSelected( int row, int col ) |
357 | { | 361 | { |
358 | if ( (selRow == row) && (selCol == col) ) | 362 | if ( (selRow == row) && (selCol == col) ) |
359 | return; | 363 | return; |
360 | 364 | ||
361 | int oldRow = selRow; | 365 | int oldRow = selRow; |
362 | int oldCol = selCol; | 366 | int oldCol = selCol; |
363 | 367 | ||
364 | if ( row < 0 || col < 0 ) | 368 | if ( row < 0 || col < 0 ) |
365 | row = col = -1; | 369 | row = col = -1; |
366 | 370 | ||
367 | selCol = col; | 371 | selCol = col; |
368 | selRow = row; | 372 | selRow = row; |
369 | 373 | ||
370 | updateCell( oldRow, oldCol ); | 374 | updateCell( oldRow, oldCol ); |
371 | updateCell( selRow, selCol ); | 375 | updateCell( selRow, selCol ); |
372 | if ( row >= 0 ) | 376 | if ( row >= 0 ) |
373 | emit selected( row, col ); | 377 | emit selected( row, col ); |
374 | 378 | ||
375 | if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) | 379 | if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) |
376 | parentWidget()->close(); | 380 | parentWidget()->close(); |
377 | 381 | ||
378 | } | 382 | } |
379 | 383 | ||
380 | 384 | ||
381 | 385 | ||
382 | /*!\reimp | 386 | /*!\reimp |
383 | */ | 387 | */ |
384 | void QWellArray::focusInEvent( QFocusEvent* ) | 388 | void QWellArray::focusInEvent( QFocusEvent* ) |
385 | { | 389 | { |
386 | updateCell( curRow, curCol ); | 390 | updateCell( curRow, curCol ); |
387 | } | 391 | } |
388 | 392 | ||
389 | 393 | ||
390 | /*! | 394 | /*! |
391 | Sets the size of the well array to be \c rows cells by \c cols. | 395 | Sets the size of the well array to be \c rows cells by \c cols. |
392 | Resets any brush info set by setCellBrush(). | 396 | Resets any brush info set by setCellBrush(). |
393 | 397 | ||
394 | Must be called by reimplementors. | 398 | Must be called by reimplementors. |
395 | */ | 399 | */ |
396 | void QWellArray::setDimension( int rows, int cols ) | 400 | void QWellArray::setDimension( int rows, int cols ) |
397 | { | 401 | { |
398 | nRows = rows; | 402 | nRows = rows; |
399 | nCols = cols; | 403 | nCols = cols; |
400 | if ( d ) { | 404 | if ( d ) { |
401 | if ( d->brush ) | 405 | if ( d->brush ) |
402 | delete[] d->brush; | 406 | delete[] d->brush; |
403 | delete d; | 407 | delete d; |
404 | d = 0; | 408 | d = 0; |
405 | } | 409 | } |
406 | setNumCols( nCols ); | 410 | setNumCols( nCols ); |
407 | setNumRows( nRows ); | 411 | setNumRows( nRows ); |
408 | } | 412 | } |
409 | 413 | ||
410 | void QWellArray::setCellBrush( int row, int col, const QBrush &b ) | 414 | void QWellArray::setCellBrush( int row, int col, const QBrush &b ) |
411 | { | 415 | { |
412 | if ( !d ) { | 416 | if ( !d ) { |
413 | d = new QWellArrayData; | 417 | d = new QWellArrayData; |
414 | d->brush = new QBrush[nRows*nCols]; | 418 | d->brush = new QBrush[nRows*nCols]; |
415 | } | 419 | } |
416 | if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) | 420 | if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) |
417 | d->brush[row*nCols+col] = b; | 421 | d->brush[row*nCols+col] = b; |
418 | #ifdef CHECK_RANGE | 422 | #ifdef CHECK_RANGE |
419 | else | 423 | else |
420 | qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); | 424 | qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); |
421 | #endif | 425 | #endif |
422 | } | 426 | } |
423 | 427 | ||
424 | 428 | ||
425 | 429 | ||
426 | /*! | 430 | /*! |
427 | Returns the brush set for the cell at \a row, \a col. If no brush is set, | 431 | Returns the brush set for the cell at \a row, \a col. If no brush is set, |
428 | \c NoBrush is returned. | 432 | \c NoBrush is returned. |
429 | */ | 433 | */ |
430 | 434 | ||
431 | QBrush QWellArray::cellBrush( int row, int col ) | 435 | QBrush QWellArray::cellBrush( int row, int col ) |
432 | { | 436 | { |
433 | if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) | 437 | if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) |
434 | return d->brush[row*nCols+col]; | 438 | return d->brush[row*nCols+col]; |
435 | return NoBrush; | 439 | return NoBrush; |
436 | } | 440 | } |
437 | 441 | ||
438 | 442 | ||