Subversion Repositories tpanel

Rev

Rev 420 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 420 Rev 421
Line 17... Line 17...
17
 */
17
 */
18
 
18
 
19
#include <QPainter>
19
#include <QPainter>
20
#include <QEvent>
20
#include <QEvent>
21
#include <QKeyEvent>
21
#include <QKeyEvent>
-
 
22
#include <QApplication>
22
 
23
 
23
#include "tqtextedit.h"
24
#include "tqtextedit.h"
24
#include "terror.h"
25
#include "terror.h"
25
 
26
 
26
using std::string;
27
using std::string;
27
 
28
 
28
TQTextEdit::TQTextEdit(QWidget* parent)
29
TQTextEdit::TQTextEdit(QWidget* parent)
29
    : QLabel(parent)
30
    : QWidget(parent)
30
{
31
{
31
    DECL_TRACER("TQTextEdit::TQTextEdit(QWidget* parent)");
32
    DECL_TRACER("TQTextEdit::TQTextEdit(QWidget* parent)");
32
 
33
 
33
    init();
34
    init();
34
}
35
}
35
 
36
 
36
TQTextEdit::TQTextEdit(const QString& text, QWidget* parent)
37
TQTextEdit::TQTextEdit(const QString& text, QWidget* parent)
37
    : QLabel(parent),
38
    : QWidget(parent),
38
      mText(text)
39
      mText(text)
39
{
40
{
40
    DECL_TRACER("TQTextEdit::TQTextEdit(const QString& text, QWidget* parent)");
41
    DECL_TRACER("TQTextEdit::TQTextEdit(const QString& text, QWidget* parent)");
41
}
42
}
42
 
43
 
43
void TQTextEdit::init()
44
void TQTextEdit::init()
44
{
45
{
45
    DECL_TRACER("TQTextEdit::init()");
46
    DECL_TRACER("TQTextEdit::init()");
46
 
47
 
47
    setCursor(Qt::IBeamCursor);
48
    setCursor(Qt::IBeamCursor);
-
 
49
    setAutoFillBackground(true);
-
 
50
    update();
48
    setTextInteractionFlags(Qt::TextEditorInteraction);
51
//    setTextInteractionFlags(Qt::TextEditorInteraction);
49
    setTextFormat(Qt::PlainText);
52
//    setTextFormat(Qt::PlainText);
50
}
53
}
51
 
54
 
52
void TQTextEdit::setText(const QString& text)
55
void TQTextEdit::setText(const QString& text)
53
{
56
{
54
    DECL_TRACER("TQTextEdit::setText(const std::string& text)");
57
    DECL_TRACER("TQTextEdit::setText(const std::string& text)");
55
 
58
 
56
    if (mText != text)
59
    if (mText != text)
57
    {
60
    {
58
        mText = text;
61
        mText = text;
59
        repaint();
62
        update();
60
    }
63
    }
61
}
64
}
62
 
65
 
63
bool TQTextEdit::event(QEvent* event)
66
bool TQTextEdit::event(QEvent* event)
64
{
67
{
Line 164... Line 167...
164
    DECL_TRACER("TQTextEdit::append(const QString& txt)");
167
    DECL_TRACER("TQTextEdit::append(const QString& txt)");
165
 
168
 
166
    mText += txt;
169
    mText += txt;
167
//    QLabel::setText(mText);
170
//    QLabel::setText(mText);
168
    mPos = mText.length();
171
    mPos = mText.length();
169
    repaint();
172
    update();
170
}
173
}
171
 
174
 
172
void TQTextEdit::insert(const QString& txt, int pos)
175
void TQTextEdit::insert(const QString& txt, int pos)
173
{
176
{
174
    DECL_TRACER("TQTextEdit::insert(const QString& txt, int pos)");
177
    DECL_TRACER("TQTextEdit::insert(const QString& txt, int pos)");
Line 176... Line 179...
176
    if (mText.isEmpty())
179
    if (mText.isEmpty())
177
    {
180
    {
178
        mText = txt;
181
        mText = txt;
179
//        QLabel::setText(mText);
182
//        QLabel::setText(mText);
180
        mPos = mText.length();
183
        mPos = mText.length();
181
        repaint();
184
        update();
182
        return;
185
        return;
183
    }
186
    }
184
 
187
 
185
    if (pos >= 0)
188
    if (pos >= 0)
186
    {
189
    {
Line 208... Line 211...
208
    {
211
    {
209
        mText = txt + mText;
212
        mText = txt + mText;
210
        mPos += txt.length();
213
        mPos += txt.length();
211
    }
214
    }
212
 
215
 
213
    repaint();
216
    update();
214
//    QLabel::setText(mText);
217
//    QLabel::setText(mText);
215
}
218
}
216
 
219
 
217
void TQTextEdit::setAlignment(Qt::Alignment al)
220
void TQTextEdit::setAlignment(Qt::Alignment al)
218
{
221
{
Line 255... Line 258...
255
    else if (mAlignment & Qt::AlignBottom)
258
    else if (mAlignment & Qt::AlignBottom)
256
        mPosY = height() - mPadBottom - mTextHeight / 2;
259
        mPosY = height() - mPadBottom - mTextHeight / 2;
257
 
260
 
258
    MSG_DEBUG("Font point size: " << mFontPointSize << ", text length: " << mTextLength << ", text height: " << mTextHeight);
261
    MSG_DEBUG("Font point size: " << mFontPointSize << ", text length: " << mTextLength << ", text height: " << mTextHeight);
259
    MSG_DEBUG("Pos X: " << mPosX << ", Pos Y: " << mPosY);
262
    MSG_DEBUG("Pos X: " << mPosX << ", Pos Y: " << mPosY);
-
 
263
//    QApplication::processEvents();
260
    repaint();
264
    update();
261
}
265
}
262
 
266
 
263
void TQTextEdit::setBackgroundPixmap(const QPixmap& pixmap)
267
void TQTextEdit::setBackgroundPixmap(const QPixmap& pixmap)
264
{
268
{
265
    DECL_TRACER("TQTextEdit::setBackgroundPixmap(const QPixmap& pixmap)");
269
    DECL_TRACER("TQTextEdit::setBackgroundPixmap(const QPixmap& pixmap)");
266
 
270
 
267
    if (pixmap.isNull())
271
    if (pixmap.isNull())
268
        return;
272
        return;
269
 
273
 
270
    mBackground = pixmap;
274
    mBackground = pixmap;
271
    setPixmap(mBackground);
275
//    setPixmap(mBackground);
-
 
276
//    QApplication::processEvents();
272
    repaint();
277
    update();
273
}
278
}
274
 
279
 
275
void TQTextEdit::resizeEvent(QResizeEvent *evt)
280
void TQTextEdit::resizeEvent(QResizeEvent *evt)
276
{
281
{
277
    DECL_TRACER("TQTextEdit::resizeEvent(QResizeEvent *evt)");
282
    DECL_TRACER("TQTextEdit::resizeEvent(QResizeEvent *evt)");
278
 
283
 
279
    updateCoordinates();
284
    updateCoordinates();
280
    QLabel::resizeEvent(evt);
285
    QWidget::resizeEvent(evt);
281
}
286
}
282
 
287
 
283
void TQTextEdit::paintEvent(QPaintEvent*)
288
void TQTextEdit::paintEvent(QPaintEvent*)
284
{
289
{
285
    DECL_TRACER("TQTextEdit::paintEvent(QPaintEvent*)");
290
    DECL_TRACER("TQTextEdit::paintEvent(QPaintEvent*)");