~ubuntu-branches/ubuntu/maverick/datakiosk/maverick

« back to all changes in this revision

Viewing changes to src/datakiosk/src/formlayout.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-06-27 22:48:06 UTC
  • Revision ID: james.westby@ubuntu.com-20050627224806-8farkci1dc2onhbs
Tags: upstream-0.7
ImportĀ upstreamĀ versionĀ 0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   Copyright (C) 2005 by Adam Treat                                      *
 
3
*   treat@kde.org                                                         *
 
4
*                                                                         *
 
5
*   This program is free software; you can redistribute it and/or modify  *
 
6
*   it under the terms of the GNU General Public License as published by  *
 
7
*   the Free Software Foundation; either version 2 of the License, or     *
 
8
*   (at your option) any later version.                                   *
 
9
*                                                                         *
 
10
***************************************************************************/
 
11
 
 
12
#ifndef FORMLAYOUT_H
 
13
#define FORMLAYOUT_H
 
14
 
 
15
#include <qlayout.h>
 
16
#include <qptrlist.h>
 
17
 
 
18
class QRect;
 
19
 
 
20
class FormLayoutIterator : public QGLayoutIterator
 
21
{
 
22
public:
 
23
    FormLayoutIterator( QPtrList<QLayoutItem> *l )
 
24
            : idx( 0 ), m_itemList( l )
 
25
    {}
 
26
 
 
27
    QLayoutItem *current()
 
28
    {
 
29
        return idx < int( m_itemList->count() ) ? m_itemList->at( idx ) : 0;
 
30
    }
 
31
 
 
32
    QLayoutItem *next()
 
33
    {
 
34
        idx++;
 
35
        return current();
 
36
    }
 
37
 
 
38
    QLayoutItem *takeCurrent()
 
39
    {
 
40
        return m_itemList->take( idx );
 
41
    }
 
42
 
 
43
private:
 
44
    int idx;
 
45
    QPtrList<QLayoutItem> *m_itemList;
 
46
};
 
47
 
 
48
class FormLayout : public QLayout
 
49
{
 
50
    Q_OBJECT
 
51
public:
 
52
    FormLayout( QWidget *parent, int margin = 0, int spacing = -1 );
 
53
    FormLayout( QLayout *parent, int spacing );
 
54
    FormLayout( int spacing );
 
55
    ~FormLayout();
 
56
 
 
57
    virtual void addItem( QLayoutItem *item );
 
58
    virtual QSizePolicy::ExpandData expanding() const;
 
59
    virtual bool hasHeightForWidth() const;
 
60
    virtual int heightForWidth( int ) const;
 
61
    virtual QSize minimumSize() const;
 
62
    virtual QSize sizeHint() const;
 
63
    virtual QLayoutIterator iterator();
 
64
    virtual bool isEmpty() const;
 
65
 
 
66
public slots:
 
67
    void slotCalculateItemSize();
 
68
 
 
69
protected:
 
70
    virtual void setGeometry( const QRect &rect );
 
71
 
 
72
private:
 
73
    int doLayout( const QRect &rect, bool testOnly ) const;
 
74
 
 
75
    QPtrList<QLayoutItem> m_itemList;
 
76
    int m_itemWidth;
 
77
    int m_itemHeight;
 
78
    int m_width;
 
79
};
 
80
 
 
81
#endif