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
|
/***************************************************************************
tableitem.cpp - description
-------------------
begin : Mon 15 Mar 2004
copyright : (C) 2004 by Michal Rudolf <mrudolf@kdewebdev.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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tqtextedit.h>
#include <tqpainter.h>
#include "tableitem.h"
TableItem::TableItem(TQTable* table, EditType et) : TQTableItem(table, et)
{
setReplaceable(false);
m_halign = TQt::AlignLeft;
m_valign = TQt::AlignVCenter;
}
TableItem::TableItem(TQTable* table, EditType et, const TQString& text) : TQTableItem(table, et, text)
{
setReplaceable(false);
m_halign = TQt::AlignLeft;
m_valign = TQt::AlignVCenter;
}
TableItem::TableItem (TQTable* table, EditType et, const TQString& text, const TQPixmap& p) :
TQTableItem(table, et, text, p)
{
setReplaceable(false);
m_halign = TQt::AlignLeft;
m_valign = TQt::AlignVCenter;
}
TQWidget* TableItem::createEditor() const
{
TQTextEdit* Editor = new TQTextEdit(table()->viewport());
Editor->setTextFormat(TQTextEdit::PlainText);
Editor->setHScrollBarMode(TQScrollView::AlwaysOff);
Editor->setVScrollBarMode(TQScrollView::AlwaysOff);
Editor->setBold(m_header);
Editor->setText(text());
TQObject::connect(Editor, TQT_SIGNAL(textChanged()), table(), TQT_SLOT(doValueChanged()));
return Editor;
}
void TableItem::setContentFromEditor(TQWidget *w)
{
if (w->inherits( TQTEXTEDIT_OBJECT_NAME_STRING ))
setText(((TQTextEdit*)w)->text());
else
TQTableItem::setContentFromEditor(w);
}
void TableItem::paint(TQPainter* p, const TQColorGroup& cg, const TQRect& cr, bool selected)
{
if (m_header) {
TQFont editFont = p->font();
editFont.setBold(true);
p->setFont(editFont);
}
TQRect cr0(0, 0, cr.width(), cr.height());
if (selected) {
p->fillRect(cr0, cg.brush(TQColorGroup::Highlight));
p->setPen(cg.highlightedText());
}
else {
p->fillRect(cr0, cg.brush(TQColorGroup::Base));
p->setPen(cg.text());
}
if (!pixmap().isNull()) {
p->drawPixmap(4, 4, pixmap());
p->drawText(6 + pixmap().width(), 4, cr0.width()-8, cr0.height()-8, m_halign | m_valign | WordBreak, text());
}
else
p->drawText(4, 4, cr0.width()-8, cr0.height()-8, m_halign | m_valign | WordBreak, text());
}
TQSize TableItem::sizeHint() const
{
TQSize size = TQTableItem::sizeHint();
size.setWidth(size.width()+8);
size.setHeight(size.height()+8);
return size;
}
|