cursoredit.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <tqmap.h>
22#include <tqvariant.h>
23#include <tqcursor.h>
24
25#include <tdelocale.h>
26#include <kdebug.h>
27
28#include "cursoredit.h"
29#include "property.h"
30
31using namespace KoProperty;
32
33//TQStringVariantMap *CursorEdit::m_spValues = 0;
34Property::ListData *m_cursorListData = 0;
35
36
37CursorEdit::CursorEdit(Property *property, TQWidget *parent, const char *name)
38: ComboBox(property, parent, name)
39{
40 /*
41 if(!m_spValues) {
42 m_spValues = new TQStringVariantMap();
43 (*m_spValues)[i18n("Arrow")] = TQt::ArrowCursor;
44 (*m_spValues)[i18n("Up Arrow")] = TQt::UpArrowCursor;
45 (*m_spValues)[i18n("Cross")] = TQt::CrossCursor;
46 (*m_spValues)[i18n("Waiting")] = TQt::WaitCursor;
47 (*m_spValues)[i18n("iBeam")] = TQt::IbeamCursor;
48 (*m_spValues)[i18n("Size Vertical")] = TQt::SizeVerCursor;
49 (*m_spValues)[i18n("Size Horizontal")] = TQt::SizeHorCursor;
50 (*m_spValues)[i18n("Size Slash")] = TQt::SizeBDiagCursor;
51 (*m_spValues)[i18n("Size Backslash")] = TQt::SizeFDiagCursor;
52 (*m_spValues)[i18n("Size All")] = TQt::SizeAllCursor;
53 (*m_spValues)[i18n("Blank")] = TQt::BlankCursor;
54 (*m_spValues)[i18n("Split Vertical")] = TQt::SplitVCursor;
55 (*m_spValues)[i18n("Split Horizontal")] = TQt::SplitHCursor;
56 (*m_spValues)[i18n("Pointing Hand")] = TQt::PointingHandCursor;
57 (*m_spValues)[i18n("Forbidden")] = TQt::ForbiddenCursor;
58 (*m_spValues)[i18n("What's this")] = TQt::WhatsThisCursor;
59 }*/
60
62 if (!m_cursorListData) {
63 TQValueList<TQVariant> keys;
64 keys
65 << TQt::BlankCursor
66 << TQt::ArrowCursor
67 << TQt::UpArrowCursor
68 << TQt::CrossCursor
69 << TQt::WaitCursor
70 << TQt::IbeamCursor
71 << TQt::SizeVerCursor
72 << TQt::SizeHorCursor
73 << TQt::SizeBDiagCursor
74 << TQt::SizeFDiagCursor
75 << TQt::SizeAllCursor
76 << TQt::SplitVCursor
77 << TQt::SplitHCursor
78 << TQt::PointingHandCursor
79 << TQt::ForbiddenCursor
80 << TQt::WhatsThisCursor;
81 TQStringList strings;
82 strings << i18n("Mouse Cursor Shape", "No Cursor")
83 << i18n("Mouse Cursor Shape", "Arrow")
84 << i18n("Mouse Cursor Shape", "Up Arrow")
85 << i18n("Mouse Cursor Shape", "Cross")
86 << i18n("Mouse Cursor Shape", "Waiting")
87 << i18n("Mouse Cursor Shape", "I")
88 << i18n("Mouse Cursor Shape", "Size Vertical")
89 << i18n("Mouse Cursor Shape", "Size Horizontal")
90 << i18n("Mouse Cursor Shape", "Size Slash")
91 << i18n("Mouse Cursor Shape", "Size Backslash")
92 << i18n("Mouse Cursor Shape", "Size All")
93 << i18n("Mouse Cursor Shape", "Split Vertical")
94 << i18n("Mouse Cursor Shape", "Split Horizontal")
95 << i18n("Mouse Cursor Shape", "Pointing Hand")
96 << i18n("Mouse Cursor Shape", "Forbidden")
97 << i18n("Mouse Cursor Shape", "What's This?");
98 m_cursorListData = new Property::ListData(keys, strings);
99 }
100
101 if(property)
102 property->setListData(new Property::ListData(*m_cursorListData));
103}
104
105CursorEdit::~CursorEdit()
106{
107 delete m_cursorListData;
108 m_cursorListData = 0;
109}
110
111TQVariant
112CursorEdit::value() const
113{
114 return TQCursor(ComboBox::value().toInt());
115}
116
117void
118CursorEdit::setValue(const TQVariant &value, bool emitChange)
119{
120 ComboBox::setValue(value.toCursor().shape(), emitChange);
121}
122
123void
124CursorEdit::drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
125{
126 ComboBox::drawViewer(p, cg, r, value.toCursor().shape());
127}
128
129void
130CursorEdit::setProperty(Property *prop)
131{
132 if(prop && prop != property())
133 prop->setListData(new Property::ListData(*m_cursorListData));
134 ComboBox::setProperty(prop);
135}
136
137#include "cursoredit.moc"
The base class representing a single property.
Definition property.h:177
void setListData(ListData *list)
Definition property.cpp:434
const char * name(StdAction id)
Namespace for a set of classes implementing generic properties framework.