summaryrefslogtreecommitdiffstats
path: root/kmrml/kmrml/propertysheet.h
blob: 2e20cb85d40d0d47a0d656989c91b69427b556f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* This file is part of the KDE project
   Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation, version 2.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef PROPERTYSHEET_H
#define PROPERTYSHEET_H

#include <tqdom.h>
#include <tqstring.h>
#include <tqptrlist.h>

class TQWidget;

namespace KMrml
{
    class PropertySheet
    {
    public:
        enum Type
        {
            MultiSet = 1,       // ??
            Subset,             // radio-button/combobox or listbox
            SetElement,         // CheckBox -> disables/enables tqchildren?
            Boolean,            // CheckBox
            Numeric,            // Slider/Spinbox
            Textual,            // lineedit
            Panel,              // groupbox?
            Clone,
            Reference
        };
        enum Visibility
        {
            Visible,
            Invisible,
            Popup
        };
        enum SendType
        {
            Element = 1,
            Attribute,
            AttributeName,
            AttributeValue,
            Children,
            None
        };

        PropertySheet();
        PropertySheet( const TQDomElement& elem );
        PropertySheet( const PropertySheet& ps );
        ~PropertySheet() {};

        PropertySheet& operator=( const PropertySheet& ps );

        bool isValid() const {
            // required mrml attributes
            return !m_id.isNull() && m_type != 0 && m_sendType != 0;
        }
        void initFromDOM( const TQDomElement& elem );

        void toElement( TQDomElement& parent );

        TQWidget * createWidget( TQWidget *parent, const char *name = 0 );

    private:
        static Visibility getVisibility( const TQString& value );
        static Type getType( const TQString& value );
        static SendType getSendType( const TQString& value );
        static int toInt( const TQString& value, int defaultValue = 0 );

        void init();


        // update operator=() when adding data members!

        TQPtrList<PropertySheet> m_subSheets;
        Visibility m_visibility;
        Type m_type;
        TQString m_caption;
        TQString m_id;

        SendType m_sendType;
        TQString m_sendName;
        TQString m_sendValue;

        int m_minRange;
        int m_maxRange;
        int m_stepSize;

        // Type = Subset && m_minSubsetSize == m_maxSubsetSize == 1 -> Combobox
        // or radio buttons.
        // > max > 1  -> Listbox with multiselection
        int m_minSubsetSize;
        int m_maxSubsetSize;

    };

}

#endif // PROPERTYSHEET_H