source: trunk/doc/html/qlistbox-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qlistbox.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qlistbox.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qlistbox.h</h1>
33
34<p>This is the verbatim text of the qlistbox.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/**********************************************************************
38** $Id: qlistbox-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QListBox widget class
41**
42** Created : 941121
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the widgets module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QLISTBOX_H
75#define QLISTBOX_H
76
77#ifndef QT_H
78#include "qscrollview.h"
79#include "qpixmap.h"
80#endif // QT_H
81
82#ifndef QT_NO_LISTBOX
83
84
85class QListBoxPrivate;
86class QListBoxItem;
87class QString;
88class QStrList;
89class QStringList;
90
91
92class Q_EXPORT QListBox : public QScrollView
93{
94 friend class QListBoxItem;
95 friend class QListBoxPrivate;
96
97 Q_OBJECT
98 Q_ENUMS( SelectionMode LayoutMode )
99 Q_PROPERTY( uint count READ count )
100 Q_PROPERTY( int numItemsVisible READ numItemsVisible )
101 Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
102 Q_PROPERTY( QString currentText READ currentText )
103 Q_PROPERTY( int topItem READ topItem WRITE setTopItem DESIGNABLE false )
104 Q_PROPERTY( SelectionMode selectionMode READ selectionMode WRITE setSelectionMode )
105 Q_PROPERTY( bool multiSelection READ isMultiSelection WRITE setMultiSelection DESIGNABLE false )
106 Q_PROPERTY( LayoutMode columnMode READ columnMode WRITE setColumnMode )
107 Q_PROPERTY( LayoutMode rowMode READ rowMode WRITE setRowMode )
108 Q_PROPERTY( int numColumns READ numColumns )
109 Q_PROPERTY( int numRows READ numRows )
110 Q_PROPERTY( bool variableWidth READ variableWidth WRITE setVariableWidth )
111 Q_PROPERTY( bool variableHeight READ variableHeight WRITE setVariableHeight )
112
113public:
114 QListBox( QWidget* parent=0, const char* name=0, WFlags f=0 );
115 ~QListBox();
116
117 virtual void setFont( const QFont &amp; );
118
119 uint count() const;
120
121 void insertStringList( const QStringList&amp;, int index=-1 );
122 void insertStrList( const QStrList *, int index=-1 );
123 void insertStrList( const QStrList &amp;, int index=-1 );
124 void insertStrList( const char **,
125 int numStrings=-1, int index=-1 );
126
127 void insertItem( const QListBoxItem *, int index=-1 );
128 void insertItem( const QListBoxItem *, const QListBoxItem *after );
129 void insertItem( const QString &amp;text, int index=-1 );
130 void insertItem( const QPixmap &amp;pixmap, int index=-1 );
131 void insertItem( const QPixmap &amp;pixmap, const QString &amp;text, int index=-1 );
132
133 void removeItem( int index );
134
135 QString text( int index ) const;
136 const QPixmap *pixmap( int index ) const;
137
138 void changeItem( const QListBoxItem *, int index );
139 void changeItem( const QString &amp;text, int index );
140 void changeItem( const QPixmap &amp;pixmap, int index );
141 void changeItem( const QPixmap &amp;pixmap, const QString &amp;text, int index );
142
143 void takeItem( const QListBoxItem * );
144
145 int numItemsVisible() const;
146
147 int currentItem() const;
148 QString currentText() const { return text(currentItem()); }
149 virtual void setCurrentItem( int index );
150 virtual void setCurrentItem( QListBoxItem * );
151 void centerCurrentItem() { ensureCurrentVisible(); }
152 int topItem() const;
153 virtual void setTopItem( int index );
154 virtual void setBottomItem( int index );
155
156 long maxItemWidth() const;
157
158 enum SelectionMode { Single, Multi, Extended, NoSelection };
159 virtual void setSelectionMode( SelectionMode );
160 SelectionMode selectionMode() const;
161
162 void setMultiSelection( bool multi );
163 bool isMultiSelection() const;
164
165 virtual void setSelected( QListBoxItem *, bool );
166 void setSelected( int, bool );
167 bool isSelected( int ) const;
168 bool isSelected( const QListBoxItem * ) const;
169 QListBoxItem* selectedItem() const;
170
171 QSize sizeHint() const;
172 QSize minimumSizeHint() const;
173
174 QListBoxItem *item( int index ) const;
175 int index( const QListBoxItem * ) const;
176 QListBoxItem *findItem( const QString &amp;text, ComparisonFlags compare = BeginsWith ) const;
177
178 void triggerUpdate( bool doLayout );
179
180 bool itemVisible( int index );
181 bool itemVisible( const QListBoxItem * );
182
183 enum LayoutMode { FixedNumber,
184 FitToWidth, FitToHeight = FitToWidth,
185 Variable };
186 virtual void setColumnMode( LayoutMode );
187 virtual void setColumnMode( int );
188 virtual void setRowMode( LayoutMode );
189 virtual void setRowMode( int );
190
191 LayoutMode columnMode() const;
192 LayoutMode rowMode() const;
193
194 int numColumns() const;
195 int numRows() const;
196
197 bool variableWidth() const;
198 virtual void setVariableWidth( bool );
199
200 bool variableHeight() const;
201 virtual void setVariableHeight( bool );
202
203 void viewportPaintEvent( QPaintEvent * );
204
205#ifndef QT_NO_COMPAT
206 bool dragSelect() const { return TRUE; }
207 void setDragSelect( bool ) {}
208 bool autoScroll() const { return TRUE; }
209 void setAutoScroll( bool ) {}
210 bool autoScrollBar() const { return vScrollBarMode() == Auto; }
211 void setAutoScrollBar( bool enable ) { setVScrollBarMode( enable ? Auto : AlwaysOff ); }
212 bool scrollBar() const { return vScrollBarMode() != AlwaysOff; }
213 void setScrollBar( bool enable ) { setVScrollBarMode( enable ? AlwaysOn : AlwaysOff ); }
214 bool autoBottomScrollBar() const { return hScrollBarMode() == Auto; }
215 void setAutoBottomScrollBar( bool enable ) { setHScrollBarMode( enable ? Auto : AlwaysOff ); }
216 bool bottomScrollBar() const { return hScrollBarMode() != AlwaysOff; }
217 void setBottomScrollBar( bool enable ) { setHScrollBarMode( enable ? AlwaysOn : AlwaysOff ); }
218 bool smoothScrolling() const { return FALSE; }
219 void setSmoothScrolling( bool ) {}
220 bool autoUpdate() const { return TRUE; }
221 void setAutoUpdate( bool ) {}
222 void setFixedVisibleLines( int lines ) { setRowMode( lines ); }
223 int inSort( const QListBoxItem * );
224 int inSort( const QString&amp; text );
225 int cellHeight( int i ) const { return itemHeight(i); }
226 int cellHeight() const { return itemHeight(); }
227 int cellWidth() const { return maxItemWidth(); }
228 int cellWidth(int i) const { Q_ASSERT(i==0); Q_UNUSED(i) return maxItemWidth(); }
229 int numCols() const { return numColumns(); }
230#endif
231
232 int itemHeight( int index = 0 ) const;
233 QListBoxItem * itemAt( const QPoint &amp; ) const;
234
235 QRect itemRect( QListBoxItem *item ) const;
236
237 QListBoxItem *firstItem() const;
238
239 void sort( bool ascending = TRUE );
240
241public slots:
242 void clear();
243 virtual void ensureCurrentVisible();
244 virtual void clearSelection();
245 virtual void selectAll( bool select );
246 virtual void invertSelection();
247
248signals:
249 void highlighted( int index );
250 void selected( int index );
251 void highlighted( const QString &amp;);
252 void selected( const QString &amp;);
253 void highlighted( QListBoxItem * );
254 void selected( QListBoxItem * );
255
256 void selectionChanged();
257 void selectionChanged( QListBoxItem * );
258 void currentChanged( QListBoxItem * );
259 void clicked( QListBoxItem * );
260 void clicked( QListBoxItem *, const QPoint &amp; );
261 void pressed( QListBoxItem * );
262 void pressed( QListBoxItem *, const QPoint &amp; );
263
264 void doubleClicked( QListBoxItem * );
265 void returnPressed( QListBoxItem * );
266 void rightButtonClicked( QListBoxItem *, const QPoint &amp; );
267 void rightButtonPressed( QListBoxItem *, const QPoint &amp; );
268 void mouseButtonPressed( int, QListBoxItem*, const QPoint&amp; );
269 void mouseButtonClicked( int, QListBoxItem*, const QPoint&amp; );
270
271 void contextMenuRequested( QListBoxItem *, const QPoint &amp; );
272
273 void onItem( QListBoxItem *item );
274 void onViewport();
275
276protected:
277 void mousePressEvent( QMouseEvent * );
278 void mouseReleaseEvent( QMouseEvent * );
279 void mouseDoubleClickEvent( QMouseEvent * );
280 void mouseMoveEvent( QMouseEvent * );
281 void contentsContextMenuEvent( QContextMenuEvent * );
282
283 void keyPressEvent( QKeyEvent *e );
284 void focusInEvent( QFocusEvent *e );
285 void focusOutEvent( QFocusEvent *e );
286 void resizeEvent( QResizeEvent * );
287 void showEvent( QShowEvent * );
288
289 bool eventFilter( QObject *o, QEvent *e );
290
291 void updateItem( int index );
292 void updateItem( QListBoxItem * );
293
294#ifndef QT_NO_COMPAT
295 void updateCellWidth() { }
296 int totalWidth() const { return contentsWidth(); }
297 int totalHeight() const { return contentsHeight(); }
298#endif
299
300 virtual void paintCell( QPainter *, int row, int col );
301
302 void toggleCurrentItem();
303 bool isRubberSelecting() const;
304
305 void doLayout() const;
306
307 void windowActivationChange( bool );
308
309#ifndef QT_NO_COMPAT
310 bool itemYPos( int index, int *yPos ) const;
311 int findItem( int yPos ) const { return index(itemAt(QPoint(0,yPos)) ); }
312#endif
313
314protected slots:
315 void clearInputString();
316
317private slots:
318 void refreshSlot();
319 void doAutoScroll();
320 void adjustItems();
321
322private:
323 void mousePressEventEx( QMouseEvent * );
324 void tryGeometry( int, int ) const;
325 int currentRow() const;
326 int currentColumn() const;
327 void updateSelection();
328 void repaintSelection();
329 void drawRubber();
330 void doRubberSelection( const QRect &amp;old, const QRect &amp;rubber );
331 void handleItemChange( QListBoxItem *old, bool shift, bool control );
332 void selectRange( QListBoxItem *from, QListBoxItem *to, bool invert, bool includeFirst, bool clearSel = FALSE );
333
334 void emitChangedSignal( bool );
335
336 int columnAt( int ) const;
337 int rowAt( int ) const;
338
339 QListBoxPrivate * d;
340
341 static QListBox * changedListBox;
342
343private: // Disabled copy constructor and operator=
344#if defined(Q_DISABLE_COPY)
345 QListBox( const QListBox &amp; );
346 QListBox &amp;operator=( const QListBox &amp; );
347#endif
348};
349
350
351class Q_EXPORT QListBoxItem
352{
353public:
354 QListBoxItem( QListBox* listbox = 0 );
355 QListBoxItem( QListBox* listbox, QListBoxItem *after );
356 virtual ~QListBoxItem();
357
358 virtual QString text() const;
359 virtual const QPixmap *pixmap() const;
360
361 virtual int height( const QListBox * ) const;
362 virtual int width( const QListBox * ) const;
363
364 bool isSelected() const { return s; }
365 bool isCurrent() const;
366
367#ifndef QT_NO_COMPAT
368 bool selected() const { return isSelected(); }
369 bool current() const { return isCurrent(); }
370#endif
371
372 QListBox *listBox() const;
373
374 void setSelectable( bool b );
375 bool isSelectable() const;
376
377 QListBoxItem *next() const;
378 QListBoxItem *prev() const;
379
380 virtual int rtti() const;
381 static int RTTI;
382
383protected:
384 virtual void paint( QPainter * ) = 0;
385 virtual void setText( const QString &amp;text ) { txt = text; }
386 void setCustomHighlighting( bool );
387
388private:
389 QString txt;
390 uint s:1;
391 uint dirty:1;
392 uint custom_highlight : 1;
393 int x, y;
394 QListBoxItem * p, * n;
395 QListBox* lbox;
396 friend class QListBox;
397 friend class QListBoxPrivate;
398 friend class QComboBox;
399 friend class QComboBoxPopupItem;
400
401private: // Disabled copy constructor and operator=
402#if defined(Q_DISABLE_COPY)
403 QListBoxItem( const QListBoxItem &amp; );
404 QListBoxItem &amp;operator=( const QListBoxItem &amp; );
405#endif
406};
407
408
409class Q_EXPORT QListBoxText : public QListBoxItem
410{
411public:
412 QListBoxText( QListBox* listbox, const QString &amp; text=QString::null );
413 QListBoxText( const QString &amp; text=QString::null );
414 QListBoxText( QListBox* listbox, const QString &amp; text, QListBoxItem *after );
415 ~QListBoxText();
416
417 int height( const QListBox * ) const;
418 int width( const QListBox * ) const;
419
420 int rtti() const;
421 static int RTTI;
422
423protected:
424 void paint( QPainter * );
425
426private: // Disabled copy constructor and operator=
427#if defined(Q_DISABLE_COPY)
428 QListBoxText( const QListBoxText &amp; );
429 QListBoxText &amp;operator=( const QListBoxText &amp; );
430#endif
431};
432
433
434class Q_EXPORT QListBoxPixmap : public QListBoxItem
435{
436public:
437 QListBoxPixmap( QListBox* listbox, const QPixmap &amp; );
438 QListBoxPixmap( const QPixmap &amp; );
439 QListBoxPixmap( QListBox* listbox, const QPixmap &amp; pix, QListBoxItem *after );
440 QListBoxPixmap( QListBox* listbox, const QPixmap &amp;, const QString&amp; );
441 QListBoxPixmap( const QPixmap &amp;, const QString&amp; );
442 QListBoxPixmap( QListBox* listbox, const QPixmap &amp; pix, const QString&amp;, QListBoxItem *after );
443 ~QListBoxPixmap();
444
445 const QPixmap *pixmap() const { return &amp;pm; }
446
447 int height( const QListBox * ) const;
448 int width( const QListBox * ) const;
449
450 int rtti() const;
451 static int RTTI;
452
453protected:
454 void paint( QPainter * );
455
456private:
457 QPixmap pm;
458private: // Disabled copy constructor and operator=
459#if defined(Q_DISABLE_COPY)
460 QListBoxPixmap( const QListBoxPixmap &amp; );
461 QListBoxPixmap &amp;operator=( const QListBoxPixmap &amp; );
462#endif
463};
464
465
466#endif // QT_NO_LISTBOX
467
468#endif // QLISTBOX_H
469</pre>
470<!-- eof -->
471<p><address><hr><div align=center>
472<table width=100% cellspacing=0 border=0><tr>
473<td>Copyright &copy; 2007
474<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
475<td align=right><div align=right>Qt 3.3.8</div>
476</table></div></address></body>
477</html>
Note: See TracBrowser for help on using the repository browser.