summaryrefslogtreecommitdiffstats
path: root/lib/koproperty/editors/cursoredit.cpp
blob: 5ff0bb34f8b1ca01933eb8c09b2e252512f73219 (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* This file is part of the KDE project
   Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
   Copyright (C) 2004  Alexander Dymo <cloudtemple@mskat.net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

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

#include "cursoredit.h"

#include <tqmap.h>
#include <tqvariant.h>
#include <tqcursor.h>

#include <klocale.h>
#include <kdebug.h>

#include "property.h"

using namespace KoProperty;

//TQMap<TQString, TQVariant> *CursorEdit::m_spValues = 0;
Property::ListData *m_cursorListData = 0;


CursorEdit::CursorEdit(Property *property, TQWidget *parent, const char *name)
: ComboBox(property, parent, name)
{
	/*
	if(!m_spValues) {
		m_spValues = new TQMap<TQString, TQVariant>();
		(*m_spValues)[i18n("Arrow")] = TQt::ArrowCursor;
		(*m_spValues)[i18n("Up Arrow")] = TQt::UpArrowCursor;
		(*m_spValues)[i18n("Cross")] = TQt::CrossCursor;
		(*m_spValues)[i18n("Waiting")] = TQt::WaitCursor;
		(*m_spValues)[i18n("iBeam")] = TQt::IbeamCursor;
		(*m_spValues)[i18n("SizeQt::Vertical")] = TQt::SizeVerCursor;
		(*m_spValues)[i18n("SizeQt::Horizontal")] = TQt::SizeHorCursor;
		(*m_spValues)[i18n("Size Slash")] = TQt::SizeBDiagCursor;
		(*m_spValues)[i18n("Size Backslash")] = TQt::SizeFDiagCursor;
		(*m_spValues)[i18n("Size All")] = TQt::SizeAllCursor;
		(*m_spValues)[i18n("Blank")] = TQt::BlankCursor;
		(*m_spValues)[i18n("SplitQt::Vertical")] = TQt::SplitVCursor;
		(*m_spValues)[i18n("SplitQt::Horizontal")] = TQt::SplitHCursor;
		(*m_spValues)[i18n("Pointing Hand")] = TQt::PointingHandCursor;
		(*m_spValues)[i18n("Forbidden")] = TQt::ForbiddenCursor;
		(*m_spValues)[i18n("What's this")] = TQt::WhatsThisCursor;
	}*/

//! @todo NOT THREAD-SAFE
	if (!m_cursorListData) {
		TQValueList<TQVariant> keys;
		keys 
			<< TQt::BlankCursor
			<< TQt::ArrowCursor
			<< TQt::UpArrowCursor
			<< TQt::CrossCursor
			<< TQt::WaitCursor
			<< TQt::IbeamCursor
			<< TQt::SizeVerCursor
			<< TQt::SizeHorCursor
			<< TQt::SizeBDiagCursor
			<< TQt::SizeFDiagCursor
			<< TQt::SizeAllCursor
			<< TQt::SplitVCursor
			<< TQt::SplitHCursor
			<< TQt::PointingHandCursor
			<< TQt::ForbiddenCursor
			<< TQt::WhatsThisCursor;
		TQStringList strings;
		strings << i18n("Mouse Cursor Shape", "No Cursor")
			<< i18n("Mouse Cursor Shape", "Arrow")
			<< i18n("Mouse Cursor Shape", "Up Arrow")
			<< i18n("Mouse Cursor Shape", "Cross")
			<< i18n("Mouse Cursor Shape", "Waiting")
			<< i18n("Mouse Cursor Shape", "I")
			<< i18n("Mouse Cursor Shape", "SizeQt::Vertical")
			<< i18n("Mouse Cursor Shape", "SizeQt::Horizontal")
			<< i18n("Mouse Cursor Shape", "Size Slash")
			<< i18n("Mouse Cursor Shape", "Size Backslash")
			<< i18n("Mouse Cursor Shape", "Size All")
			<< i18n("Mouse Cursor Shape", "SplitQt::Vertical")
			<< i18n("Mouse Cursor Shape", "SplitQt::Horizontal")
			<< i18n("Mouse Cursor Shape", "Pointing Hand")
			<< i18n("Mouse Cursor Shape", "Forbidden")
			<< i18n("Mouse Cursor Shape", "What's This?");
		m_cursorListData = new Property::ListData(keys, strings);
	}

	if(property)
		property->setListData(new Property::ListData(*m_cursorListData));
}

CursorEdit::~CursorEdit()
{
	delete m_cursorListData;
	m_cursorListData = 0;
}

TQVariant
CursorEdit::value() const
{
	return TQCursor(ComboBox::value().toInt());
}

void
CursorEdit::setValue(const TQVariant &value, bool emitChange)
{
	ComboBox::setValue(value.toCursor().shape(), emitChange);
}

void
CursorEdit::drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
{
	ComboBox::drawViewer(p, cg, r, value.toCursor().shape());
}

void
CursorEdit::setProperty(Property *prop)
{
	if(prop && prop != property())
		prop->setListData(new Property::ListData(*m_cursorListData));
	ComboBox::setProperty(prop);
}

#include "cursoredit.moc"